// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// holds the remote server address 
var serverAddress = "newsout/newsprint_js.php";
// when set to true, display detailed error messages
var showErrors = true;
// initialize the validation requests cache 
var cache = new Array();

// creates an XMLHttpRequest instance
function createXmlHttpRequestObject() 
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    {
      try 
      { 
        // try to create XMLHttpRequest object
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {} // ignore potential error
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    displayError("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

// function that displays an error message
function displayError($message)
{
  // ignore errors if showErrors is false
  if (showErrors)
  {
    // turn error displaying Off
    showErrors = false;
    // display error message
 
    alert("Error encountered: \n" + $message);
    // retry validation after 10 seconds
    setTimeout("validate();", 10000);
  }
}

// function that handles the HTTP response
function handleRequestStateChange() 
{
  // when readyState is 4, we read the server response
  if (xmlHttp.readyState == 4) 
  {
    // continue only if HTTP status is "OK"
    if (xmlHttp.status == 200) 
    {
      try
      {
        // read the response from the server
        readResponse();
      }
      catch(e)
 
      {
        // display error message
        displayError(e.toString());
      }
    }
    else
    {
      // display error message
      displayError(xmlHttp.statusText);
    }
  }
}

function showUser(str){	
	var url="bm_stuffs/outlet/js_rate.php"
	url=url+"?cntry_en="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedShow ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChangedShow(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 	} 
}

/***********SHOW PRINT NEWS ******************/
function ShowPrint(str){	
	var url="newsout/newsprint_js.php"
	url=url+"?id="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedPrint ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}


function Show24Print(str){	
	var url="newsout/newslist_js.php"
	url=url+"?page="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedPrint ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function ShowPrintComment(str, ner, comment, button){	
	var url="newsout/newsprint_js.php"
	if (ner=="" || ner==null || comment=="" || comment==null){
		alert("Та нэр юм уу сэтгэгдлээ хоосон орхисон байна !!!");
	}else{

	url=url+"?id="+str+"&ner="+ner+"&comment="+comment;
	url=url+"&sid="+Math.random();
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedPrint ;
			xmlHttp.send(null);
			
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
	}
}


function stateChangedPrint(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("content_top").innerHTML=xmlHttp.responseText 
 	} 
}

/***********SHOW MENU SELECTION ******************/
function MenuClick(str1, str2){	
	var url="menu/menu_js.php"
	url=url+"?current="+str1+"?sub="+str2
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedMenu ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}
function stateChangedMenu(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("content_top").innerHTML=xmlHttp.responseText 
 	} 
}

/***********MULTI BETAMAX CHANGER ******************/
function showUser_1(str){	
	var url="bm_stuffs/outlet/js_multi.php"
	url=url+"?cntry_en_1="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChanged_1 ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChanged_1(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("MultiTxtHint").innerHTML=xmlHttp.responseText 
 	} 
}


function showUser_2(str){	
	var url="bm_stuffs/outlet/js_multi.php"
	url=url+"?cntry_en_2="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChanged_2 ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChanged_2(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("MultiTxtHint").innerHTML=xmlHttp.responseText 
 	} 
}


function showUser_3(str,cntry){	
	var url="bm_stuffs/outlet/js_multi.php"
	url=url+"?cntry_en_3="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChanged_3 ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChanged_3(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("MultiTxtHint").innerHTML=xmlHttp.responseText 
 	} 
}


function showUser_4(str){	
	var url="bm_stuffs/outlet/js_multi.php"
	url=url+"?cntry_en_4="+str
	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChanged_4 ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChanged_4(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("MultiTxtHint").innerHTML=xmlHttp.responseText 
 	} 
}

function checkmail_g10(f,e,s){
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var bufemail="-- Имэйл хаягаа зөв бичнэ үү. \r\n (Жнь: mn_gmobile@yahoo.com)";
var bufsel="--Утасны дугаараа Сонгоно уу.\r\n";
var retback=true;
var codefilter=/^\d+$/;
var returnemail=emailfilter.test(e.value);
	if (returnemail==false || s.value=="none"){
		if (returnemail!==false){
			bufemail="";
			retback=false;
		}
		if (s.value!=="none"){
			bufsel="";
			retback=false;
		}
		alert(bufsel+bufemail);
	}else {
		showPop10(f);
	}
	return retback;
}

function checkmail_g30(f,e,s){
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var bufemail="-- Имэйл хаягаа зөв бичнэ үү. \r\n (Жнь: mn_gmobile@yahoo.com)";
var bufsel="--Утасны дугаараа Сонгоно уу.\r\n";
var retback=true;
var codefilter=/^\d+$/;
var returnemail=emailfilter.test(e.value);
	if (returnemail==false || s.value=="none"){
		if (returnemail!==false){
			bufemail="";
			retback=false;
		}
		if (s.value!=="none"){
			bufsel="";
			retback=false;
		}
		alert(bufsel+bufemail);
	}else {
		showPop30(f);
	}
	return retback;
}

function showPop10(form){	
	var obj1 = form.elements["gnum_g10"];
	var obj2 = form.elements["email_g10"];
	var obj3 = form.elements["sid"];
	var obj4 = form.elements["time"];
	var url="gmobile/transfer.php";
	url=url+"?gnum="+obj1.value+"&email="+obj2.value+"&sid="+obj3.value + "&time="+obj4.value;
	//only continue if xmlHttp isn't void
	var Win2 = window.open(url, "mywindow", "width=850, height=700");
	Win2.moveTo(300,100);
}

function showPop30(form){	
	var obj1 = form.elements["gnum_g30"];
	var obj2 = form.elements["email_g30"];
	var obj3 = form.elements["sid"];
	var obj4 = form.elements["time"];
	var url="gmobile/transfer.php";
	url=url+"?gnum="+obj1.value+"&email="+obj2.value+"&sid="+obj3.value + "&time="+obj4.value;
	//only continue if xmlHttp isn't void
	var Win2 = window.open(url, "mywindow", "width=850, height=700");
	Win2.moveTo(300,100);
}

function clickinv(id,str){
	if(id.value==str){
		id.value=''; 
		id.style.font='Arial 15px';
		id.style.color='#000000';
	}
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Roman Feldblum (web.developer@programmer.net) -->

<!-- Begin
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==4){
	//d10=p.indexOf('(')
	pp=p;
	d5=p.indexOf('-')
	if(d5==-1){
		pp=pp+"-";
	}
	//pp="("+pp+")";
	document.gForm.birthday.value="";
	document.gForm.birthday.value=pp;
}

if(p.length>4){
	d1=p.indexOf('-')
	d2=p.indexOf('-')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,5);
		//alert(p30);
		p30=p30+"-"
		p31=p.substring(5,7);
		pp=p30+p31;
		//alert(p31);
		document.gForm.birthday.value="";
		document.gForm.birthday.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,4);
	p14=p11.substring(4,6);
	p15=p.substring(d2+1,12);
	document.gForm.birthday.value="";
	pp=p13+"-"+p14+p15;
	document.gForm.birthday.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+3);
		p18=p.substring(d2+3,12);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.gForm.birthday.value="";
	document.gForm.birthday.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m,str){
	clickinv(m,str);
n=m.name;
//p1=document.forms[0].elements[n]
p1=m

	ValidatePhone()

}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
/*****************************************************************/



