/**************************
 Javascript functions file
 **************************/
function getHeight()
{
        var y = 0;
        if (self.innerWidth)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientWidth)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}

function checkBrowserSize(){
    if (parseInt(navigator.appVersion)>3) {
        if (navigator.appName=="Netscape") {
	    winW = window.innerWidth-16;
	    winH = window.innerHeight-16;
	 }	
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	    winW = document.body.offsetWidth-20;
	    winH = document.body.offsetHeight-20;
	 }
	 if(winH > 0 && winH < 620) document.getElementById('feature_image').style.display='none';
     }
}

function CheckRequiredFields() {
		if(alreadySubmitted) return false;
		var errormessage = new String();
	        // Put field checks below this point.
		if(WithoutContent(document.ccform.firstname.value))
	                	{ errormessage += "\n\nPlease type something in the \"FirstName\" text field."; }
	        if(WithoutContent(document.ccform.lastname.value))
	                	{ errormessage += "\n\nPlease type something in the \"LastName\" text field."; }
		if(WithoutContent(document.ccform.email.value))
	                	{ errormessage += "\n\nPlease type something in the \"Email\" text field."; }
		if(WithoutContent(document.ccform.address1.value))
	                	{ errormessage += "\n\nPlease type something in the \"Address 1\" text field."; }
		if(WithoutContent(document.ccform.city.value))
	                	{ errormessage += "\n\nPlease type something in the \"City\" text field."; }
		if(WithoutContent(document.ccform.state.value))
	                	{ errormessage += "\n\nPlease type something in the \"State\" text field."; }
		if(WithoutContent(document.ccform.zip.value))
	                	{ errormessage += "\n\nPlease type something in the \"ZIP\" text field."; }
		if(WithoutContent(document.ccform.cardnum.value))
	                	{ errormessage += "\n\nPlease type something in the \"Credit Card Number\" text field."; }
		if(WithoutContent(document.ccform.cardcid.value))
	                	{ errormessage += "\n\nPlease type something in the \"CID\" text field."; }
	        // Put field checks above this point.
		if(errormessage.length > 2) {
	                alert('NOTE:' + errormessage);
	        	document.ccform.ccsubmit.disabled=false;
		        return false;
	        }
		alreadySubmitted = true;
		return true;
}	
	
function WithoutContent(ss) {
	        if(ss.length > 0) { return false; }
	        return true;
}

function toolbarDisplay() {
	var timer = document.getElementById("timer");
	var footer = document.getElementById("footer");
//	var list1 = document.getElementById("list1");
//	var list2 = document.getElementById("list2");
//	var list3 = document.getElementById("list3");
//	var list4 = document.getElementById("list4");
/*	
	footer.onmouseover = function() {
	    list1.style.display = "block";
	    list2.style.display = "block";
	    list3.style.display = "block";
	    list4.style.display = "block";
	}
	footer.onmouseout = function() {
	    list1.style.display = "none";
	    list2.style.display = "none";
	    list3.style.display = "none";
	    list4.style.display = "none";
	}
*/
	timerStartTime();
}

function changeBottomFrame(){
	 var newaddress = document.getElementById('webaddress').value;
	 if(newaddress.indexOf('http')==-1) newaddress = 'http://' + newaddress;
	 if(document.getElementById('bottomframe')!=null) frames['bottomframe'].location.href = newaddress;
	 else window.opener.location.href = newaddress;
}

function popOff(siteid){
	 timerStartTime();
	 window.open('success.php?popoff=true&siteid='+siteid+'&RemainingTime='+document.getElementById('timer').innerHTML,'toolbar','width=850,height=200,resizable=1,scrollbars=0,toolbar=0,titlebar=0');
	 location.href = document.getElementById('bottomframe').src;
}

function timerStartTime(){
	 if(document.getElementById("timer")){
	       document.getElementById("timer").innerHTML = Math.floor(cTicks/3600/10)+""+Math.floor(cTicks/3600%10)+":"+Math.floor(cTicks%3600/60/10)+""+Math.floor(cTicks%3600/60%10)+":"+Math.floor(this.cTicks%3600%60/10)+""+this.cTicks%3600%60%10;
	       cTicks--;
	       if(cTicks<=0){
	     	     clearInterval(timerInterval);
	     	     document.getElementById("timer").innerHTML = "00:00:00";
	       }
	 }
}
function ajaxLoader(url,postdata) {
	var xmlhttp = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				location.href = xmlhttp.responseText;
			}
		}
		xmlhttp.open("post", url, true);
		xmlhttp.setRequestHeader( 'Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
		xmlhttp.send(postdata);
	}
}

