﻿// JScript File
function Popalbum(posTit){
    window.open(posTit,'','left=100,top=50,width=500,height=200,toolbar=0,scrollbars=1,status=0,resizeable=1');
}
function Popalbummail(){
    window.open('forwardtoafriend.aspx','','left=100,top=50,width=800,height=500,toolbar=0,scrollbars=1,status=0,resizeable=1');
}
function PopProgram(lst){
        if (lst.options[lst.selectedIndex].value!=-1){
        window.open('subp1.aspx?pageid='+lst.options[lst.selectedIndex].value,'','left=100,top=50,width=800,height=500,toolbar=0,scrollbars=1,status=0,resizeable=1');
        }    
}
function PopProgramByName(id){
        window.open(id,'','left=100,top=50,width=800,height=500,toolbar=0,scrollbars=1,status=0,resizeable=1');       
}
 function openIT(u,W,H, sc) {
		                var x = (screen.width - W) / 2;
		                var y = (screen.height - H) / 2;
		                //window.moveBy(left, top);
		                window.open(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+", left="+250+",top="+200);
                    }
                    //img,caption,date,description
function PopImage(img)
{
	//caption = escape(caption);
     //date = escape(date);
     //description = escape(description);
	 //openIT('pop_gl.htm?img='+img+"&caption="+caption+"&date="+date+"&description="+description,500,600);
	openIT('pop_gl.htm?img='+img,500,600);
}
function ValidateForm()
{
         var msg;
         var msg2;
	      msg=""
	   msg2="";
       if (document.getElementById('txtFirstName').value=="")
           msg +="- First Name\n"  
       if (document.getElementById('txtLastName').value=="")
           msg +="- Last Name\n" 
       if (document.getElementById('txtCompany').value=="")
            msg+="- Company\n"  
       if (document.getElementById('txtProfession').value=="")
            msg+="- Position\n"   
       if (document.getElementById('txtTelephone').value=="")
            msg+="- Telephone\n"       
       if (document.getElementById('ddlCountry').value=="")
            msg+="- Country\n"
       if (document.getElementById('txtCity').value=="")
            msg+="- City\n" 
	   if (document.getElementById('txtEmail').value=="")
		   msg +="- Email\n" 
		      else{
		            if (IsValidEmailAddress(document.getElementById('txtEmail'))==false)
	               msg2="- Invalid email address \n"}
	            if (msg!="")
	            {
	               msg="Please enter the following information:\n" + msg +msg2
		            alert(msg);
		            return false;
	            }
	            else{
	               if (msg2==""){
	               return true;
	               }else{
	                alert(msg2);
		            return false;}
		            }
	} 
	function IsValidEmailAddress(txt){
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
			return true;
		} else {
			return false;
		}
	}
} 
function ValidateFormCV()
{
         var msg;
         var msg2;
	      msg=""
	   msg2="";
       if (document.getElementById('txtFullName').value=="")
           msg +="- Full Name\n" 
	   if (document.getElementById('txtCV').value=="")
		   msg +="- Attach CV\n" 
	   if (document.getElementById('txtEmail').value=="")
		   msg +="- Email\n" 
		      else{
		            if (IsValidEmailAddress(document.getElementById('txtEmail'))==false)
	               msg2="- Invalid email address \n"}
	            if (msg!="")
	            {
	               msg="Please enter the following information:\n" + msg +msg2
		            alert(msg);
		            return false;
	            }
	            else{
	               if (msg2==""){
	               return true;
	               }else{
	                alert(msg2);
		            return false;}
		            }
	}
function ValidateSearch()
		{	
			var msg="";
			if ((document.getElementById('ControlRightMenu1_txtSearch').value=="") || (document.getElementById('ControlRightMenu1_txtSearch').value=="search our site"))
				msg +="- keyword\n" 
			if (msg!="")
			{
				msg="Please enter the following information:\n" + msg
				alert(msg);
				return false;
			}
			else
				return true; 
		}
function validateMail()
		{
			var msg="";
			if (document.getElementById('ControlRightMenu1_txtmailingList').value == "")
				msg +="- Email\n"
			else
			{
				if((document.getElementById('ControlRightMenu1_txtmailingList').value.indexOf('@', 0) == -1) || (document.getElementById('ControlRightMenu1_txtmailingList').value.indexOf('.') == -1) || (document.getElementById('ControlRightMenu1_txtmailingList').value.indexOf(' ') > 0) || (document.getElementById('ControlRightMenu1_txtmailingList').value.indexOf('#') > 0)) 
					msg +="- a valid Email Address\n" 
			}	 
			if (msg!="")
			{
				msg="Please enter the following information:\n" + msg
				alert(msg);
				return false;
			}
			else
				return true; 
		}
function ValidateNewsLetter()
{
         var msg;
         var msg2;
	      msg=""
	   msg2="";
       if (document.getElementById('txtFirstName').value=="")
           msg +="- First Name\n" 
       if (document.getElementById('txtLastName').value=="")
           msg +="- Last Name\n"
       if (document.getElementById('txtCompany').value=="")
           msg +="- Company\n" 
       if (document.getElementById('txtProfession').value=="")
           msg +="- Position\n" 
       if (document.getElementById('txtTelephone').value=="")
           msg +="- Telephone\n" 
       if (document.getElementById('ddlCountry').value=="")
           msg +="- Country\n" 
       if (document.getElementById('txtcity').value=="")
           msg +="- City\n" 
	   if (document.getElementById('txtEmail').value=="")
		   msg +="- Email\n" 
		      else{
		            if (IsValidEmailAddress(document.getElementById('txtEmail'))==false)
	               msg2="- Invalid email address \n"}
	            if (msg!="")
	            {
	               msg="Please enter the following information:\n" + msg +msg2
		            alert(msg);
		            return false;
	            }
	            else{
	               if (msg2==""){
	               return true;
	               }else{
	                alert(msg2);
		            return false;}
		            }
	} 
function print_function()
{     
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
		disp_setting+="scrollbars=yes,width=600, height=500, left=100, top=100";
	var content_vlue = document.getElementById("mycustomscroll").innerHTML;
	/*var title_vlue = document.getElementById("Title").innerHTML;*/

	var docprint=window.open("","",disp_setting);

	docprint.document.open();
	docprint.document.write('<html><head><title> Arabian Media Services</title><style> a{color:#000; text-decoration:none;}</style>');
	docprint.document.write('<link href="CSS/styles.css" type="text/css" rel="stylesheet" media="screen" /></head><body onLoad="self.print(); self.close();" >');
	docprint.document.write('<table width="100%" style="padding:20px;font-family:Arial, Helvetica, sans-serif;font-weight:normal;letter-spacing:normal;background:#ffffff;font-size:10px;color:#6d6e71;" cellspacing="0" cellpadding="0" border="0">');
	docprint.document.write('<tr><td style="border-bottom:solid 2px #6d6e71;padding-bottom:10px;"><img src="images/ams-logo-print.gif"/></td></tr>');
	docprint.document.write('<tr><td><br>'+content_vlue+'</td></tr></table>');
	docprint.document.write('</body></html>');
	docprint.document.close(); 
 	docprint.focus();
}
function OpenWnd(mypage, myname, w, h, scroll)

{
      var winl = (screen.width - w) / 2;
      var wint = (screen.height - h) / 2;
      winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=No'
      win = window.open(mypage, myname, winprops)
      if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}
function OpenProgram(URL){
     OpenWnd('Subp1.aspx?pageid='+URL, 'AMS', 750,500, 'yes');
}

