////////////////////////////////////////////////////////
function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       if (oldonload) {   
         oldonload();   
       }   
       func(); 
     }   
   }   
 }  
////////////////////////////////////////////////////////
//var loopTime=setInterval("currentTime()",100);
var startTime=new Date();

////////////////////////////////////////////////////////
function currentTime(){
  var a=Math.floor((new Date()-startTime)/100)/10;
  if (a%1==0) a+=".0";
  
  if (a == 4){
	  window.location.href = window.location.href;
  }else if (a == 2){

  }
  
}

////////////////////////////////////////////////////////
addLoadEvent(
	function(){
		//clearTimeout(loopTime);
		if (document.getElementById("pageLoading")){
			document.getElementById("pageLoading").style.visibility="hidden";
			document.getElementById("pageLoading").style.display="none";
		}

	}
);
////////////////////////////////////////////////////////
function getWindow(wName,Title,Url,wWidth,wHeight,resize) {

    try {
        ColdFusion.Window.destroy(wName,true);
    } catch(e) { }
		ColdFusion.Window.create(wName,Title,Url,
		{
		center:true,
		modal:true,
		draggable:true,
		height:wHeight,
		width:wWidth,
		refreshonshow:true,
		resizable:resize
		});
}
////////////////////////////////////////////////////////
function resizeWindow(wName,wWidth,wHeight){     
      myWindow = ColdFusion.Window.getWindowObject(wName);    
      myWindow.setContentSize(wWidth, wHeight);
      
   }
////////////////////////////////////////////////////////
function validateEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

 		 return true					
	}
////////////////////////////////////////////////////////
function ValidateSignUpForm(){
	var emailID = document.emailSignUpFrm.emailSignUp;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email");
		emailID.focus();
		return false;
	}
	if (validateEmail(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	addEmail();
 }
////////////////////////////////////////////////////////
function emailAdded(result){
	document.getElementById("newsLetterContainer").innerHTML = "Thank you! Your email has been added.";
}
////////////////////////////////////////////////////////
function addEmail(){
	var emailID = document.emailSignUpFrm.emailSignUp.value;		
	
	var g = new ajaxCFProxy();
		g.setCallbackHandler(emailAdded);
		g.addEmailToList(emailID);
		
}
////////////////////////////////////////////////////////

