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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function CheckMaxLength(obj, maxLength, evt){
	var charCode=(evt.which) ? evt.which : event.keyCode
	var max = maxLength - 0;
	var text = obj.value;
	if(text.length > max){
		var ignoreKeys = [8,46,37,38,39,40,35,36];
		for(i=0;i<ignoreKeys.length;i++){
			if(charCode==ignoreKeys[i]){
				return true;
			}
		}
		return false;
		}
	else{
		return true;
		}
} 

function toggleBlock(div_id, link_id){
	var d = MM_findObj(div_id);
	var s = MM_findObj(link_id);
alert(d)
	if(d != null){
		if(d.style.display == "block"){
			d.style.display = "none";
		} else {
			d.style.display = "block";
		}
	}
}
function ClearFieldMsg(Msg, FieldID){
	if(document.getElementById(FieldID).value==Msg)
		document.getElementById(FieldID).value="";
	}

function ChangeNationality(lst){
	if (lst.selectedIndex==0){
		document.getElementById("divRegister").style.display="none";
		document.getElementById("divPassport").style.display="none";
		}
	else if (lst.selectedIndex==1){
		document.getElementById("divRegister").style.display="block";
		document.getElementById("divPassport").style.display="none";
		}
	else {
		document.getElementById("divRegister").style.display="none";
		document.getElementById("divPassport").style.display="block";
		}
	}
	
function ValidatePost(){
	var msg="";
	if (Trim(document.getElementById("ControlComments1_ControlForumPostDetails1_txtPostTitle").value)=="" || document.getElementById("ControlComments1_ControlForumPostDetails1_txtPostTitle").value=="type your post title here")
		msg+=" - Post Title is required\n";
    if (document.getElementById("ControlComments1_ControlForumPostDetails1_txtPostText").value=="" || document.getElementById("ControlComments1_ControlForumPostDetails1_txtPostText").value=="type your post message here")
		msg+=" - Post Message is required";
	if (msg!=""){
		alert(msg);
		return false;
	}
	else
		return true;
}
function ChangeSize(classname,divname){
	var divsize = MM_findObj(divname);
	divsize.className = classname;
}

function popImage(img, caption)
{
	caption = escape(caption);
	openIT('pop_gl.htm?img='+img+"&caption="+caption,800,550,true,false,'');
}

function openIT(u,W,H, sc,rs, wndname) {
		var x = (screen.width - W) / 2;
		var y = (screen.height - H) / 2;
		window.open(u, wndname,"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+",status=yes,resizable="+(rs ? "yes" : "no")+", left="+x+",top="+y);
		//window.open(u, '',"width="+W+",height="+H+",scrollbars=yes,resizable=Yes, left="+x+",top="+y);
}


function openVideo(VideoID){
		openIT('GetMacAddress.html?ID=' + VideoID,643,452,true,false,'video')
		}
function openLiveVideo(VideoID){
   openIT('LiveVideo.aspx?type=live&ID=' + VideoID,643,452,'yes','live')
	
}
function RedirectParent(path){
	window.opener.document.location=path;
	window.opener.focus();
}
function printArticle() {
	if (window.print) {
		setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) {
		alert("Press 'Cmd+p' on your keyboard to print article.");
	}
	else {
		alert("Press 'Ctrl+p' on your keyboard to print article.")
		}
}

function OpenEmail(URL){
     OpenWnd('Forward.aspx?URL='+URL, 'Email', 670, 610, 'no');
}
function popProgramFeedback(type,ProgID){
   OpenWnd('ProgramFeedback.aspx?type='+type+'&ID='+ProgID, 'SendFeedback', 670, 488, 'no');
}
function OpenTerms(URL){
     OpenWnd('terms.html', '', 688, 610, 'yes');
}
function OpenPrivacy(URL){
     OpenWnd('Privacy.html', '', 670, 575, 'no');
}
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 ValidateFeedback(){
	var msg="";
	var msg1="";
	var strvalmail=""
	if (document.Form1.txtName.value=="")
		msg+=" - Name\n";
	if (document.Form1.txtEmail.value=="")
		msg+=" - Email\n";
	else{
		strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0)
			msg1+=" Invalid Email Address\n";
	    } 
	if (document.Form1.txtMessage.value=="")
		msg+=" - Message\n";
	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n" + msg )
		return false;
		}	
	}
