		function featuresclick(fefor){
			//centering with css
			centerPopup('ourfeatures', 800);
			//load popup
			loadPopup('ourfeatures', 800);
			jQuery("#avlfeatures").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "ourfeatures.php",
			   data: "sf="+fefor,
			   success: function(msg){
				   jQuery("#avlfeatures").html(msg);
			   }
			 });
		}
		function promoclick1(ifrmurl){
			//centering with css
			centerPopup('promosd', 800);
			//load popup
			loadPopup('promosd', 800);
			jQuery("#avlpromos").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "avlpromos.php",
			   data: "cpid="+ifrmurl,
			   success: function(msg){
				   jQuery("#avlpromos").html(msg);
			   }
			 });
		}
		function mynlclick(nlemail){
			//centering with css
			centerPopup('mynlsub', 800);
			//load popup
			loadPopup('mynlsub', 800);
			jQuery("#avlmynlsub").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "nlsubscribe.php",
			   data: "nlemail="+nlemail,
			   success: function(msg){
				   jQuery("#avlmynlsub").html(msg);
			   }
			 });
		}
		function promoclick(ifrmurl){
			//centering with css
			centerPopup('promosd', 800);
			//load popup
			loadPopup('promosd', 800);
			jQuery("#avlpromos").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "avlpromos.php",
			   data: ifrmurl,
			   success: function(msg){
				   jQuery("#avlpromos").html(msg);
			   }
			 });
		}
		function myvideoclick(){
			centerPopup("myvideosd", 500);
			//load popup
			loadPopup("myvideosd", 500);
		}
		function myvidclick(sf, video){
			centerPopup("myvideosd", 500);
			//load popup
			loadPopup("myvideosd", 500);
			jQuery("#avlmyvideo").html('<center><img src="images/loader-bar.gif" width="250" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "get-video.php",
			   data: "sf="+sf+"&video="+video,
			   success: function(msg){
				   jQuery("#avlmyvideo").html(msg);
			   }
			 });
		}
		function myspotclick(certid){
			centerPopup("myspotsd", 950);
			//load popup
			loadPopup("myspotsd", 950);
//			alert("vidid");
			if (vidid != "")
				jQuery('#'+vidid).html('<img src="images/wdug.jpg" width=342 height=225 border=0 style="border:2px solid #000;">');
			jQuery("#avlmyspot").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "spot-live.php",
			   data: "certid="+certid,
			   success: function(msg){
				   jQuery("#avlmyspot").html(msg);
			   }
			 });
		}
		function couponclick1(ifrmurl){
			//centering with css
			centerPopup("couponsd", 800);
			//load popup
			loadPopup("couponsd", 800);
			jQuery("#avlcoupons").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "avlcoupons.php",
			   data: "cpid="+ifrmurl,
			   success: function(msg){
				   jQuery("#avlcoupons").html(msg);
			   }
			 });
		}
		function couponclick(ifrmurl){
			//centering with css
			centerPopup("couponsd", 800);
			//load popup
			loadPopup("couponsd", 800);
			jQuery("#avlcoupons").html('<center><img src="images/loader-bar.gif" width="300" height="15" border="0" /></center>');
			jQuery.ajax({
			   type: "GET",
			   url: "avlcoupons.php",
			   data: ifrmurl,
			   success: function(msg){
				   jQuery("#avlcoupons").html(msg);
			   }
			 });
		}
