function flash()
{
window.open("jsp/flashdemo.jsp",
	"mywindow22","location=0,status=0,address=0,scrollbars=0,width=390,height=620,top=90,left=350");
}

function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }
}



function tellfriend()
{
window.open("jsp/tellfriend.jsp",
	"mywindow","location=0,status=0,address=0,scrollbars=0,width=390,height=620,top=90,left=350");
}

function AddDevice()
	{
		winObj=window.open("jsp/newdevice.jsp","mywindow","location=0,status=0,address=0,scrollbars=0,width=415,height=525,top=90,left=350");
	}

function send_friend(obj)
	{
		var senderName  = obj.document.sendfriend.senderName.value;
		var friendName  = obj.document.sendfriend.friendName.value;
		var senderEmail  = obj.document.sendfriend.senderEmail.value;
		var friendEmail  = obj.document.sendfriend.friendEmail.value;
		var friendMobileNum  = obj.document.sendfriend.friendMobileNum.value;
		//var comments  = obj.document.sendfriend.comments.value;
		
		if(senderName=="")
			{
				alert('Please enter your name');
				return ;
			}
		if(friendName=="")
			{
				alert('Please enter your friend name');
				return ;
			}
		
		if(senderEmail=="")
			{
				alert('Please enter your email address');
				return ;
			}
		if(ValidateEmail(senderEmail)==false)
			{
				    obj.document.sendfriend.senderEmail.value ="";
					return;
			}
		if(friendEmail=="")
			{
				alert('Please enter your friends email address');
				return ;
			}
		
		if(ValidateEmail(friendEmail)==false)
			{
				    obj.document.sendfriend.friendEmail.value="";
					return;
			}
		if(friendMobileNum=="")
			{
				alert('Please enter mobile number of your friend ');
				return ;
			}
		if(friendMobileNum.length < 10 )
			{
				alert('Invalid Mobile Number\n Please enter 10 digits');
				return;
			}
		/*if(comments=="")
			{
				alert('Please enter comments ');
				return ;
			}*/
		obj.document.sendfriend.submit();
	}
	
function LiveChat()
{
window.open("http://server.iad.liveperson.net/hc/37916487/?cmd=file&file=visitorWantsToChat&site=37916487&SESSIONVAR!skill=Enthusiast%20Mobile%20Support&SESSIONVAR!window_look=Enthusiast%20Mobile%20Support&referrer='+escape(document.location)",
	"chatwindow","status=0,address=0,scrollbars=0,width=475,height=330,top=200,left=350");
}

function SendMessage()
{
	window.open("http://server.iad.liveperson.net/hc/s-37916487/web/ticketpub/msgcontroller.jsp?surveyname=Enthusiast Mobile Form",
	"sendwindow","location=0,status=0,address=0,scrollbars=0,width=450,height=500,top=200,left=350");
}

function validateData(data,message)
{
	var dataPattern="0123456789";
	var i=0;
	var j=0;
	var pos=1;
	while(i<data.length && pos==1)
	 {
		for(j=0;j<dataPattern.length;j++)
		{
			if(data.charAt(i) == dataPattern.charAt(j))
			{
			   i++;
			   pos=1;
			   break;
			}
			else
			{
				pos=0;
			}
		}
	}//End while
	if(i<data.length)
	{
		alert(message);
		return false;
	}
	return true;
		
}

