
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/********************************************************************/
/********************************************************************/
/********************************************************************/

function SetFocus(Cntrl)
{
	var Control = document.getElementById(Cntrl);
	if (window.event.keyCode == 13)	
		Control.focus(Cntrl);
}



function getConfirm(msg)
{
	return confirm(Msg);
}

function PopupDialog(Path,Height,Width,Winname)
	{	
		var result
		result = window.showModalDialog(Path,Winname,"dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;scroll:yes;help:no;status:no");
		return (result);
	}
function PopupWin(Path,Height,Width)
	{
		window.open(Path,"new_page","Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	   //window.showModalDialog(Path,"","dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;scroll:no;help:no;status:no");
	}
	function PopupWin1(Path,Height,Width,Title)
	{
		window.open(Path,Title,"Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=no,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	   //window.showModalDialog(Path,"","dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;scroll:no;help:no;status:no");
	}
	
	function ViewImage1(ImageName)
	{
		var m1 = new Image();
		m1.src=ImageName;
		var m = new Image();
		m.src=ImageName;
		Width = m.width;
		Height = m.height;
		var winl = ((screen.width/2)-(Width/2));
		var wint = ((screen.height/2)-(Height/2));
		winprops = 'height='+m.height+',width='+m.width+',top='+wint+',left='+winl+',resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no';
		var msgWindow = window.open('','',winprops);
		msgWindow.document.open();
		msgWindow.document.write('<title>Constitutional Court</title><body bgcolor="#f6f8f4" onBlur="self.close()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td valign=middle align=center><IMG BORDER="0" SRC="' + ImageName + '"></td></tr></table></body>');
		msgWindow.document.close();
	}
	
	
	function ViewImage(ImageName,Height,Width)
	{
		//alert(ImageName);
		var winl = ((screen.width/2)-(Width/2));
		var wint = ((screen.height/2)-(Height/2));
		//alert(DetArr.length+DetArr[0]+DetArr[1]+DetArr[2]);
		winprops = 'height='+Height+',width='+Width+',top='+wint+',left='+winl+',resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no';
		var msgWindow = window.open('','',winprops);
		msgWindow.document.open();
		msgWindow.document.write('<title>مرحبا بك في تربية نت</title><body bgcolor="#f6f8f4" onBlur="self.close()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td valign=middle align=center><IMG BORDER="0" SRC="' + ImageName + '"></td></tr></table></body>');
		msgWindow.document.close();
	}
	
	function ViewFlash(ImageName)
	{
		//alert(ImageName);
		//Width = 
		//var winl = ((screen.width/2)-(Width/2));
		//var wint = ((screen.height/2)-(Height/2));
		//alert(DetArr.length+DetArr[0]+DetArr[1]+DetArr[2]);'height='+Height+',width='+Width+',top='+wint+',left='+winl+',
		winprops = 'resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no';
		var msgWindow = window.open('','',winprops);
		msgWindow.document.open();
		
		ImgBnr	= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"  ID=\"Object1\" VIEWASTEXT>";
										ImgBnr	+= "<param name=\"movie\" value=\""+ImageName+"\">";
										ImgBnr	+= "<param name=\"quality\" value=\"high\">";
										ImgBnr	+= "<param name=\"WMode\" value=\"Transparent\">";
										ImgBnr	+= "<embed src=\""+ImageName+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" ></embed>";
										ImgBnr	+= "</object>";
		
		msgWindow.document.write('<title>مرحبا بك في تربية نت</title><body bgcolor="#f6f8f4" onBlur="self.close()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td valign=middle align=center>' + ImgBnr + '</td></tr></table></body>');
		msgWindow.document.close();
	}
	function IsValidEmail(Email)
	{
		var regex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/ ;//  /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,3}$/
		//alert(Email + "\n" + regex.test(Email));
		if (!regex.test(Email)) 
			return (false);
		else
			return (true);   

	}
	
	
	function IsValidUrl(Url)
	{

		var regex = /^https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?$/ ;
		if (!regex.test(Url)) 
			return (false);
		else
			return (true);   

	}
	
	
	
	
	/***********************************************************/
	/***********************************************************/
	/**************** Getting Driving Direction ****************/
	/***********************************************************/
	/***********************************************************/
	/***********************************************************/
	
	function Popup(Path,Height,Width)
	{	var result
		//window.open(Path,"","Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	  result = window.showModalDialog(Path,"","dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;scroll:no;help:no;status:no");
	  //if (result == null)
		//	result = "";
	  return (result);
	}
	
	
function checkFrmTwoPoints(msg)
{
	if(document.frmMOL.txtPntOfIntrst.value=="")
		{
			alert(msg);
			return false;
		}
	else
		return true;
}
// this function will open a dialog page in which the user can select...
// a landmark name
// the selection which is the returned value from the dialog..
// will be written in the text field passed to the function.
function writeLmkNameFromList(lmkNameText,hidValue)
{
	var result;
	result = Popup('dialog.aspx?dialogID=1',325,400);
	if (result != null) 
	{
		var msg= result.split(";");
		lmkNameText.value = msg[0];
		hidValue.value = msg[1];
	}
}

// this function will open a dialog page containing the results of..
// searching for the name inside the text passed to the function...
// the selection which is the returned value from the dialog..
// will be written in the text field...
function writeLmkNameFromFindResults(lmkNameText,hidRefNo,msg)
{
	var result;
	alert(lmkNameText);
	if (lmkNameText.value != "")
	{
	
		
	
		path = 'dialog.aspx?dialogID=2&lmkname=' + escape(lmkNameText.value);
		alert(path);
		result = Popup(path,260,350)
		if (result != null)
			{
				var msg= result.split(";");
				lmkNameText.value = msg[0];
				
				hidRefNo.value = msg[1];
			}
	}
	else
		{
			alert(msg);
		}
}
	