function textCounter1(theField,theCharCounter,theLineCounter, lastchrcount,maxChars,maxLines,maxPerLine)
{
	if (theCharCounter.value >=0 && theLineCounter.value >= 0){
		var strTemp = "";
		var strLineCounter = 0;
		var strCharCounter = 0;
		for (var i = 0; i < theField.value.length; i++){
			var strChar = theField.value.substring(i, i + 1);
			if (strChar == '\n'){
				strTemp += strChar;
				strCharCounter = 1;
				strLineCounter += 1;
			}else if (strCharCounter == maxPerLine){
				strTemp += '\n' + strChar;
				strCharCounter = 1;
				strLineCounter += 1;
			}else{
				strTemp += strChar;
				strCharCounter ++;
			}
			if ( (maxChars - strTemp.length) < 1 || (maxLines - strLineCounter) < 1){
				if (lastchrcount.value == "" || lastchrcount.value <= 0){
					if (theField.value.length > maxChars)
						lastchrcount.value = maxChars;
					else
						lastchrcount.value = strTemp.length;
				} else {
					if (lastchrcount.value > maxChars)
						lastchrcount.value = strTemp.length;
				}
			theField.value = theField.value.substr(0,lastchrcount.value);
			theCharCounter.value = 0;
			theLineCounter.value = 0;
			}
		}
		theCharCounter.value = maxChars - strTemp.length;
		theLineCounter.value = maxLines - strLineCounter;
		lastchrcount.value = theField.value.length;
	} else{
		theField.value = theField.value.substr(0,lastchrcount.value);
		theCharCounter.value = 0;
		theLineCounter.value = 0;
	}
}
function setmarkpoint(latlngstr, bullet){
	jQuery.ajax({
	   type: "GET",
	   url: "kmltmp.php",
	   data: "latlng="+latlngstr+"&gbbullet="+bullet,
	   success: function(msg){
		   if (msg.length > 0){
			 var cert=eval(msg);
			 document.frmMap.sellat.value = cert[0];
			 document.frmMap.sellng.value = cert[1];
		   }
	   }
	 });
}
function setmarkpointl(latlngstr, bullet){
	jQuery.ajax({
	   type: "GET",
	   url: "kmltmp.php",
	   data: "latlng="+latlngstr+"&gbbullet="+bullet,
	   success: function(msg){
		   if (msg.length > 0){
			 var cert=eval(msg);
			window.opener.document.addProp.latbox.value=cert[0];
			window.opener.document.addProp.lonbox.value=cert[1];
		   }
	   }
	 });
}
function setcertstyle(catid, cfid){
	$("#cert_styles").html("<img src='images/loading.gif' />");
	jQuery.ajax({
	   type: "GET",
	   url: "cert-styles.php",
	   data: "catid="+catid,
	   success: function(msg){
		 var radio="";
		 if (msg.length > 0){
			 var cert=eval(msg);
			 radio="<table>";
			 for(var i=0;i<cert.length;i++){
				if (cfid == cert[i]['cfid'])
					var vselected = true;
			 }
			 for(var i=0;i<cert.length;i++)
			 {
				if (vselected){
					if (cfid == cert[i]['cfid']){
						var sel = "checked";
						document.addProp.maxchars.value = cert[i]['cust_msg_chars'];
						document.addProp.maxlines.value = cert[i]['cust_msg_lines'];
						document.addProp.perlinechars.value = cert[i]['cust_message_characters'];
						document.addProp.lastchrcount.value = 0;
						textCounter1(document.addProp.msg,document.addProp.remChars,document.addProp.remLines, document.addProp.lastchrcount,document.addProp.maxchars.value, document.addProp.maxlines.value, document.addProp.perlinechars.value);
					}else
						var sel = "";
				} else {
					if (i==0)
						var sel = "checked";
					else
						var sel = "";
				}
				radio +="<tr valign=top><td style='padding:3px;'><input type='radio' name='cfid' value='"+cert[i]['cfid']+"' "+sel+" onClick='setcustmsgparams("+cert[i]['cust_message_characters']+", "+cert[i]['cust_msg_lines']+", "+cert[i]['cust_msg_chars']+");'/></td><td style='padding:3px;'>"+cert[i]['cert_name']+"</td><td style='padding:3px;'><a href='themes/scert-"+cert[i]['cfid']+"-f.jpg' class='lightbox' rel='roadtrip' title='Sample Certificate'><img src='themes/"+cert[i]['certificate']+"' width='50' border=0></a></td><td><a href='themes/scert-"+cert[i]['cfid']+"-b.jpg' class='lightbox' rel='roadtrip' title='Sample Certificate Back'><img src='themes/"+cert[i]['certificate_back']+"' width='50' border=0></a></td><td><a href='themes/scert-"+cert[i]['cfid']+"-pv.jpg' class='lightbox' rel='roadtrip' title='Sample Photo Viewer'><img src='themes/"+cert[i]['certframe']+"' width='50' border=0></a></td></tr>";
			 }
			 radio+="</table>";
		 } else {
			 radio ="";
		}
		 jQuery("#cert_styles").html('');
		 jQuery("#cert_styles").append(radio);
	   }
	 });
}
function setcustmsgparams(per_line, lines, charlimit){
	document.addProp.maxchars.value = charlimit;
	document.addProp.maxlines.value = lines;
	document.addProp.perlinechars.value = per_line;
	document.addProp.lastchrcount.value = 0;
	textCounter1(document.addProp.msg,document.addProp.remChars,document.addProp.remLines, document.addProp.lastchrcount,document.addProp.maxchars.value, document.addProp.maxlines.value, document.addProp.perlinechars.value);
}
function setsubcats(catid, scatid, szoneid){
	$("#zones").html("<img src='images/loading.gif' />");
	jQuery.ajax({
	   type: "GET",
	   url: "sub-cats.php",
	   data: "catid="+catid,
	   success: function(msg){
		 var radio="";
		 var selscatids="";
		 if (msg.length > 0 && msg != "No Zone Found"){
			 var scats=eval(msg);
			 radio="<table><tr valign=top>";
			 for(var i=0;i<scats.length;i++)
			 {
				if (scatid.indexOf(","+scats[i]['catid']+",") >= 0)
					var sel = "checked";
				else
					var sel = "";
				if (i != 0 && i%3==0)
					radio += "</tr><tr valign=top>";
				radio +="<td width='20' style='padding:3px;'><input type='checkbox' name='scatid[]' id='scatid[]' value='"+scats[i]['catid']+"' onClick='getsubzomes();' "+sel+"/></td><td width='32%' style='padding:3px;'> "+scats[i]['cat_name']+"</td>";
				if (sel == "checked")
					selscatids += ","+scats[i]['catid'];
			 }
			if (scats.length>0 && scats.length % 3 == 2)
				radio += "<td width='32%'>&nbsp;</td>";
			if (scats.length>0 && scats.length % 3 == 1)
				radio += "<td width='64%' colspan='2'>&nbsp;</td>";
			 radio+="</tr></table>";
			 $("#zoneslist").css("display", "block");
		 } else {
			 radio="&nbsp;";
			 $("#zoneslist").css("display", "none");
		}
		 jQuery("#zones").html('');
		 jQuery("#zones").append(radio);
		setsubzones(selscatids.substr(1), szoneid);
/*		setsubzones(scats[0]['catid'], '<?=($_SESSION["szoneid"])?$_SESSION["szoneid"]:" ";?>');*/
	   }
	 });
}
function setsubzones(catid, scatid1){
	$("#sub_zones").html("<img src='images/loading.gif' />");
	jQuery.ajax({
			type: "GET",
			url: "sub-cats.php",
			data: "scatid="+catid,
			success: function(msg){
				var radio="";
				if (msg.length > 0 && msg != "No Zone Found"){
					var scats1=eval(msg);
					radio="<table><tr valign=top>";
					for(var i=0;i<scats1.length;i++)
					{
						if (scatid1.indexOf(","+scats1[i]['catid']+",") >= 0)
							var sel = "checked";
						else
							var sel = "";
						if (i != 0 && i%3==0)
							radio += "</tr><tr valign=top>";
						radio +="<td width='20' style='padding:3px;'><input type='checkbox' name='szoneid[]' value='"+scats1[i]['catid']+"' id='szoneid[]' "+sel+"/></td><td width='32%' style='padding:3px;'> "+scats1[i]['cat_name']+"</td>";
					}
					if (scats1.length>0 && scats1.length % 3 == 2)
						radio += "<td width='32%'>&nbsp;</td>";
					if (scats1.length>0 && scats1.length % 3 == 1)
						radio += "<td width='64%' colspan='2'>&nbsp;</td>";
					radio+= (radio != "<table><tr valign=top>") ? "</tr></table>":"";
					 $("#szoneslist").css("display", "block");
				} else {
					radio="&nbsp;";
					 $("#szoneslist").css("display", "none");
				}
				jQuery("#sub_zones").html('');
				jQuery("#sub_zones").append(radio);
			}
	 });
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function setbreakup(shrow, optvalue){
	if (optvalue == "No"){
		var nshrow=document.getElementById(shrow);
		nshrow.className='hide';
	} else {
		var nshrow=document.getElementById(shrow);
		nshrow.className='';
	}
}
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
	thisfield.value = "";
  }
} 
function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
   thisfield.value = defaulttext;
  }
}
function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 112,top = 34');");
}
function popUpImg(URL, width, height) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left = 112,top = 34');");
}

