/*
Author: Michele
Date: 09/10/2004 
Description: Cookie Mix
*/



/* Function: popWindow
 * -------------------
 * Generic popup window function, can be called from pretty much anywhere.
 * opens a popup window with passed in url, height, width, and name.  The
 * popup window should open centered on the computer screen.
 *
 */

function popSmmWindow(url, name, width, height) {
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	var opts = 'height=' + height + ',width=' + width + ",screenX=" + x + ",left=" + x + ",screenY=" + y + ",top=" + y + ',location=no,scrollbars=yes,menubar=no,resizable=no,status=no,toolbar=no';
	//var opts = "height=" + height + ",width=" + width + ",scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no";
	_nw = window.open(url, name, opts);
	_nw.focus();

}



function GetCookie(Name) {
	var search = Name + "="
  	var returnvalue = "";
  	if (document.cookie.length > 0) {
    	offset = document.cookie.indexOf(search);
    	if (offset != -1) { // if the cookie exists
      		offset += search.length;
      		end = document.cookie.indexOf(";", offset); // set the index of beginning value
      		if (end == -1) {// set the index of the end of cookie value
        		end = document.cookie.length;
      			returnvalue=unescape(document.cookie.substring(offset, end));
    		}
  		}
  		return returnvalue;
  	}
}

function SetCookie (name, value) {
  	var argv = SetCookie.arguments;
  	var argc = SetCookie.arguments.length;
 	var expires = (argc > 2) ? argv[2] : null;
 	var domain = (argc > 3) ? argv[3] : null;
  	var path = (argc > 4) ? argv[4] : null;
  	var delay = (argc > 5) ? argv[5] : null;
	var secure = (argc > 6) ? argv[6] : false;
   	document.cookie = name + "=" + escape (value) +
  	((expires == null) ? "" : ("; expires=" + expires)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((path == null) ? "" : ("; path=" + path)) +
   	((delay == null) ? "" : ("; delay=" + delay)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.setTime (exp.getTime() - 1);
}

function SimpleCookie (cookieName, cookieValue, expires_in_minutes,thisdomain,path) {
  	var expDate = new Date();
  	expDate.setTime( expDate.getTime() + (expires_in_minutes * 60 * 1000*24*60) );
  	SetCookie(cookieName,cookieValue,expDate.toGMTString(),thisdomain,path);
}

/*
Author: Michele
Date: 07/29/2004 
Description: Image rollovers
*/
if (document.images) {
	var emboff = new Image();
   	emboff.src = "/images/homeoff.gif";
        var emb1off = new Image();
        emb1off.src = "/images/howoff.gif";
        var emb2off = new Image();
        emb2off.src = "/images/priceoff.gif";
        var emb3off = new Image();
        emb3off.src = "/images/touroff.gif";
        var emb4off = new Image();
        emb4off.src = "/images/testimonialsoff.gif";
        var emb5off = new Image();
        emb5off.src = "/images/faqoff.gif";
        var emb6off = new Image();
        emb6off.src = "/images/signupoff.gif";
        var emb7off = new Image();
        emb7off.src = "/images/machineoff.gif";
        var emb8off = new Image();
        emb8off.src = "/images/dashoff.gif";
        var emb9off = new Image();
        emb9off.src = "/images/toolsoff.gif";
        var emb10off = new Image();
        emb10off.src = "/images/accountoff.gif";
        var emb11off = new Image();
        emb11off.src = "/images/contactoff.gif";
        var emb12off = new Image();
        emb12off.src = "/images/overviewoff.gif";
        var emb13off = new Image();
        emb13off.src = "/images/visitorsoff.gif";
        var emb14off = new Image();
        emb14off.src = "/images/conversionsoff.gif";
        var emb15off = new Image();
        emb15off.src = "/images/incomeoff.gif";
        var emb16off = new Image();
        emb16off.src = "/images/affiliateoff.gif";



	var embon = new Image();
   	embon.src = "/images/homeon.gif";
        var emb1on = new Image();
        emb1on.src = "/images/howon.gif";
        var emb2on = new Image();
        emb2on.src = "/images/priceon.gif";
        var emb3on = new Image();
        emb3on.src = "/images/touron.gif";
        var emb4on = new Image();
        emb4on.src = "/images/testimonialson.gif";
        var emb5on = new Image();
        emb5on.src = "/images/faqon.gif";
        var emb6on = new Image();
        emb6on.src = "/images/signupon.gif";
        var emb7on = new Image();
        emb7on.src = "/images/machineon.gif";
        var emb8on = new Image();
        emb8on.src = "/images/dashon.gif";
        var emb9on = new Image();
        emb9on.src = "/images/toolson.gif";
        var emb10on = new Image();
        emb10on.src = "/images/accounton.gif";
        var emb11on = new Image();
        emb11on.src = "/images/contacton.gif";
        var emb12on = new Image();
        emb12on.src = "/images/overviewon.gif";
        var emb13on = new Image();
        emb13on.src = "/images/visitorson.gif";
        var emb14on = new Image();
        emb14on.src = "/images/conversionson.gif";
        var emb15on = new Image();
        emb15on.src = "/images/incomeon.gif";
       var emb16on = new Image();
        emb16on.src = "/images/affiliateon.gif";


}

function img_act(imgName) {
if (document.images) {
       	document.images[imgName].src = eval(imgName + "on.src");
}
}
    
function img_inact(imgName) {
if (document.images) {
        document.images[imgName].src = eval(imgName + "off.src");
}
}


/*
Author: Michele
Date: 07/29/2004 
Description: new window
*/
function NewWindow(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";win=window.open(mypage,myname,settings);
	win.focus();
}

function NewWindow1(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";win=window.open(mypage,myname,settings);
	win.focus();
}

function launchWin(urlPath, winName, params) {
	winName = window.open (urlPath,winName,params);
	winName.focus();
}


/*
Author: Michele
Date: 02/08/2005 
Description: show hide divs
*/
function showDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "block"; 
}
function hideDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "none";  	
}
function hideparentDiv(layer) {
  	elem = parent.document.getElementById(layer);
  	elem.style.display = "none";  	
}
function showRow(rowid) {
  	elem = document.getElementById(rowid);
  	if (elem.style.display == 'none') {
	  	elem.style.display = "table-row"; 
	} else {
	  	elem.style.display = "none"; 
	}
}
function hideRow(rowid) {
  	elem = document.getElementById(rowid);
  	elem.style.display = "none"; 
}

