window.defaultStatus="Find the work-at-home opportunities right for You!";

if (document.all) {
	document.onmouseover = showLink;
}

if (document.images) {
	spc  = new Image();
	spc.src = "/images/spacer.gif";
}

function showLink() {
if (window.event.srcElement.tagName == "A") {
	if (window.event.srcElement.innerText != "") {
	window.status = window.event.srcElement.innerText; return true;
			}
	}

	if (window.event.srcElement.tagName == "IMG" && window.event.srcElement.parentElement.tagName =="A" ) {
		window.status = window.event.srcElement.alt; return true;
	}

}


function addfav () {
var bookmarkurl="http://www.SurveyLot.com"
var bookmarktitle="SurveyLot.com: Find the work-at-home opportunities right for You!"
if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4) {
window.external.AddFavorite(bookmarkurl,bookmarktitle)
} else {
alert ("Please, press CTRL+D to bookmark this page.\nThank You!")
}

}

function hideDiv(objectId){
  changeObjectVisibility(objectId,'hidden','none');
}
function showDiv(objectId){
  changeObjectVisibility(objectId,'visible','block');
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility, newDisplay) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
        styleObject.display = newDisplay;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function newSearch () {
	hideDiv('staticinfo');
	showDiv('searchinfo');
	hideDiv('s1');
	showDiv('s2');
}




function viewDetails(pid){
	var hg=350;
	var argv = viewDetails.arguments.length;
	if ( argv > 1) {
		hg = viewDetails.arguments[1];
		}
		
var detailWindow=window.open(pid + '.htm','_blank','width=480, height=' + hg + ',scrollbars=yes,status=no,toolbar=no,menubar=no,location=no');
detailWindow.focus();
}



function comingsoon() {
	alert ('Please,  join our mailng list.  We will notify when this offer becomes available');
	document.sform.email.focus();

}

function showSearch () {
	document.images['retr'].src = spc.src;
}

function formCheck(formobj) {
	var unselect = false;	
	var errs = false;
	var alertMsg = "Please, make a valid selection!:\n";

	document.sform.fname.value = document.sform.fname.value.replace(/^\s*|\s*$/g,"");
	document.sform.lname.value = document.sform.lname.value.replace(/^\s*|\s*$/g,"");
	document.sform.email.value = document.sform.email.value.replace(/^\s*|\s*$/g,"");
	document.sform.zip.value = document.sform.zip.value.replace(/^\s*|\s*$/g,"");

	if (document.sform.fname.value == "" || document.sform.fname.value == null){
		alert ("Please, enter your first name.");
		errs = true;
		document.sform.fname.focus();
		return false;
	}
				
				
	if (document.sform.lname.value == "" || document.sform.fname.value == null){
		alert ("Please, enter your last name.");
		errs = true;
		unselect = true;
		document.sform.lname.focus();
		return false;
	}	

	if (document.sform.email.value == "" || document.sform.email.value == null){
		alert ("Please, enter your email address.");
		errs = true;
		unselect = true;
		document.sform.email.focus();
		return false;
	}


	if (formobj.gender.options[formobj.gender.selectedIndex].value == 0) {
		alert("Please, specify your gender.")
		errs = true;
		formobj.gender.focus();
		return false;
	}

	if (formobj.age.options[formobj.age.selectedIndex].value == 0) {
		alert("Please, specify your age.");
		errs = true;
		formobj.age.focus();
		return false;
	}

	if (formobj.country.options[formobj.country.selectedIndex].value == "0") {
		alert("Please, select country.");
		errs = true;
		formobj.country.focus();
		return false;
	}


	if (formobj.zip.value == ""  || formobj.zip.value == null) {
		alert("Please, enter zip code.");
		errs = true;
		formobj.zip.focus();
		return false;
	}

				
	if (echeck(document.sform.email.value)==false) {
		alert("Invalid email address!");
		errs = true;
		unselect = true;
		document.sform.email.focus();
		return false;
	}

	if (formobj.privacy_agree != null && formobj.privacy_agree.checked != 1) {
		alert("You must agree to our Privacy Policy by checking the checkbox!");
		errs = true;
		formobj.privacy_agree.focus();
		return false;
	}
	
	if (count_preferences()==false) {
		errs = true;
		return false;
	}
	
	if (errs == true) {
		return false;
	}  else {
		return true;
	}
}

	function echeck(str) {
		var email = 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
		 }

		 if (str.indexOf("..")!=-1){

		    return false
		 }


 
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null)
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }



 		 return true
	}

	

function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj.value = newVal;
}

function count_preferences() {
	
	var	valch = 0;
	for(var i=0; i< document.sform.elements['q'].length;i++){
		if(document.sform.elements['q'][i].checked)	valch++;
	}

	if (valch==0) {
		alert("Please, specify your preferences.");
		errs = true;
		return false;
	} else {
		return true;
	}
	
	}
	

function trackClick(clickType, pageName, id) {
	if (typeof(_gaq) != "undefined") {
		_gaq.push(['_trackEvent', 'Click' + clickType, pageName, 'id'+id]);
	}	
}

function ga_to(pageName, id) {
	trackClick('Listing', pageName, id);
}

function ga_ta(pageName, id) {
	trackClick('Freebie',pageName,id);
}	