function check_all_cb(cb_form){
	if (cb_form.elements["check_all"].checked){
		for (var i=0; i<cb_form.elements.length; i++){
			if (cb_form.elements[i].type == "checkbox"){
				cb_form.elements[i].checked = true;
			}
		}
	} else {
		for (var i=0; i<cb_form.elements.length; i++){
			if (cb_form.elements[i].type == "checkbox"){
				cb_form.elements[i].checked = false;
			}
		}
	}
}

function uncheck_check_all(cb_form, current_cb){
	var checked_count=0;
	var total_count=0;
	if (!current_cb.checked){
		cb_form.elements["check_all"].checked = false;
	}
	for (var i=0; i<cb_form.elements.length; i++){
		if (cb_form.elements[i].type == "checkbox"){
			if (!cb_form.elements[i].checked)
				checked_count++;
		}
	}
	if (checked_count <= 1)
		cb_form.elements["check_all"].checked = true;
//	alert();
}

function copy_value(i_index, frm, items){
	var cp_string = frm.elements[(0*44 + 6 + i_index + 0)].value;
	for (i=0; i<items; i++){
		frm.elements[(i*44 + 6 + i_index + i)].value = cp_string;
	}
}

/*function emailCheckNew(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }

 		 return true;					
	}*/

function emailCheck (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			return false;
		}
	}
	if (user.match(userPat)==null) {
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false;
			}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
   		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		return false;
	}
	if (len<2) {
		return false;
	}
	return true;
}

