/******Ankhbayar********/
function viewsub(id){
	document.getElementById(id).innerHTML = '';
	document.getElementById('title' + id).innerHTML = '<img src="images/plus.gif" onclick="expandsub(\''+ id +'\');">';
}
function expandsub(id){
	document.getElementById('title' + id).innerHTML = '<img src="images/minus.gif" onclick="viewsub(\''+id+'\');">';
	if(id == "id1")	document.getElementById(id).innerHTML 	= '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Complimentary international buffet breakfast</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td width="40%" align="left">Free weekly  newspaper "Mongol messenger"</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr></table>';
	if(id == "id2")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Color TV</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td align="left">Cable  TV</td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td></tr></table>';
	if(id == "id3")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Mini bar </td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td align="left">Coffee maker </td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"> </td><td align="center"> </td></tr></table>';
	if(id == "id4")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Work desk / lamp</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td align="left">PC in room </td><td align="center"> </td><td align="center"> </td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"> </td></tr><tr><td align="left">Living room </td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"> </td><td align="center"> </td></tr>	</table>';
	if(id == "id5")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Broadband high speed internet access</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr>	</table>';
	if(id == "id6")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Baby crib upon request</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td align="left">In room safe deposit boxes</td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center">Upon request</td></tr></table>';		
	if(id == "id7")	document.getElementById(id).innerHTML = '<table border="0" width="100%" class="display_div" cellspacing="0"><tr><td width="40%" align="left">Bathrobe</td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td><td align="center" width="15%"><img src="images/yes.gif" border="0"></td></tr><tr bgcolor="#A0C0E9"><td align="left">Hairdryer</td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"><img src="images/yes.gif" border="0"></td><td align="center"> </td><td align="center"> </td></tr></table>';
}

function toggleFolder(a){
		var g=document.getElementById("id"+a);
	  if (g.style.display=='')
	  g.style.display='none';
	  else 
	  g.style.display='';
	  
}

function d(id1){	
	if(lastrowid != -1)
		try{
			lastrowid.id = lastcurrent;
		}
		catch(e){}
	lastcurrent = id1.id;
	lastrowid = id1;
	id1.id = 'current';
}

function d1(id2){
	document.getElementById('select').id='';
	id2.id='select';
}

/****************/
function change_image(image){	
	document.getElementById('maindiv').innerHTML='<img class="main-image" name="main" id="main" src="images/gallery/'+image+'.jpg" align="center">';	
}
function change_image1(image){	
	document.getElementById('maindiv').innerHTML='<img name="main" id="main" src="images/gallery/'+image+'.jpg" align="center">';	
}
function loading(id){
	document.getElementById(id).innerHTML = '<img src="images_new/ajax-loader23.gif" align="center">';
}

var lastrowcolor;
var lastrowid = -1;
function selectRow(id, bkcolor){
	if(lastrowid != -1)
		try{
			document.getElementById(lastrowid).style.background = lastrowcolor;
		}
		catch(e){}
	lastrowcolor = document.getElementById(id).style.background;
	lastrowid = id;
	document.getElementById(id).style.background = bkcolor;
}