/*
Author: Michele
Date: 02/23/2005 
Description: remove email
*/
var effaced=0;

function efface (elem) {
	if (effaced == 1){
		elem.value='';
	}
	if (effaced > 0) {
		effaced=1;
	} else {
		effaced=effaced+1;
	}
}


/*
Author: Michele
Date: 10/23/2005 
Description: give custom colors
*/


function changecolors(header,currHeader) {
if (!currHeader) { 
	if (header == "animals_casualcats.gif") {
		document.theForm.titleColor.value = "#FF9C00";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#014B91";
	} else if (header == "animals_catfaces.gif") {
		document.theForm.titleColor.value = "#015C7F";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#015C7F";
	} else if (header == "animals_paws.gif") {
		document.theForm.titleColor.value = "#9D080D";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#9D080D";
	} else if (header == "animals_pawsbones.gif") {
		document.theForm.titleColor.value = "#4280AF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#97C7EB";
	} else if (header == "animals_puppylove.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#CEC4C5";
	} else if (header == "business_bluegear.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#8791B7";
	} else if (header == "business_building.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#41341E";
	} else if (header == "business_gears.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#919BA9";
	} else if (header == "business_global.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#00AEEF";
	} else if (header == "business_grey.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#333333";
	} else if (header == "business_newspaper.gif") {
		document.theForm.titleColor.value = "#404738";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#404738";
	} else if (header == "business_thumbsup.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "business_woman.gif") {
		document.theForm.titleColor.value = "#18387F";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#18387F";
	} else if (header == "flowers_pink.gif") {
		document.theForm.titleColor.value = "#325299";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#ED008D";
	} else if (header == "general_black.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_ltblue.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_blue.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_blue1.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_green.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_grey.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_orange.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_pink.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_purple.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_red.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "general_white.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "personal_bubbles1.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#708BBF";
	} else if (header == "personal_bubbles.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#708BBF";
	} else if (header == "personal_hipwoman.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#CE3D07";
	} else if (header == "personal_martini.gif") {
		document.theForm.titleColor.value = "#422203";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#28CCE0";
	} else if (header == "personal_music.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#7D5769";
	} else if (header == "personal_redbubble.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#C33377";
	} else if (header == "personal_retro.gif") {
		document.theForm.titleColor.value = "#004348";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#05AECD";
	} else if (header == "recreation_bike.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#8781BD";
	} else if (header == "recreation_boat.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "techno_blueflare.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#000000";
	} else if (header == "techno_blue.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#015195";
	} else if (header == "techno_green.gif") {
		document.theForm.titleColor.value = "#FFFFFF";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#245828";
	} else if (header == "techno_wave1.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#517425";
	} else if (header == "techno_mouse.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#59B8E4";
	} else if (header == "techno_wave.gif") {
		document.theForm.titleColor.value = "#000000";
		document.theForm.bgcolor.value = "#FFFFFF";
		document.theForm.borderColor.value = "#A3B2B7";
	} else if (header == "smmpreload.gif") {
		document.theForm.titleColor.value = "";
		document.theForm.bgcolor.value = "#E2E2E2";
		document.theForm.borderColor.value = "#B8B8B8";
	}
}
}

var exit=true;
function xitpop() {
	if (exit)
	open('exitpop.php','','toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,height=700,width=525');
}