function check_input(field_name) {
	if (field_name && (field_name.type != "hidden")) {
    	var field_value = field_name.value;
		if (field_value == '' || check_blank_space(field_value)) {
      		return true;
    	}
  	}
}

function combo_select(field_name, field_value) {
	for (i=0; i < field_name.length; i++){
		if (field_name.options[i].value == field_value)
			field_name.options.selectedIndex = i;
	}
}

function check_blank_space(strIn) {
	var flag = true;
	for (i=0; i<strIn.length; i++){
		if (strIn[i] != ' ')
			flag = false;
	}
	return flag;
}

function SetFocus(TargetFormName) {
	var target = 0;
	if (TargetFormName != "") {
    	for (i=0; i<document.forms.length; i++) {
      		if (document.forms[i].name == TargetFormName) {
        		target = i;
        		break;
      		}
    	}
  	}
	var TargetForm = document.forms[target];
    for (i=0; i<TargetForm.length; i++) {
    	if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
			TargetForm.elements[i].focus();
			if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        		TargetForm.elements[i].select();
      		}
			break;
    	}
  	}
}

function RemoveFormatString(TargetElement, FormatString) {
	if (TargetElement.value == FormatString) {
    	TargetElement.value = "";
  	}
	TargetElement.select();
}

function CheckDateRange(from, to) {
	//mm/dd/yyyy
	if (Date.parse(from.value) <= Date.parse(to.value)) {
    	return true;
  	} else {
    	return false;
  	}
}