/***********user register**********Ankhbayar*************/
//var pwds=['password','abc123','myspace','blink182','qwerty','fuckyou','123abc','baseball','football','123456','1234567','12345678','soccer','monkey','liverpool','princess','jordan','jordan23','slipknot','superman','iloveyou','123123','123456789','access','administrator','adminadmin'];
var name,name1,birth,gender,zip,city,phone,fax,address,state,coutry,email,code;
function check_name(l,id){
      //var l=document.regform.name;
      if (l.value.length<3 || l.value.length>35){
            name=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"><span class="copy">'+"Firstname"+'</span>';
      }
      else {
            name=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

function check_name1(l,id){
      //var l=document.regform.name;
      if (l.value.length<3 || l.value.length>35){
            name1=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"><span class="copy">'+"Lastname"+'</span>';
      }
      else {
            name1=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

/*function check_birth(){
      if (document.regform.by.value==0 || document.regform.bm.value==0 || document.regform.bd.value==0){
            birth=0;
            document.getElementById('chf_birth').innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            birth=1;
            document.getElementById('chf_birth').innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}
*/
function check_gender(l,id){
      if (l.value==0){
            gender=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            gender=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

/*function check_zip(l,id,limit){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(l.value) && l.value.length<limit){
           zip=1;
           document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            zip=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">&nbsp;Maximal zip length is 3 characters';
      }
      allowreg();	
}*/

function check_city(l,id){
      //var l=document.regform.name;
      if (l.value.length<=3 || l.value.length>35){
            city=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">&nbsp;Minimal city length is 3 characters';
      }
      else {
            city=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

function check_phone(l,id,limit){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(l.value) && l.value.length<=limit){
            phone=1;
           document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            phone=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">&nbsp;Maximal phone length is 12 characters';
      }
      allowreg();	
}

/*function check_fax(l,id,limit){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(l.value) && l.value.length<=limit){
           fax=1
           document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            fax=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">&nbsp;Maximal fax length is 12 characters';
      }
      allowreg();	
	
}*/
function check_address(l,id){
	  //var l=document.regform.name;
      if (l.value.length<3 || l.value.length>35){
            address=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"><span class="copy">Address</span>';
      }
      else {
            address=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();	
}

function check_state(l,id){
	  //var l=document.regform.name;
      if (l.value.length<3 || l.value.length>35){
            state=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">&nbsp;Minimal password length is 2 characters';
      }
      else {
            state=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();	
	
}

function check_country(l,id){
      if (l.value==-1){
            coutry=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            coutry=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}


function check_email(l,id){
      //var l=document.regform.email;
      if (!l.value.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,6}$/)){
            email=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Incorrect e-mail</span>';
      }
      else {
            email=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

function check_code(l,id,limit){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(l.value) && l.value.length<limit){
           code=1;
           document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      else {
            code=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();	
}
/*

function check_pass0(id){
      var is=0;
      for (var i=0;i<pwds.length;i++){
            if (document.regform.password.value==pwds[i] || document.regform.password.value==pwds[i]+'1'){
                  is=1;
            }
      }
      if (document.regform.password.value.match(/^(.)\1*$/)){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Password must contain various characters</span>';
      }
      else if (document.regform.password.value.length>15){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Maximal password length is <b>15</b> characters</span>';
      }
      else if (document.regform.password.value.length<6){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Minimal password length is <b>6</b> characters</span>';
      }
      else if (document.regform.password.value=='kDi3p9S7'){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy"></span>';
      }
      else if (document.regform.password.value.match(/[^a-zA-Z0-9\-_]/)){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Password contains illegal characters</span>';
      }
      else if (is==1){
            che12=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Too simple password</span>';
      }
      else {
            che12=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}

function check_pass(id){
      var p1=document.regform.password;
      var p2=document.regform.password1;
      if (p1.value!=p2.value){
            che2=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">Password confirmation error</span>';
      }
      else if (che12!=1){
            che2=0;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/chu.gif" align="absmiddle" width="16" height="16"> <span class="copy">&quot;Password&quot; field is filled in incorrectly</span>';
      }
      else {
            che2=1;
            document.getElementById(id).innerHTML='<img border="0" src="images_new/reg/ch.gif" align="absmiddle" width="16" height="16">';
      }
      allowreg();
}*/
function allowreg(num){
      //if (name==1 && name1==1 && birth==1 && gender==1 && zip==1 && city==1 && phone==1 && fax==1 && address==1 && state==1 && coutry==1 && email==1){
      if (name==1 && name1==1 && gender==1 && city==1 && phone==1 && address==1 && state==1 && coutry==1 && email==1){
            document.getElementById('sbm').disabled=false;
      }
      else {
            document.getElementById('sbm').disabled=true;
      }
}



var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function drag_drop(e){
	if (ie5&&dragapproved&&event.button==1){
		document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx
		document.getElementById("dwindow").style.top=tempy+event.clientY-offsety
		}
	else if (ns6&&dragapproved){
		document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx
		document.getElementById("dwindow").style.top=tempy+e.clientY-offsety
		}
	}

function initializedrag(e){
	offsetx=ie5? event.clientX : e.clientX
	offsety=ie5? event.clientY : e.clientY
	
	if (ie5) document.getElementById("saver").style.display=''

	tempx=parseInt(document.getElementById("dwindow").style.left)
	tempy=parseInt(document.getElementById("dwindow").style.top)

	dragapproved=true
	document.onmousemove=drag_drop
	}
	
function loadwindow2(url,width,height){
	if (!ie5&&!ns6){	
		window.open(url,"","width=width,height=height,scrollbars=1")
	}
	else{
		document.getElementById("dwindow").style.display=''
		document.getElementById("dwindow").style.width=initialwidth=width
		document.getElementById("dwindow").style.height=initialheight=height
		document.getElementById("dwindow").style.left=document.body.clientWidth/2-300
		document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30 : document.body.scrollTop*1+30
		document.getElementById("cframe").src=url
		}
	}

function maximize(){
	if (minrestore==0){
		minrestore=1 //maximize window
		document.getElementById("maxname").setAttribute("src","restore.gif")
		document.getElementById("dwindow").style.width=ns6? window.innerWidth-20 : document.body.clientWidth
		document.getElementById("dwindow").style.height=ns6? window.innerHeight-20 : document.body.clientHeight
		}
	else{
		minrestore=0 //restore window
		document.getElementById("maxname").setAttribute("src","max.gif")
		document.getElementById("dwindow").style.width=initialwidth
		document.getElementById("dwindow").style.height=initialheight
		}
	document.getElementById("dwindow").style.left=ns6? window.pageXOffset : document.body.scrollLeft
	document.getElementById("dwindow").style.top=ns6? window.pageYOffset : document.body.scrollTop
	}

function closeit(){
	document.getElementById("dwindow").style.display="none"
	}

if (ie5||ns6) document.onmouseup=new Function("dragapproved=false;document.onmousemove=null;document.getElementById('saver').style.display='none'")