
/*
	------------- ASU Discovery Co.,Ltd -------------
	
	CreateDate: 2008-11-15 12:18
	UpdateDate: 2008-11-19 10:22
	Created by programmer UGTAKHBAYAR Mandakh
	Updated by programmer IDERBAYAR	Jamsranjav
	-------------------------------------------------
	General user defined function
	
	
*/

var querywindow = '';

function OpenWindow(url,p_height,p_top){
	
    if (!querywindow.closed && querywindow.location) {
        querywindow.focus();
    } else {
		//alert(url+'&scrolltop='+p_top);
		querywindow=window.open(url,'','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=no,top=1,left=1,width=500,height='+p_height);
    }

    if (!querywindow.opener) {
        querywindow.opener = self;
    }

	querywindow.location=url;

	if (window.focus) {		
        querywindow.focus();
    }

    return false;
}

function ShowPage(f,elm){
	f.activepage.value=elm;
	f.submit();
}

function IsEmpty(elm,msg){
	if(elm.value==""){
		alert(msg+" нь хоосон байна!");
		elm.focus();
		return true;
	} else return false;
}

function IsNum(elm,msg,cc){
	if(isNaN(elm.value)){
    	alert(msg+" нь тоо байх ёстой!");
		elm.value="";
		elm.focus();
		return false;
	}
	else if(parseFloat(elm.value)<=0 && cc!=1){
		alert(msg+" нь 0-ээс багагүй байх ёстой!");
		elm.value="";
		elm.focus();
		return false;
	}
	return true;
}

function IsEmail(elm){
	// checks if the e-mail address is valid
	/*
	var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	var matchArray = elm.value.match(emailPat);
	if (matchArray == null) {
		alert("Таны и-мэйл хаягийн бичилт буруу байна!");
		elm.focus();
		elm.select();
		return false;
	}
	return true;
	*/
	//alert("validating");
	emailRegEx = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	if (!elm.value.match(emailRegEx)){
		alert("И-мэйл хаягийн бичилт буруу байна!");
		elm.focus();
		elm.select();
		return false;
	}
	return true;
}

function WriteDate(){
	var now = new Date();
	var month = now.getMonth();
	var day = now.getDate();
	var year = now.getYear();
	var yearname;
	if(year < 1000) year+=1900;
	if(!yearname) yearname = year;
	document.write("<font face='Tahoma' color='#000000'>");
	document.write(yearname+" оны "+(month+1)+ "-р сарын " +day);
	document.write("</font>");
}

/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
	target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"


//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

/*
	var message="";
	
	function clickIE() {if (document.all) {(message);return false;}}
	function clickNS(e) {if
	(document.layers||(document.getElementById&&!document.all)) {
	if (e.which==2||e.which==3) {(message);return false;}}}
	if (document.layers)
	{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
	else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
	
	document.oncontextmenu=new Function("return false")
*/

// -->