function showVideo(str){	
	var url="playlist/index.php"

	url=url+"&sid="+Math.random()
	//only continue if xmlHttp isn't void
	if (xmlHttp){
		//try to connect to the server
		try{
			//ask for permission to call remote server, for Mozilla-based browsers
			try{
				//this generates an error (that we ignore) if the browser is not Mozilla
				netscape, security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
			}catch (e) {} //ignore error
			//initiate server access
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=stateChangedVideo ;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e){
			alert ("Can't connect to server:\n" +e.toString());
		}
	}
}

function stateChangedVideo(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("showwholelist").innerHTML=xmlHttp.responseText 
 	} 
}


function bankselected(selectobj){
	var bankNum1='<table  align="center" >	<tr><td>Банк:</td><td class="namebank"><strong>Kookmin bank (국민은행)</strong></td></tr> <tr><td>Дугаар: </td><td class="namebank"><strong>053602-04-123666';
	var bankNum2='<table  align="center" >	<tr><td>Банк:</td><td class="namebank"><strong>Woori bank (우리은행)</strong></td></tr> <tr><td>Дугаар: </td><td class="namebank"><strong>1002-233-601009';
	var bankNum3='<table  align="center" >	<tr><td>Банк:</td><td class="namebank"><strong>IKB банк(기업은행)</strong></td></tr> <tr><td>Дугаар: </td><td class="namebank"><strong>010-057463-02-015';
	var bankNum4='<table  align="center" >	<tr><td>Банк:</td><td class="namebank"><strong>NongHyup банк(농협은행)</strong></td></tr> <tr><td>Дугаар: </td><td class="namebank"><strong>024-02-236485';
	var banksInfo2='</strong><br /></td></tr><tr><td>Эзэмшигч: </td><td class="namebank"><strong>Davaa </strong><br /></td></tr></table>';
	
    if (selectobj=="bank1"){			 
	 document.getElementById("banksinform").innerHTML=(bankNum1+banksInfo2);
	 }
	 if(selectobj=="bank2"){
	document.getElementById("banksinform").innerHTML= (bankNum2+banksInfo2);
	 }
	 if (selectobj=="bank3"){
	 document.getElementById("banksinform").innerHTML= (bankNum3+banksInfo2);
	 }
	 if (selectobj=="bank4"){
	 document.getElementById("banksinform").innerHTML= (bankNum4+banksInfo2);
	 }
}