function validate_date(DateToCheck, FormatString) {
	//"mm/dd/yyyy", "dd/mm/yyyy", "mm-dd-yyyy", "dd-mm-yyyy"
	var strDateToCheck;
	var strDateToCheckArray;
	var strFormatArray;
	var strFormatString;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var intDateSeparatorIdx = -1;
	var intFormatSeparatorIdx = -1;
	var strSeparatorArray = new Array("-"," ","/",".");
	var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
	var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	strDateToCheck = DateToCheck.toLowerCase();
	strFormatString = FormatString.toLowerCase();
	
/*	if (strDateToCheck.length != strFormatString.length) {
		return false;
	}*/
	
	for (i=0; i<strSeparatorArray.length; i++) {
		if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
	  		intFormatSeparatorIdx = i;
	  		break;
		}
	}
	
	for (i=0; i<strSeparatorArray.length; i++) {
		if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
	  		intDateSeparatorIdx = i;
	  		break;
		}
	}
	
	if (intDateSeparatorIdx != intFormatSeparatorIdx) {
		return false;
	}
	
	if (intDateSeparatorIdx != -1) {
		strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
		if (strFormatArray.length != 3) {
	  		return false;
		}
	
		strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
		if (strDateToCheckArray.length != 3) {
	  		return false;
		}
	
		for (i=0; i<strFormatArray.length; i++) {
	  		if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
				strMonth = strDateToCheckArray[i];
	  		}
	
			if (strFormatArray[i] == 'dd') {
				strDay = strDateToCheckArray[i];
	  		}
	
	  		if (strFormatArray[i] == 'yyyy') {
				strYear = strDateToCheckArray[i];
	  		}
		}
	} else {
		if (FormatString.length > 7) {
	  		if (strFormatString.indexOf('mmm') == -1) {
				strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
	  		} else {
				strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
	  		}
	
	  		strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
	  		strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
		} else {
	  		return false;
		}
	}
	
	if (strYear.length != 4) {
		return false;
	}
	
	intday = parseInt(strDay, 10);
	if (isNaN(intday)) {
		return false;
	}
	if (intday < 1) {
		return false;
	}
	
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) {
		for (i=0; i<strMonthArray.length; i++) {
	  		if (strMonth == strMonthArray[i]) {
				intMonth = i+1;
				break;
	  		}
		}
		if (isNaN(intMonth)) {
	  		return false;
		}
	}
	if (intMonth > 12 || intMonth < 1) {
		return false;
	}
	
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) {
		return false;
	}
	if (IsLeapYear(intYear) == true) {
		intDaysArray[1] = 29;
	}
	
	if (intday > intDaysArray[intMonth - 1]) {
		return false;
	}
	
	return true;
}

function IsLeapYear(intYear) {
	if (intYear % 100 == 0) {
		if (intYear % 400 == 0) {
		  return true;
		}
	} else {
		if ((intYear % 4) == 0) {
	  		return true;
		}
	}
	
	return false;
}

function move_box(an, box) { 
	var cleft = 0; 
	var ctop = 0; 
	var obj = an;
	while (obj.offsetParent) { 
		cleft += obj.offsetLeft; 
		ctop += obj.offsetTop; 
		obj = obj.offsetParent; 
	}
	box.style.left = cleft + 'px';
	ctop += an.offsetHeight + 8; 
	if (document.body.currentStyle && document.body.currentStyle['marginTop']) { 
		ctop += parseInt(document.body.currentStyle['marginTop']); 
	} 
	box.style.top = ctop + 'px';
}

function show_hide_box(an, width, height) { 
	var bgcolor = "#F4F8E7";
	var borderStyle = "1px solid #89C70A";
	var href = an.href; 
	var boxdiv = document.getElementById(href); 
	if (boxdiv != null) { 
		if (boxdiv.style.display=='none') { 
			move_box(an, boxdiv);
			boxdiv.style.display='block'; 
		} else 
			boxdiv.style.display='none';
		return false; 
	} 
	boxdiv = document.createElement('div');
	boxdiv.setAttribute('id', href);
	boxdiv.style.display = 'block';
	boxdiv.style.position = 'absolute'; 
	boxdiv.style.width = width + 'px';
	boxdiv.style.height = height + 'px'; 
	boxdiv.style.color = "#000000";
	boxdiv.style.padding = "0px";
	boxdiv.style.border = borderStyle;
	boxdiv.style.backgroundColor = bgcolor; 
	var contents = document.createElement('iframe'); 
	contents.scrolling = 'no';
	contents.frameBorder = '0'; 
	contents.style.width = width + 'px';
	contents.style.height = height + 'px'; 
	contents.src = href;
	boxdiv.appendChild(contents); 
	document.body.appendChild(boxdiv);
	move_box(an, boxdiv); 
	return false;
}
function showhideDiv(szDivID, szArrID) {
  if (document.layers) { // NN4+
  	if (document.layers[szDivID].display == "none"){
		document.layers[szDivID].display = "inline";
		document.layers[szDivID].style.position = 'relative'; 
		document.layers[szDivID].style.align = 'left';
		if (szArrID.src != "")
			szArrID.src = "images/arrow-open.png";
	}else{
    	document.layers[szDivID].display = "none";
		if (szArrID.src != "")
			szArrID.src = "images/arrow-close.png";
	}
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
	var obj = document.getElementById(szDivID);
  	if (obj.style.display == "none"){
		obj.style.display = "inline";
		obj.style.position = 'relative'; 
		obj.style.align = 'left'; 
		if (szArrID.src != "")
			szArrID.src = "images/arrow-open.png";
	} else {
    	obj.style.display = "none";
		if (szArrID.src != "")
			szArrID.src = "images/arrow-close.png";
	}
  } else if (document.all) { // IE 4
  	if (document.all[szDivID].style.display == "none"){
	    document.all[szDivID].style.display = "none";
		if (szArrID.src != "")
			szArrID.src = "images/arrow-open.png";
	}else{
	    document.all[szDivID].style.display = "none";
		if (szArrID.src != "")
			szArrID.src = "images/arrow-close.png";
	}
  }
}
function toggleDiv(szDivID) {
  if (document.layers) { // NN4+
  	if (document.layers[szDivID].display == "none"){
		document.layers[szDivID].display = "inline";
		document.layers[szDivID].style.position = 'relative'; 
		document.layers[szDivID].style.align = 'left';
	}else{
    	document.layers[szDivID].display = "none";
	}
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
	var obj = document.getElementById(szDivID);
  	if (obj.style.display == "none"){
		obj.style.display = "inline";
		obj.style.position = 'relative'; 
		obj.style.align = 'left'; 
	} else {
    	obj.style.display = "none";
	}
  } else if (document.all) { // IE 4
  	if (document.all[szDivID].style.display == "none"){
	    document.all[szDivID].style.display = "none";
	}else{
	    document.all[szDivID].style.display = "none";
	}
  }
}
function check_selected(theField){
	alert('Please dont Copy and Paste from this field.');
	theField.focus();
	return false;
}