function changeTarget(type) {
	targetURL = "http://www.simplemoneymachines.com/index" + type + "-split.php";
	document.squeeze.redirectURL.value = targetURL;
	if (type == "NB") {
		actionURL = "http://www.simplemoneymachines.com/siteadmin/autoresponder/autoSubscribe.php?listID=9&customerID=1&machineID=1&fromForm=1";
	} else {
		actionURL = "http://www.simplemoneymachines.com/siteadmin/autoresponder/autoSubscribe.php?listID=7098&customerID=1&machineID=1&fromForm=1";
	}
	document.squeeze.action = actionURL;
 
}
function checkTarget() {
	target = document.squeeze.redirectURL.value;
	if (target == "") {
		targetURL = "http://www.simplemoneymachines.com/index-split.php";
	}
	
}

function ValidateEmails () {

	error = false;
	f = document.squeeze;
	error_message = "The following error(s) must be corrected before the form can be submitted:\n\n";
	
	// E-MAIL
	if (f.email1.value == '' || f.email2.value == '' || f.email3.value == '') {
		error_message = error_message + "* You Need To Refer At Least 3 Friends To Get Your Free Gift.\n";
		error = true;
	}

	if (f.email1.value) {
		var str=f.email1.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your First Friend is Not Valid...\n";
			error = true;
		}
	}

	if (f.email2.value) {
		var str=f.email2.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Second Friend is Not Valid...\n";
			error = true;
		}
	}

	if (f.email3.value) {
		var str=f.email3.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Third Friend is Not Valid...\n";
			error = true;
		}
	}

	// ALERT AND RETURN FALSE IF ERROR
	if (error == true) {
		error_message = error_message + "\nIf You Do Not Want to Refer Friends To Get Your Gift Click the 'Skip This...' Link At The Bottom Of The Page.\n";
		alert (error_message);
		return false;
	}

	// OTHERWISE, RETURN TRUE
	return true;
}

function ValidateEmails1 () {

	error = false;
	f = document.squeeze;
	error_message = "The following error(s) must be corrected before the form can be submitted:\n\n";
	
	// E-MAIL
	if (f.email1.value == '') {
		error_message = error_message + "* You Need To Refer At Least 1 Friend To Enter the Contest.\n";
		error = true;
	}

	if (f.email1.value) {
		var str=f.email1.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your First Friend is Not Valid...\n";
			error = true;
		}
	}

	if (f.email2.value) {
		var str=f.email2.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Second Friend is Not Valid...\n";
			error = true;
		}
	}

	if (f.email3.value) {
		var str=f.email3.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Third Friend is Not Valid...\n";
			error = true;
		}
	}

	if (f.email4.value) {
		var str=f.email4.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Fourth Friend is Not Valid...\n";
			error = true;
		}
	}	

	if (f.email5.value) {
		var str=f.email5.value;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)) {
		} else {
			error_message = error_message + "* The Email Address of Your Fifth Friend is Not Valid...\n";
			error = true;
		}
	}
	
	// ALERT AND RETURN FALSE IF ERROR
	if (error == true) {
		error_message = error_message + "\nIf You Do Not Want to Refer Friends Simply Exit this page.\n";
		alert (error_message);
		return false;
	}

	// OTHERWISE, RETURN TRUE
	return true;
}



var browser_name = navigator.appName;

function showDivProd(layer) {
	elem = document.getElementById('1');
	elem.style.display = "none";

	elem = document.getElementById('1b');
	elem.style.display = "none";

	elem = document.getElementById('1c');
	elem.style.display = "none";

	elem = document.getElementById('1e');
	elem.style.display = "none";

	elem = document.getElementById('1f');
	elem.style.display = "none";

	elem = document.getElementById('2');
	elem.style.display = "none"; 

	elem = document.getElementById('2a');
	elem.style.display = "none"; 

	elem = document.getElementById('2b');
	elem.style.display = "none"; 

	elem = document.getElementById('4');
	elem.style.display = "none"; 

	elem = document.getElementById('50');
	elem.style.display = "none"; 

	if (layer == "0") {
	}

	if (layer == "1") {
		elem = document.getElementById("1");
		elem.style.display = "block"; 

		elem = document.getElementById("1b");
		elem.style.display = "block"; 

		elem = document.getElementById("1c");
		elem.style.display = "block"; 
		
		elem = document.getElementById("1e");
		elem.style.display = "block"; 	
		
		elem = document.getElementById("1f");
		elem.style.display = "block"; 		

		elem = document.getElementById("4");
		elem.style.display = "block"; 		

	}

	if (layer == "2") {
		elem = document.getElementById("2");
		elem.style.display = "block"; 

		elem = document.getElementById("2a");
		elem.style.display = "block"; 

		elem = document.getElementById("2b");
		elem.style.display = "block"; 

		elem = document.getElementById("4");
		elem.style.display = "block"; 		
	}

	if (layer == "50") {
		elem = document.getElementById("50");
		elem.style.display = "block"; 

		elem = document.getElementById("4");
		elem.style.display = "block"; 		

	}	
}

