// Coding by Bataka tbatbaatar@yahoo.com 
// WEB  :  http://www.biirbeh.com  http://www.bbssoft.biz
// MAIL :  tbatbaatar@yahoo.com    info@bbssoft.biz
// Date :  2007-01-29

/// window on load function sss

		var achaallaj_baina=1;


window.onload = function () {
/*	
	var  pageurl = new String (document.location);
	  
	  pageurl = pageurl.split("?");
 
		if(  pageurl[1]  == undefined  ) 
		{
			requestPage('');
 		}
 */
	  

};

/// window on load function eee

/// get function sss
function requestPage(cmd) {
           // var sId = document.getElementById("PageId").value;
		   // alert (cmd);
			var cmds=cmd;	
			cmds = cmds.split("&");
		 //	alert (cmds[0]);
		//	alert (cmds[1]);
			
		if(achaallaj_baina==0)  return(0);	
			
				  //   var thisId123 = document.getElementById('right_menu_main');
				//	 thisId123.style.display ="" ;  
				/*
				if( cmds[0] == '?sel=announcement'  )
				{
					//	alert("q2");
				     var thisId123 = document.getElementById('right_menu_main');
					 thisId123.style.display ="" ;  
				     var thisId123 = document.getElementById('right_menu_announcement');
					 thisId123.style.display ="none" ;  
				}
				else
				{
					//	alert("q2");
				     var thisId123 = document.getElementById('right_menu_main');
					 thisId123.style.display ="none" ;  
				     var thisId123 = document.getElementById('right_menu_announcement');
					 thisId123.style.display ="" ;  
				}
			
			var cmds=cmd;

			cmds = cmds.split("&obj_id");
			
				if(  cmd  == '?sel=content&menu_id=1'  ||  cmd  == '?sel=contactus'  )
						//on_off('LeftBox', 1 )
				else 		
						//on_off('LeftBox', 0 )
			*/

//	  var  cmds =  listArray[0];
//?sel=content&menue_id=2&obj_id=34
//		alert(pageurl[1]);


	var divPageID = document.getElementById("divPage");
//    divPageID.value = "<img src=\"images/indicator_waitanim.gif\" border=0 />"; 
//	alert (divPageID.value);
//    divPageID.innerHTML =  "<img src=\"images/indicator_waitanim.gif\" border=0 />"; 
divPageID.innerHTML  = "<img src=\"images/indicator_waitanim.gif\" border=0 /> Ачааллаж байна ... <br> " + divPageID.innerHTML ; 

	achaallaj_baina = 0;
	
	
          var oXmlHttp = zXmlHttp.createRequest();
			
            oXmlHttp.open("get", "_function.php" + cmd, true);
            oXmlHttp.onreadystatechange = function () 
			{
                if (oXmlHttp.readyState == 4) 
				{
							displayPage("<img src=\"images/indicator_waitanim.gif\"  /> Ачааллаж байна  ...");
							
                    if (oXmlHttp.status == 200) 
						{
							displayPage(oXmlHttp.responseText);
							achaallaj_baina = 1;

						} 
					else 
						{
							//alert ("Loading");
						   //displayPage( "Loading..." );
							displayPage("An error occurred:  " + oXmlHttp.statusText); //statusText is not always accurate
						}
                }            
            };
            oXmlHttp.send(null);
        }
/// get function sss


   
// New post function sss         
        function requestPagep(cmd) {

//	var divPageID = document.getElementById("divPage");
//   divPageID.innerHTML = " <img src='images/indicator_waitanim.gif' border=0 />"; 

			var oForm = document.forms[0];
            var sBody = getRequestBody(oForm);
        
            var oXmlHttp = zXmlHttp.createRequest();
          oXmlHttp.open("post", "_function.php" + cmd , true);
            oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            
            oXmlHttp.onreadystatechange = function () {
                if (oXmlHttp.readyState == 4) 
				{
					
					displayPage(" <img src='images/indicator_waitanim.gif'  />");
					
                    if (oXmlHttp.status == 200) 
					{
                        displayPage(oXmlHttp.responseText);
                    } else 
					{
                        displayPage("An error occurred: post " + oXmlHttp.statusText);
                    }
                }            
            };
            oXmlHttp.send(sBody);        
        }
        
// New post  function eee

// post -r guideg yum bna le gej sss
	function getRequestBody(oForm) {
            var aParams = new Array();

            for (var i=0 ; i < oForm.elements.length; i++) {
                var sParam = encodeURIComponent(oForm.elements[i].name);
                sParam += "=";
                sParam += encodeURIComponent(oForm.elements[i].value);
                aParams.push(sParam);
            } 
            
            return aParams.join("&");        
        }
// post -r guideg yum bna le gej eee

        
// Displey show function  sss
        function displayPage(sText) {
            var divPage = document.getElementById("divPage");
            divPage.innerHTML = sText;
        }
// Displey show function  eee
    

//////////////////ADDITIONAL FUNCTION ///////////////////////////////////////
//////////////////ADDITIONAL FUNCTION ///////////////////////////////////////


function check_frmfriend(  )
{ // check form
		 var frm_fields = new Array(
						   "ymail" 	 , "Input your mail ?"  ,
						   "ycomment" 	 , "Input comment?"  
										  );
	   var s;
	  s=frm_fields.length/2;
		for (var i=0; i<s; i++)
			   if (document.getElementById(frm_fields[i*2]).value=="" )
			   { 
				alert(frm_fields[i*2+1]); document.getElementById(frm_fields[i*2]).focus();
				 return false;
				 break;
			   }
	var mail_input = frm_friend.ymail.value;
	var mail_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (mail_filter.test(mail_input))
	   return true;
	else 	
	{
		alert(" Your mail has syntax errors " ); frm_friend.ymail.focus();
		return false;
	  }  
} // check  form


 
function sub_category(sub_id)
{ // Answer

	var thisId = document.getElementById(sub_id);
//        thisId = document.all(sub_id);    
   if (thisId.style.display =="none")
    { 
     thisId.style.display = "";
    } 
   else 
    {
 	 thisId.style.display = "none";
    } 


} // Answer
 