function toggleBlock(d, i)
{
	var e = MM_findObj(d);
	var img = MM_findObj(i);
	if (!e) return;
	if (e.style.display == "block"){
		e.style.display = "none";
		img.src = "images/btn_more.gif";
	} else {
		e.style.display = "block";
		img.src = "images/btn_close.gif";
	}
}

function HighlightButton(count,index){
	var itemindex;
	for (var i=0;i<count;i++){
		itemindex=i+2;
		if (itemindex<10)
			itemindex="0"+itemindex;
			//alert(document.getElementById("ControlLatestNews1_gvNews_ctl"+itemindex+"_lbtnTitle"))
		if(i==index){
			document.getElementById("ControlLatestNews1_gvNews_ctl"+itemindex+"_lbtnTitle").className="news-cat-on";
		}
		else{
			document.getElementById("ControlLatestNews1_gvNews_ctl"+itemindex+"_lbtnTitle").className="";
			}
	}
}

function Checkvote(btns, ItemsCount, lang)
{
	var i;
	var ItemChecked=false;
	i=0;
	for (i=0; i< ItemsCount;i++){
		if (document.getElementById(btns + "_" + i ).checked==true)
			ItemChecked=true
	}
	
	if (ItemChecked==true){
			return true;
	}
	else {
		alert("Please select an answer")
		return false;
	}
 }
 
 function ValidateSearch(strid){
	if (Trim(document.getElementById(strid).value)==""){
		alert("keyword is required");
		return false;
	}
	else{
		if(Trim(document.getElementById(strid).value).length<3){
			alert("Keyword must be at least 3 characters");
			return false;
		}
		else{
			return true;
		}
	}	
}
 
function ValidateSearchPrograms(strid){
	if (Trim(document.getElementById(strid+"txtkeyword").value)==""){
		alert("The following fields are required:\n - Keyword");
		return false;
	}
	else{
		if(Trim(document.getElementById(strid+"txtkeyword").value).length<3){
			alert("Keyword must be at least 3 characters");
			return false;
		}
		else{
			return true;
		}
	}	
}

function CheckLogin(username, password){
		if (Trim(document.getElementById(username).value)=="" || Trim(document.getElementById(password).value)==""){
			alert("Please enter your Username and your Password");
			return false;
		}
		else{
			return true;
		}
	}
	function LoggedInAlert(){
		alert("This account is already logged in")
	}
function SubmitLogin(btn) {
		// process only the Enter key 
		if (event.keyCode == 13) {
			// cancel the default submit 
			event.returnValue=false; 
			event.cancel = true; 
			// submit the form by programmatically clicking the specified button 
			document.getElementById(btn).click();
		} 
	 }
function CheckDateFilter(){
   if (document.Form1.txtFromDate.value==""){
       alert("Please select a date");
       return false;
    }
	else
		return true;

}
function ValidateForward(){
	var msg="";
	var msg1="";
	var strvalmail=""
	if (document.Form1.txtSender.value=="")
		msg+="Sender Name\n";
	if (document.Form1.txtSenderMail.value=="")
		msg+="Sender Email\n";
	else{
		strvalmail=IsValidEmail(document.Form1.txtSenderMail);
	    if (strvalmail.length>0)
			msg1+="Invalid Sender Email Address\n";
	    } 
	if (document.Form1.txtReceiver.value=="")
		msg+="Receiver Name\n";
	if (document.Form1.txtReceiverMail.value=="")
		msg+="Receiver Email\n";
	else{
		strvalmail=IsValidEmail(document.Form1.txtReceiverMail);
	    if (strvalmail.length>0)
			msg1+="Invalid Receiver Email Address\n";
	    } 
	if (document.Form1.txtSubject.value=="")
		msg+="Subject\n";
	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}	
	
	}