// Email Validity Check
function validate_email(StrObj) {
	var email = ""; // if no match, use this
	var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
	if (emailsArray.length > 0){
		for (var i = 0; i < emailsArray.length; i++) {
			email += emailsArray[i];
			alert("Email found "+email);
		}
		if (email != "")
			return true;
	}
	return false;
}

// character counter
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function Text_Limit(szDivID, txtField, txtLimit){
	var templimit = 0
	if (txtField.value.length > txtLimit){
		txtLimit = txtField.value.length;
		txtField.value = txtField.value.substr(0, txtLimit);
		  if (document.layers) { // NN4+
			  document.layers[szDivID].style.display = 'block';
			  document.layers[szDivID].innerHTML = "<b>0</b> Characters left";
		  } else if (document.getElementById) { // gecko(NN6) + IE 5+
			var obj = document.getElementById(szDivID);
			  obj.style.display = 'block';
			  obj.innerHTML = "<b>0</b> Characters left";
		  } else if (document.all) { // IE 4
			  document.all[szDivID].style.display = 'block';
			  document.all[szDivID].innerHTML = "<b>0</b> Characters left";
		  }
	} else {
		  if (document.layers) { // NN4+
			  document.layers[szDivID].style.display = 'block';
			  document.layers[szDivID].innerHTML = "<b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  } else if (document.getElementById) { // gecko(NN6) + IE 5+
			var obj = document.getElementById(szDivID);
			  obj.style.display = 'block';
			  obj.innerHTML = "<b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  } else if (document.all) { // IE 4
			  document.all[szDivID].style.display = 'block';
			  document.all[szDivID].innerHTML = "<b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  }
	}
}
function Limit_Text(szDivID, txtField, txtLimit){
	var listArray = txtField.value.split("\n");
	var templimit = 0
	var lines=9;
	if (txtField.value.length > txtLimit || listArray.length > lines){
		txtLimit = txtField.value.length;
		txtField.value = txtField.value.substr(0, txtLimit);
		  if (document.layers) { // NN4+
			  document.layers[szDivID].style.display = 'block';
			  document.layers[szDivID].innerHTML = "<b>0</b> Lines or <b>0</b> Characters left";
		  } else if (document.getElementById) { // gecko(NN6) + IE 5+
			var obj = document.getElementById(szDivID);
			  obj.style.display = 'block';
			  obj.innerHTML = "<b>0</b> Lines or <b>0</b> Characters left";
		  } else if (document.all) { // IE 4
			  document.all[szDivID].style.display = 'block';
			  document.all[szDivID].innerHTML = "<b>0</b> Lines or <b>0</b> Characters left";
		  }
	} else {
		lines = lines-listArray.length;
		  if (document.layers) { // NN4+
			  document.layers[szDivID].style.display = 'block';
			  document.layers[szDivID].innerHTML = "<b>"+lines+"</b> Lines or <b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  } else if (document.getElementById) { // gecko(NN6) + IE 5+
			var obj = document.getElementById(szDivID);
			  obj.style.display = 'block';
			  obj.innerHTML = "<b>"+lines+"</b> Lines or <b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  } else if (document.all) { // IE 4
			  document.all[szDivID].style.display = 'block';
			  document.all[szDivID].innerHTML = "<b>"+lines+"</b> Lines or <b>"+(txtLimit - txtField.value.length) + "</b> Characters left";
		  }
	}
}
function checkout (chkFrm){
	if (chkFrm.agree.checked == true){
		chkFrm.frmAction.value='billingAddr';
		return true;
	} else {
		alert("Please check the terms of service check box to continue.");
		chkFrm.agree.focus();
	}
	return false;
}

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = jQuery(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
	  closetimer = null;}}