/**
  Function to validate the User inputs
*/
		function onKeyAlphabetsOnly(e){
			var unicode=e.charCode? e.charCode : e.keyCode
			if (unicode!=8)
			{ //if the key isn't the backspace key (which we should allow)
   				if (unicode==9)
    			{
    			 	return true
    			}
     			 	else if (!((unicode>=65 && unicode<=90 )||(unicode>=96 && unicode<=122 ))) //if not a number
     			 	return false //disable key press
				}
			}
			
			function onKeyAlphabetsOnlyForName(e){
			var unicode=e.charCode? e.charCode : e.keyCode
			if (unicode!=8)
			{ //if the key isn't the backspace key (which we should allow)
   				if (unicode==9)
    			{
    			 	return true
    			}
     			 	else if (!((unicode>=65 && unicode<=90 )||(unicode>=96 && unicode<=122 ) || (unicode==32))) //if not a number
     			 	return false //disable key press
				}
			}
	
	
		// isAlpha: returns true if the string only contains characters A-Z or a-z
		function isAlpha(str,msg){
		  var re = /[a-zA-Z]/g
		  if (!re.test(str)){
		     alert(msg);
		  	 return false;
		  	}
		  return true;
		}	
		
	function trimAll( strValue ) {
 	var objRegExp = /^(\s*)$/;
	
	    //check for all spaces
	    if(objRegExp.test(strValue)) {
	       strValue = strValue.replace(objRegExp, '');
	       if( strValue.length == 0)
	          return strValue;
	    }
	
	   //check for leading & trailing spaces
	   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if(objRegExp.test(strValue)) {
	       //remove leading and trailing whitespace characters
	       strValue = strValue.replace(objRegExp, '$2');
	    }
	  return strValue;
	}		
	
	function TabNext(obj,event,len,next_field) {
			var phone_field_length=0;
			if (event == "down") {
				phone_field_length=obj.value.length;
				}
			else if (event == "up") {
				if (obj.value.length != phone_field_length) {
					phone_field_length=obj.value.length;
					if (phone_field_length == len) {
						next_field.focus();
						}
					}
				}
	}
				
	function onKeyNumbersOnly(e){	
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
		if (unicode==9)
	    {
	     var event=down;
	     Tabnext(event);}
		else if (unicode<48||unicode>57) //if not a number
		return false //disable key press
		}
	}	
		
		function validateInput(obj){
			var name=trimAll(obj.document.AddDeviceForm.username.value);
		    var productDevice=trimAll(obj.document.AddDeviceForm.productDevice.value);
		    var phoneCarrier=trimAll(obj.document.AddDeviceForm.phoneCarrier.value);
		    var phNumber1=trimAll(obj.document.AddDeviceForm.phoneNum1.value);
		    var phNumber2=trimAll(obj.document.AddDeviceForm.phoneNum2.value);
		    var phNumber3=trimAll(obj.document.AddDeviceForm.phoneNum3.value);
		    var emailAddress=trimAll(obj.document.AddDeviceForm.emailAddress.value);
		    var comments=trimAll(obj.document.AddDeviceForm.comments.value);
		    		        
		    var phNum1Valid=false;
			var phNum2Valid=false;
			var phNum3Valid=false;	
			var eMailValid=false;
			
		    if(name=="" || phoneCarrier=="" || phNumber1=="" || phNumber2=="" || phNumber3==""||emailAddress=="" || comments=="" || productDevice=="")
			{
				alert('Please enter the details\n All fields  are Required ')
				return;
			}	
			/**
			* Check for special characters 
			* in UserName
			*/
			if(checkSpecialChars(name,"Name cannot contain special characters")==false)
			{
				document.AddDeviceForm.username.value="";			
				return;
			}else if(checkNumericChars(name,"Name cannot contain numberic value")==false)
				  {
					 document.AddDeviceForm.username.value="";			
					 return;
				  }  
				  /**
				  * Check for only special characters 
				  * in Phone Model
				  */				  
				 if(checkSpecialChars(productDevice,"Phone Model cannot contain special characters ")==false)
	 			  {
					 document.AddDeviceForm.productDevice.value="";			
					 return;
				  }	
		      	/**
				 * perform length check for the phone number
				 */
				if(phNumber1.length < 3 || phNumber2.length < 3 || phNumber3.length < 4)
				{
					alert('Invalid Mobile Number\n Please enter 10 digits');
					document.AddDeviceForm.phoneNum1.value="";
					document.AddDeviceForm.phoneNum2.value="";
					document.AddDeviceForm.phoneNum3.value="";
					return;
				}		  
			    phNum1Valid=validateData(phNumber1,"Invalid Mobile Number\nMust Contain only digits");
			   	if(phNum1Valid==true)
					phNum2Valid=validateData(phNumber2,"Invalid Mobile Number\nMust Contain only digits");
				else{
					document.AddDeviceForm.phoneNum1.value="";
					return;
					}
				  if(phNum2Valid==true)
					  phNum3Valid=validateData(phNumber3,"Invalid Mobile Number\nMust Contain only digits");
				  else{
					  document.AddDeviceForm.phoneNum2.value="";
					  return;
				  	  }
				  if(phNum3Valid==true)
				  {
				  }	  
				  else{
					  document.AddDeviceForm.phoneNum3.value="";
					  return;
				  	  }				  
			   	if(eMailValid=ValidateEmail(emailAddress)==false)
			   	{
					document.AddDeviceForm.emailAddress.value="";
					return;
			   	}		   	
			   	document.AddDeviceForm.submit();			   	
		}
		
		
	function validateMobileno(obj)
	{
			var phNumber1=trimAll(obj.mobileNo1.value);
		    var phNumber2=trimAll(obj.mobileNo2.value);
		    var phNumber3=trimAll(obj.mobileNo3.value);
		   if(phNumber1=="" || phNumber2=="" || phNumber3==""){
		   alert("Enter correct mobile number");
		   return;
		   }
		   document.myAccountForm.submit();
	}
	
		
		function checkSpecialChars(strData,message)
 {
/**
  *Check for some special characters in  Name Field
  */
	for(var i=0;i<strData.length;i++)
	  {
		if(strData.charAt(i)==";" || strData.charAt(i)=="!" || strData.charAt(i)=="?" 
								   || strData.charAt(i)=="*" || strData.charAt(i)=="#"
								   || strData.charAt(i)=="$" || strData.charAt(i)=="%"
								   || strData.charAt(i)=="~" || strData.charAt(i)=="`"
								   || strData.charAt(i)==">" || strData.charAt(i)=="<"
								   || strData.charAt(i)=="=" || strData.charAt(i)=="-"
								   || strData.charAt(i)=="+" || strData.charAt(i)=="/"
								   || strData.charAt(i)=="^" || strData.charAt(i)=="("
								   || strData.charAt(i)==")" ||strData.charAt(i)=="_")
		  {
		   alert(message);
		   return false;
		  }
 	  }

 }
 
 function checkNumericChars(strData,message)
 {
 
 /**
  *Check for some numeric characters in Name Field
  */
	for(var i=0;i<strData.length;i++)
	  {
		if(strData.charAt(i)=="0" || strData.charAt(i)=="1" || strData.charAt(i)=="2" 
								   || strData.charAt(i)=="3" || strData.charAt(i)=="4"
								   || strData.charAt(i)=="5" || strData.charAt(i)=="6"
								   || strData.charAt(i)=="7" || strData.charAt(i)=="8"
								   || strData.charAt(i)=="9")
		  {
		   alert(message);
		   return false;
		  }
 	  }

 }
 


		function doRegisterValidations(obj){
				//Declare Variables to Hold the User Input Data	
				//alert('inside doRegisterValidations')	
				var eMailAddr  = obj.document.regform.emailAddr.value;
		        var phNumber1  = obj.document.regform.phoneNum1.value;
		        var phNumber2  = obj.document.regform.phoneNum2.value;
		        var phNumber3  = obj.document.regform.phoneNum3.value;
		        var carrier    = obj.document.regform.phoneCarrier.value;
		        //var prodDevice = document.subscribe.productDevice.value;       
		        var phNum1Valid=false;
				var phNum2Valid=false;
				var phNum3Valid=false;	
				var eMailValid=false;				
				/*Perform Validations.Check for NULL values*/
				if(eMailAddr==""||phNumber1=="" || phNumber2=="" || phNumber3=="" ){
					alert('Please enter the details\nFields Marked ( * ) are Mandatory ')
					return ;
				}
				if( carrier == "" ){
					alert("Please select your wireless carrier");
					return;
			   	} 
			   	if( carrier == "Choose Your Carrier" ){
					alert("Please select your wireless carrier");
					return;
			   	} 
				/**
				 * perform length check for the phone number
				 */
				if(phNumber1.length < 3 || phNumber2.length < 3 || phNumber3.length < 4){
					alert('Invalid Mobile Number\n Please enter 10 digits');
					obj.document.regform.phoneNum1.value="";
					obj.document.regform.phoneNum2.value="";
					obj.document.regform.phoneNum3.value="";
					return;
				}
				/**
			    * If the email is not valid, display error
				*/				
			   if(ValidateEmail(eMailAddr)==false){
				    obj.document.regform.emailAddr.value ="";
					return;
			   }
			  
			   if(carrier == "Verizon")
			   {	 
			 	//document.subscribe.action="<%=request.getContextPath()+"/regUser"%>";
			 	obj.document.regform.action="registration.do";
			 	obj.document.regform.submit();
			   }
			   else if(carrier != "Verizon")
			   {
			   		//document.subscribe.action="<%=request.getContextPath()%>/jsp/UserRegistration.jsp?phoneCarrier="+carrier;
			   		obj.document.regform.action="registration.do";
			   		obj.document.regform.submit();
			   }
		}