function ValidateRegister()
{
	var msg="";
	var msg1="";
	if (Trim(document.Form1.txtUserName.value)=="")
		msg+="- User Name\n"
	if (Trim(document.Form1.txtPassword.value)=="")
		msg+="- Password\n"
	if (Trim(document.Form1.txtConfirm.value)=="")
		msg+="- Confirm Password\n"	
	if (Trim(document.Form1.txtPassword.value)!=Trim(document.Form1.txtConfirm.value))
	    msg1+="- New password and its confirmation do not match.\n"	
	if (Trim(document.Form1.txtFName.value)=="")
		msg+="- First Name\n"
	if (Trim(document.Form1.txtLName.value)=="")
		msg+="- Last Name\n"
	if (Trim(document.Form1.txtPhone.value)=="")
		msg+="- Phone\n"
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		msg+="- Gender\n"
	if (document.Form1.lstAge.selectedIndex==0)
		msg+="- Age Group\n"
	if (document.Form1.lstCountry.selectedIndex==0)
	   msg+="- Country\n"
	if (document.Form1.lstNationality.selectedIndex==0)
	   msg+="- Nationality\n"
	
	if (Trim(document.Form1.txtEmail.value)==""){
		msg+="- Email\n"
		}
    else{
		var strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0)
	     msg1+=strvalmail
	    } 
	if (Trim(document.Form1.txtConfirmEmail.value)=="")
		msg+="- Confirm Email\n"
	if (Trim(document.Form1.txtEmail.value)!=Trim(document.Form1.txtConfirmEmail.value))
	    msg1="Email and its confirmation do not match.\n"	
	 if (document.Form1.agree.checked==false)
	   msg+="- Please review and approve the website's terms of use in order to proceed\n"	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}
}

function ValidateEdit()
{
	var msg="";
	var msg1="";
	if (Trim(document.Form1.txtUserName.value)=="")
		msg+="- User Name\n"
	if (Trim(document.Form1.txtFName.value)=="")
		msg+="- First Name\n"
	if (Trim(document.Form1.txtLName.value)=="")
		msg+="- Last Name\n"
	/*if (Trim(document.Form1.txtNickName.value)=="")
		msg+="- Nick Name\n"*/
	if (CheckRadioButtons(document.Form1.rdGender)==false)
		msg+="- Gender\n"
	if (document.Form1.lstAge.selectedIndex==0)
		msg+="- Age Group\n"
	if (document.Form1.lstCountry.selectedIndex==0)
	   msg+="- Country\n"
	if (document.Form1.lstNationality.selectedIndex==0)
	   msg+="- Nationality\n"
	if (Trim(document.Form1.txtEmail.value)==""){
		msg+="- Email\n"
		}
    else{
		var strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0)
	     msg1+=strvalmail
	    } 
  	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}
}

function ValidateChangePassword(){
    if (Trim(document.Form1.txtOldpwd.value)=="" || Trim(document.Form1.txtNewPwd.value)=="" || Trim(document.Form1.txtConfirm.value)=="")
	{
		alert("The following fields are required:\n - Old Password \n - New Password \n - Confirm New Password");
	    return false;
	  }
	else{
		if (document.Form1.txtNewPwd.value!=document.Form1.txtConfirm.value){
			alert("New Password and Confirm New Password do not match");
			return false;
			}
		else{
			return true;
		}
	}
}

function CheckSubSelection(Count){
	var radiochecked=false;
	var itemindex;
	for (i=0;i<Count;i++){
		itemindex=i+2;
		if (itemindex<10)
			itemindex="0"+itemindex;
		if (document.getElementById("dgPlans_ctl" + itemindex + "_rdSubScription").checked==true)
			radiochecked=true;
      }   
    
    if (radiochecked==false){
    	alert("Please choose a plan");
    	return false;
    }
	else{
		 if (document.Form1.agree.checked==false){
			alert("Please review and approve the website's terms of use in order to proceed\n");
			return false;
		}
		else{
		return true;
		}
	}
}

function ChangeSubSelection(Count, Index){
		var itemindex;
		var currentindex;
		Index=Index+2
		if (Index<10){
			currentindex="0" + Index;}
		else{
			currentindex= Index;}
		for (i=0;i<Count;i++){
			itemindex=i+2;
			if (itemindex<10)
				itemindex="0"+itemindex;
			document.getElementById("dgPlans_ctl" + itemindex + "_rdSubScription").checked=false;       
        	document.getElementById("dgPlans_ctl" + currentindex + "_rdSubScription").checked=true;
        }
}



