// JavaScript Document
var myGlobalHandlers = {  
	onCreate: function(){
		var element      = document.getElementById('loading');  
		  var width        = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
		  var height       = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;

		  element.style.position = "absolute";
		  element.style.display  = "block";
		  element.style.left = (document.documentElement.scrollLeft+(width -350 )/2)+'px';
		  element.style.top  = '150px';
		Element.show('loading');
	},


	onComplete: function() {
		if(Ajax.activeRequestCount == 0){
			Element.hide('loading');
		}
	}
};

Ajax.Responders.register(myGlobalHandlers); 







function Ajax_Loader(url,container, param) { 
var params = param; 
var myAjax = new Ajax.Updater(
					{success: container}, 
					url, 
					{
						method: 'get', 
						parameters: params, 
						onFailure: reportError
					});
	if(container == 'popup')
	{
		popup_show('popup');
	}	
}



function reportError(request) {
	alert('Алдаа гарлаа. Та Refresh юмуу F5 дарна уу.');
}







function showUserProMenuL(menuid)
{
	obj = document.getElementById('main'+menuid);
	obj.style.display = 'inline';
}





function showUserProMenu(menuid, left, top, content)
{	
	obj = document.getElementById('main'+menuid);
//	if(menuid == 'menu4')
	//	left -= 134;
	if(menuid == 'menu5')
		left -= 65;
	var wd = 1024;	
	if (document.all)
	{wd = document.body.clientWidth;}
	else
	{wd = window.innerWidth;}
	obj.style.left = left+((wd-820)*80/333)+20+'px';
	obj.style.top = top+103+'px';
	//obj.innerHTML = '<div align="left" style="padding-bottom:10px;">'+content+'</div>';
	obj.style.display = 'inline';
}



function hideUserProMenu(menuid)
{
	obj = document.getElementById('main'+menuid);
	obj.style.display = 'none';
}



function popup_show(id)
{
  var element      = document.getElementById(id);  

  var width        = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
  var height       = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;

  element.style.position = "absolute";
  element.style.display  = "block";

  element.style.left = (document.documentElement.scrollLeft+(width -350 )/2)+'px';
  element.style.top  = (document.documentElement.scrollTop +(height-250)/2)+'px';
}



function regme()
{
	if((document.frmregister.txtname.value != "")
	 &&(document.frmregister.txtmail.value != "")&&(document.frmregister.txtpass1.value != "")&&(document.frmregister.txtpass2.value != ""))
	{
		document.frmregister.submit();
	}
	else
	{
		alert('Мэдээллийг гүйцэт бөглөнө үү!');
	}
}



function checkdata()
{
	if((document.frmaddnews.txtnewstitle.value != "")&&(document.frmaddnews.txtzar.value != "")
		&&(document.frmaddnews.txtphone.value != ""))
	{
		document.frmaddnews.submit();
	}
	else
	{
		alert('Мэдээллийг гүйцэт бөглөнө үү!');
	}
}