function ValidateEmail(entered) {
		with (entered){
		mailChecker =  '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@.-_?+';
		for (i=0; i < entered.length; i++)
			if(mailChecker.indexOf(entered.charAt(i)) < 0)
			{					
				alert('Invalid Email');
				return false;
			}
		apos=entered.indexOf("@");
		lpos=entered.lastIndexOf("@");
		dotpos=entered.lastIndexOf(".");
		lastpos=entered.length-1;
		if (apos<1 || (dotpos-apos)<2 || (lastpos-dotpos)>3 || (lastpos-dotpos)<2 || apos != lpos ){
			
			alert('Invalid Email');
			return false;
			}
			else{
				return true;
			}
		 }//end with
		 
}				
				
function doUserInfoValidations(form)
{	    
        
		var sendPromotionalInfo=document.regform.msgEmailStatus.checked;
		var firstName=trimAll(document.regform.firstName.value);
		var lastName=trimAll(document.regform.lastName.value);
		var addr1=trimAll(document.regform.adress1.value);
		var addr2=trimAll(document.regform.address2.value);
		var zipCode=trimAll(document.regform.zipCode.value);						

		var phNum1Valid=false;
		var phNum2Valid=false;
		var phNum3Valid=false;
		var zipCodeValid=false;
		var eMailValid=false;
		var firstNameValid=false;
		var lastNameValid=false;
		var addr1Valid=false;
		var zipCodeValid=false;
		var checkedValue=null;
		var len=document.regform.gender.length;
			
		var ageVar=document.regform.age.value;
		var incomeVar=document.regform.income.value;
		var stateVar=document.regform.state.value;			
					
	    for(var i = 0; i < len; i++) {
	     if(document.regform.gender[i].checked) {
	        checkedValue=document.regform.gender[i].value;
	      }
	     } 
	    if(firstName==""||lastName==""||addr1==""||zipCode==""|| checkedValue == "")
		{
			alert('Please enter the details\nFields Marked ( * ) are Mandatory ')
			return false;
		}

		 if(checkSpecialChars(firstName,"First Name cannot contain special characters")==false)
		  {
			 document.regform.firstName.value="";			
			 return;
		}
		else if(checkNumericChars(firstName,"First Name cannot contain numberic value")==false)
		  {
			 document.regform.firstName.value="";			
			 return;
		  } 
		  	
		 if(checkSpecialChars(lastName,"Last Name cannot contain special characters")==false)
		  {
		     document.regform.lastName.value="";			
			 return;
  		  }
		else if(checkNumericChars(lastName,"Last Name cannot contain numeric value")==false)
		  {
			 document.regform.lastName.value="";			
			 return;
		  } 
		  if(zipCode.length<5)
		  {
			alert('zipcode has to be at least 5 characters long');
		   document.regform.zipCode.value="";
			return;
		}
	    else if(!validateData(zipCode,"Invalid zipcode\nMust Contain only digits")){
		   document.regform.zipCode.value="";
			return;
	    }else if(ageVar == 0){
	    	alert('Please Select Your Age');
	    	return;
	    }else if(incomeVar == 0){
	    	alert('Please Select Your Income');
	    	return;
	    }else if(stateVar == 'blank'){
	    	alert('Please Select State');
	    	return;
	    }
	    else{
		     if(sendPromotionalInfo==true)
		     {
		        document.regform.msgEmailStatus.value="1";
		     }
		     else
		     {
		       document.regform.msgEmailStatus.value="0";
		     }
		     document.regform.requestType.value="sub3";
		     document.regform.gender.value=checkedValue;
		   	 document.regform.action="SubscribeAction.do";
  		     document.regform.submit();
	   }
  }

	function showDevices(form){
		document.regform.requestType.value="";
		document.regform.action="SubscribeAction.do";
		document.regform.submit();
	}

