﻿var newwindow1;

function poptastic1(url)
{
	newwindow1=window.open(url,'name','height=270,width=590,top=100,left=100');
	if (window.focus) {newwindow1.focus()}
}

function checkEmail (email){
	if(email.match(/^[a-z|0-9]+[\_\.\-]*[a-z|0-9]+\@(([a-zA-Z0-9\-\_])+\.)+([a-zA-Z0-9]{2,4})+$/i))
		return true;
	else{
		return false;
	}
}

function check(src, subid, refer, email, optin, zip) {
	var err="";
	if(email=="")
		err+="Enter email address"+"\n";
	if(email!="" && !checkEmail(email))
		err+="Enter valid email address"+"\n"
	if(err=="")
		return submitToShopAtHome(src, subid, refer, email, optin, zip);
	else{
		alert(err);
		return false;
	}
}
function submitToShopAtHome(src, subid, refer, email, optin, zip){
	var url = "http://discounts.shopathome.com/Join/JoinNoInterface.aspx";
	var windowname = "newwin";

	var height = 20;
	var width = 20;
	leftVal = 10000;
	topVal = 10000;

//	if (/Firefox/.test(navigator.userAgent)) {
	    height = 60;
	    width = 700;
	    leftVal = (screen.width - width) / 2;
	    topVal = (screen.height - height) / 2;
//	}

	options = "left=" + leftVal + ",top=" + topVal + ",height=" + height + ",width=" + width;

	//Add your OWNER, subid, refer, src values here
	url += "?owner=NONBUNDLE&subid=" + subid + "&refer=" + refer + "&src=" + src;
	url += "&email=" + email;
	url += "&optin=" + ((optin) ? "y" : "n");

	if (typeof zip !== 'undefined') {
	    url += "&zip=" + zip;
	}

	mywin = window.open( url , windowname , options , false);
	setTimeout("mywin.close();", 45*1000);

	//add your own processing code here
}

function getCurrentForm(elem) {
    while (elem.parentNode && !elem.parentNode.tagName.match(/FORM/i)) {
        elem = elem.parentNode;
    }
    return elem.parentNode;
}