jQuery(document).ready(function()
{  jQuery('#jsddm > li').bind('mouseover', jsddm_open)
   jQuery('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;
jQuery(function()
{
  var hideDelay = 800;  
  var currentID;
  var hideTimer = null;

  // One instance that's reused to show info for the current person
  var container = jQuery('<div id="personPopupContainer">'
      + '<div id="personPopupContent"></div>'
      + '</div>');

  jQuery('body').append(container);
  jQuery('.personPopupTrigger').live('mouseover', function()
  {
      // format of 'rel' tag: pageid,personguid
	  var puwidth = jQuery('.personPopupTrigger').attr('rel');
		jQuery('#personPopupContainer').css('width', puwidth +'px');
		jQuery('#personPopupContent').css('width', puwidth+'px');
      var pageID = jQuery(this).attr('id');
      var httitle = jQuery(this).attr('name');
      var htalign = jQuery(this).attr('halign');
	  jQuery('.personPopupTrigger').css('cursor','help');
      // If no guid in url rel tag, don't popup blank
//	  alert(puwidth);
      if (currentID == '')
          return;

      if (hideTimer)
          clearTimeout(hideTimer);

      var pos = jQuery(this).offset();
      var width = jQuery(this).width();
	  if (htalign == 'left'){
		  container.css({
			  left: (pos.left - puwidth) + 'px',
			  top: pos.top + 20 + 'px'
		  });
	  }else{
		  container.css({
			  left: (pos.left + width) + 'px',
			  top: pos.top - 5 + 'px'
		  });
	  }

//      jQuery('#personPopupContent').html('&nbsp;');
	  jQuery('#personPopupContent').html('<div class="JT_loader"><div>');
      jQuery.ajax({
          type: 'GET',
          url: 'help.php',
          data: 'id=' + pageID,
          success: function(data)
          {
              // Verify that we're pointed to a page that returned the expected results.
//			  alert(data);
              if (data.length <= 0)
              {
                  jQuery('#personPopupContent').html('<span >No help found</span>');
              } else {

              // Verify requested person is this person since we could have multiple ajax
              // requests out if the server is taking a while.
                  var text = jQuery(data).find('.personPopupResult').html();
				  jQuery('#personPopupContent').html('<h3>'+httitle+'</h3>'+data);
              }
          }
      });

      container.css('display', 'block');
  });

  jQuery('.personPopupTrigger').live('mouseout', function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
      hideTimer = setTimeout(function()
      {
          container.css('display', 'none');
      }, hideDelay);
  });

  // Allow mouse over of details without hiding details
  jQuery('#personPopupContainer').mouseover(function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
  });

  // Hide after mouseout
  jQuery('#personPopupContainer').mouseout(function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
      hideTimer = setTimeout(function()
      {
          container.css('display', 'none');
      }, hideDelay);
  });
});

function shz(zid)
{
	if(document.getElementById(zid).className=='hide')
	{
		document.getElementById(zid).className='show';
	}
	else
	{
		document.getElementById(zid).className='hide';
	}
}