function AsetLogoImage()
{
	if(document.getElementById("deviceModel").value=="blank")
   {
    document.getElementById("mobileimage").src =  ipaddr+"/image/Dot.gif";
   }
	else
	{
	 var selectedDevice = document.getElementById("deviceModel").value; 
	 var mobileImage = document.getElementById(selectedDevice).value;
	 if(selectedDevice=="blank")
	 	document.getElementById("mobileimage").src = ipaddr+"/image/device_img/notAvailable_2.gif";
	 else
	  {
		 if(mobileImage!="null" && mobileImage!=""){  
		   document.getElementById("mobileimage").src = ipaddr+"/image/device_img/"+mobileImage;
		  }else{
		   document.getElementById("mobileimage").src = ipaddr+"/image/device_img/notAvailable_2.gif";
		  }
  	}
  }
}	

function setLogoImage(form)
{
	//alert("set Logo Image");
	if(document.regform.deviceModel.value=="blank"){
	//alert("if blank");   
    	document.getElementById("mobileimage").src =  "images/Dot.gif";
     }else
	{
	//alert("else"); 
		 var selectedDevice = document.regform.deviceModel.value;
		 //var mobileImage = document.getElementById(selectedDevice).value;
		 var mobileImage = document.regform.deviceModel.value;
		 //alert('11111111');
		// alert(mobileImage);
		 //alert("selectedDevice--------"+selectedDevice);
		 //alert("mobileImage-----------"+mobileImage);
		 //Not Available
		 if(selectedDevice=="blank"){
		 //alert('222222');
		 //alert("if selectedDevice is blank-----"+selectedDevice);
		 //document.subscribe.deviceModel.value="true";
		 //alert("devmodel setting true111---"+document.subscribe.deviceModel.value);
		   document.getElementById("mobileimage").src = "images/Devices/notAvailable_2.gif";
		}else
	  	{
	  	//alert('3333333333');
		 if(mobileImage!="null" && mobileImage!="")	{
		 //alert('444444444');
		 //alert("ifif mobileImage----"+mobileImage);	
		  	document.getElementById("mobileimage").src = "images/Devices/"+mobileImage;
		  }else{
		 // alert('555555555');
		  //alert("else mobileImage----"+mobileImage);	
		  //document.subscribe.deviceModel.value='true';
		 //alert("devmodel setting true222---"+document.subscribe.deviceModel.value);
		   document.getElementById("mobileimage").src = "images/Devices/notAvailable_2.gif";
		   }
		 }
	}
}