function CheckRadioButtons(rbtn){
   var check=false;
   var i=0;
   
   for (i=0;i<rbtn.length;i++){
       if(rbtn[i].checked==true) 
       check=true
   } 
  
   if (check==false)
      return false;
   else
      return true;
}

function IsValidEmail(txt){
    var stremail="";
	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 {
			stremail="- The Email address is not valid\n";
			return stremail;
		}
	}
}
 
 //validate ForgotPassword form
function validateforgot()
{
	if (document.Form1.txtEmail.value==""){
		alert("Please enter your email");
		return false;
	}
	else{
		var strvalmail=IsValidEmail(document.Form1.txtEmail);
	    if (strvalmail.length>0){
			alert("Please enter a valid email address");
			return false;
	     }
	     else
			return true;
		}
}

//validate Contact Us Form
function ValidateContact()
  {
	 
   var msg;
   var msg2;
   msg=""
    msg2="";
    if (document.Form1.txtFirstName.value=="")
		msg +="- First Name is required\n" 
	if (document.Form1.txtLastName.value=="")
		msg +="- Last Name is required\n" 
	if (document.Form1.txtEmail.value=="")
		msg +="- Email is required\n"
	else{ 
	     var strvalmail=IsValidEmail(document.Form1.txtEmail);
		 if (strvalmail.length>0)
	     msg2=strvalmail
	}
	if (document.Form1.txtMessage.value=="")
		msg +="- Message\n" 
    
	if (msg!="")
	{
	   msg="Please check the following and submit again:\n" + msg +msg2
		alert(msg);
		return false;
	}
	else{
	   if (msg2==""){
	   return true;
	   }else{
	    alert(msg2);
		return false;}
		}
	}

//TRIM Functions
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function





/***********************************************
* Bookmark site 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
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function getVar(name){
		var str = document.location.href;
		if (str.indexOf("?") != -1){
			arr1 = str.split("?");
			arr = arr1[1].split("&");
			for (var i = 0; i<arr.length;i++){
				a = arr[i].split("=");
				if (a[0] == name){
					return unescape(a[1]); 
				}
			}
		}
		return " ";
}
//function validateInt() {
//    var o = document.getElementById('txtSharesNumber');
//    if (isInteger(o.value)) {
//        return true;
//    }
//    else if(o.value < 1 || o.value > 850) {
//        alert("Please Enter a number between 1 and 850");
//        o.value = "";
//        return false;
//    }
//    else {
//        alert("Only real numbers are accepted.");
//        return false;
//    }
//}

function validateInt() {
    var txt = document.getElementById('txtSharesNumber').value;
    var min = 1;
    var max = 850;
    if (txt == "") {
        alert('Number of shares is required.');
        return false;
    }
    if (isNaN(txt)) {
        alert('Only real numbers are accepted.');
        return false;
    }
    if (!isInteger(txt)) {
        alert('Only real numbers are accepted.');
        return false;
    }
    if ((txt < min) || (txt > max)) {
        alert('Please Enter a number between 1 and 850');
        return false;
    }
    return true;
}


function validateRange() {
    var s = document.frmInput.txtInput.value;
    var A = document.frmInput.txtA.value;
    var B = document.frmInput.txtB.value;

    switch (isIntegerInRange(s, A, B)) {
        case true:
            alert(s + " is in range from " + A + " to " + B)
            break;
        case false:
            alert(s + " is not in range from " + A + " to " + B)
    }
}

// isIntegerInRange (STRING s, INTEGER a, INTEGER b)
function isIntegerInRange(s, a, b) {
    if (isEmpty(s))
        if (isIntegerInRange.arguments.length == 1) return false;
    else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt(s);
    return ((num >= a) && (num <= b));
}

function isInteger(s) {
    var i;

    if (isEmpty(s))
        if (isInteger.arguments.length == 1) return 0;
    else return (isInteger.arguments[1] == true);

    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}

function isEmpty(s) {
    return ((s == null) || (s.length == 0))
}

function isDigit(c) {
    return ((c >= "0") && (c <= "9"))
}





	