<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 19;
// -----------------------------------------------------------------------------
// -->
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);




function openFullScreenWin( html, name, scroll) {
	var features;
	features = 'width='+ screen.width +',height='+ screen.height + ',top=0,left=0,toolbar=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no';
	//alert('features:' + features);
	var n=window.open( html, name, features);
}

function PopResultsWindow(obj){

    var zip = obj.getElementById("zipcode").value;
    var radius= obj.getElementById("radius").value;
    
    openNewWindow('/search/?zipcode='+zip+'&radius='+radius+'&ZipSearchSubmit=1', 'newWin','width=600, height=400, top=0,left=0,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

function openNewWindow(theURL,winName,features) {
	var newWin;
	var locationString = '';
	if (newWin && ieX){
		locationString = locationString + newWin.location;
		if (locationString != ''){
			newWin.location.href = theURL;
		} else {
			newWin = window.open(theURL,winName,features);
		}
	} else {
		newWin = window.open(theURL,winName,features);
	}
	return newWin;
}

function roll(ele) {
	var img = ele.getElementsByTagName("img")[0];
	var src = img.src;
	img.src = (/_on/.test(src)) ? src.replace('_on', '_off') : src.replace('_off', '_on');
}


    function isInteger(s)
    {   var i;
       s = s.replace("(","").replace(")","").replace(/-/g,"")
        for (i = 0; i < s.length; i++)
        {   
            // Check that current character is number.
            var c = s.charAt(i);
            if (((c < "0") || (c > "9"))) return false;
        }
        // All characters are numbers.
       if(s.length==10) {
        return true;
       }
       else
       {
        return false;
       } 
        
    }



function echeck(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 checkscript() {
    var theForm = document.forms[0];
    var aryReqFields= new Array(); 
   aryReqFields.push("fname", "lname", "addr1", "city", "state","zip","phone", "email"); 
    
    var aryErrormsgs = new Array();
    aryErrormsgs.push("First Name", "LastName", "Address", "City", "State","ZIP", "Phone","Valid Email Address")
    
    var theForm = document.forms[0]
    var alertText = "Please fill in the following:<br />"
    var errorText = "";
    for(i=0; i<aryReqFields.length; i++){
          
             if(theForm[aryReqFields[i]].value == ""){
            errorText += aryErrormsgs[i] + "<br />"
          }
          else{
            /*if(aryReqFields[i] == "phone"){
                alert(theForm[aryReqFields[i]].value.replace(/./g,''))
                if(isInteger(theForm[aryReqFields[i]].value)==false){
                errorText += aryErrormsgs[i] + "<Br />"
               } 
            }*/
                      
            if(aryReqFields[i] == "email" && echeck(theForm[aryReqFields[i]].value)==false){
                errorText += aryErrormsgs[i] + "<br />"
            }
          }
     }
    
     if(errorText != ""){
           var errorObj = document.getElementById("errormessage");
            errorObj.innerHTML = alertText+errorText;
            return false;
        }else {
       return true; 
//        doPost('/asp/post.asp',theForm);
  //      location.href="/stage/contactus/thanks/"
        

  }
  
  }
function checkscript2() {
    var theForm = document.forms[0]
    var alertText = "Please fill in the following:<Br />"
    var errorText = "";
    
    var aryReqFields= new Array(); 
     aryReqFields.push("fname", "lname", "contacttype","phone");
  
    var aryErrormsgs = new Array();
    aryErrormsgs.push("First Name", "Last Name", "Contact Type", "Phone <i>###-###-####</i>");
   
   if(getCheckedValue(theForm.contacttype) == "Email"){
   aryReqFields.push("email"); 
   aryErrormsgs.push("Valid Email Address"); 
  }  
    
    
    for(i=0; i<aryReqFields.length; i++){
         if(theForm[aryReqFields[i]].value == ""){
            errorText += aryErrormsgs[i] + "<Br />"
          }
          else{
            if(i==4 && aryReqFields[i] == "email"){
                if(echeck(theForm[aryReqFields[i]].value)==false){
                errorText += aryErrormsgs[i] + "<Br />"
               } 
            }
            if(i==3 && aryReqFields[3] == "phone"){
                if(isInteger(theForm[aryReqFields[i]].value)==false){
                errorText += aryErrormsgs[i] + "<Br />"
               } 
            }
            
            
          }
     }
    
     if(errorText != ""){
            var errorObj = document.getElementById("errormessage");
            errorObj.innerHTML = alertText+errorText;
            return false;
        }else {
            doPost('/asp/advertisepost.asp',theForm);
            location.href="/stage/advertise/thanks/";
  }
  
  }
     function doPost(sUrl, obj) {
      var poststr = "";
            for(i=0; i<obj.elements.length; i++){
                if(obj.elements[i].name=="contacttype"){
                poststr+=obj.elements[i].name + "="+ getCheckedValue(obj.elements[i]) + "&";  
               }
               else
               {
                poststr+=obj.elements[i].name + "="+ obj.elements[i].value + "&"; 
               } 
               
            }
      //makePOSTRequest('/asp/post.asp', poststr);
     makePOSTRequest(sUrl, poststr); 

   }

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 "";
}