function doValidations(form){
			var deviceModel  = document.regform.deviceModel.value;
		    var eMailAddr  = document.regform.emailAddr.value;
	        var phNumber1  = document.regform.phoneNum1.value;
	        var phNumber2  = document.regform.phoneNum2.value;
	        var phNumber3  = document.regform.phoneNum3.value;
	        
	        //var prodDevice = document.subscribe.productDevice.value;       
	        var phNum1Valid=false;
			var phNum2Valid=false;
			var phNum3Valid=false;	
			var eMailValid=false;				
			/*Perform Validations.Check for NULL values*/
			
			if(eMailAddr==""||phNumber1=="" || phNumber2=="" || phNumber3=="" ){
				alert('Please enter the details\nFields Marked ( * ) are Mandatory ')
				return ;
			}
			if(deviceModel=="blank"){
				alert('Please enter the details\nFields Marked ( * ) are Mandatory ')
				return ;
			}
			if(phNumber1 == null){
				alert('Please enter the details\nFields Marked ( * ) are Mandatory ')
				return;
			}
			/**
			 * perform length check for the phone number
			 */
			if(phNumber1.length < 3 || phNumber2.length < 3 || phNumber3.length < 4){
				alert('Invalid Mobile Number\n Please enter 10 digits');
				document.regform.phoneNum1.value="";
				document.regform.phoneNum2.value="";
				document.regform.phoneNum3.value="";
				return;
			}
			/**
		    * If the email is not valid, display error
			*/				
		   if(ValidateEmail(eMailAddr)==false){
			    document.regform.emailAddr.value ="";
				return;
		   }
			  			  		    
		    /*Perform Validations.Check for NULL values*/
						
			document.regform.productType.value=document.regform.deviceModel.options[document.regform.deviceModel.selectedIndex].text;
			document.regform.requestType.value="sub2";
			document.regform.action="SubscribeAction.do";
			document.regform.submit();
}
		
function doWapValidations(form){
	document.regform.wapStatus.value="1";
	document.regform.action="SubscribeAction.do";
   	document.regform.submit();
}

function doMobileValidation(obj){
				//Declare Variables to Hold the User Input Data		
				var mobileNo1  = obj.loginActionForm.mobileNo1.value;
		        var mobileNo2  = obj.loginActionForm.mobileNo2.value;
		        var mobileNo3  = obj.loginActionForm.mobileNo3.value;
		       		
				/*Perform Validations.Check for NULL values*/
				if(mobileNo1=="" || mobileNo2=="" || mobileNo3=="" ){
					alert('Please enter the Mobile Number ')
					return ;
				}
				/**
				 * perform length check for the phone number
				 */
				if(mobileNo1.length < 3 || mobileNo2.length < 3 || mobileNo3.length < 4){
					alert('Invalid Mobile Number\n Please enter 10 digits');
					obj.loginActionForm.mobileNo1.value="";
					obj.loginActionForm.mobileNo2.value="";
					obj.loginActionForm.mobileNo3.value="";
					return;
				}
				obj.document.loginActionForm.action="forgotPassword.do";
			   	obj.document.loginActionForm.submit();
										  
}


var menu1=new Array()
menu1[0]='<a href="registration.do?carrier=Cingular&requestType=sub2">AT&T</a>'
menu1[1]='<a href="registration.do?carrier=Sprint&requestType=sub2">Sprint</a>'
menu1[2]='<a href="registration.do?carrier=T-Mobile&requestType=sub2">T-Mobile</a>'
menu1[3]='<a href="registration.do?carrier=Verizon&requestType=sub2">Verizon</a>'
menu1[4]='<a href="registration.do?carrier=SunCom&requestType=sub2">SunCom</a>'

var menuwidth='200px'
var menubgcolor='#E9E9E9'
var disappeardelay=250
var hidemenu_onclick="Yes"

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ 
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) 
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu
