//var product page
debut="";
hp = "";
prd = "";
cat = ""

//var diagnostics code
diagCode = "";

// popup for the checkout pages
function popcheckout(URL)
{ 
	newWin = window.open(URL,"popup","width=748,height=369,top=10,left=10,resizable=0,toolbar=0,scrollbars=0,status=0,menubar=0");
}

var newWindow

function openPopup(url, popupWidth, popupHeight) {
	if (newWindow && !newWindow.closed)	{
		newWindow.close()
	}	
		
	var winl = (screen.width - popupWidth) / 2;
	var wint = (screen.height - popupHeight) / 2;
		
	newWindow = open(url, 'Biotherm', ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
	newWindow.focus();
}

function openPopupPrint(url, popupWidth, popupHeight) {
	if(diagCode != '')
	{
		openPopup(url + '?catcode=' + diagCode, popupWidth, popupHeight);
	}
	else
	{
		openPopup(url, popupWidth, popupHeight);
	}
}



function AutoPost(oSelect)
{
	if (oSelect.options[oSelect.selectedIndex].value != '')
	{
		document.location = "index.aspx?StateID=" + oSelect.options[oSelect.selectedIndex].value;
	}
}

function AddToBag(SKU,RetailerSKU)
{
	var mf = GetMainFormName();

	var quantitySelect = GetElement("quantity_" + SKU,mf); 
	var quantity = quantitySelect.options[quantitySelect.selectedIndex].text; 
	
	if (location.search.indexOf('rtlid')!=-1)
		window.location = GetRetailerLocation(RetailerSKU,quantity);
	else
		window.location = '../checkout/Purchase_from_url.aspx?q=' + quantity + '&prdcode=' + SKU;
}

function AddToBag_men(SKU,RetailerSKU)
{
	var mf = GetMainFormName();

	var quantitySelect = GetElement("quantity_" + SKU,mf); 
	var quantity = quantitySelect.options[quantitySelect.selectedIndex].text; 
	
	if (location.search.indexOf('rtlid')!=-1)
		window.location = GetRetailerLocation(RetailerSKU,quantity);
	else
		window.location = '../../checkout_men/Purchase_from_url.aspx?q=' + quantity + '&prdcode=' + SKU;
}


function AddToBag_man(SKU)
{
	var mf = GetMainFormName();

	var quantitySelect = GetElement("quantity_" + SKU,mf); 
	var quantity = quantitySelect.options[quantitySelect.selectedIndex].text; 
	window.location = '../checkout_men/Purchase_from_url.aspx?q=' + quantity + '&prdcode=' + SKU;
}

function AddToBag_club(SKU)
{
	var mf = GetMainFormName();

	var quantitySelect = GetElement("quantity_" + SKU,mf); 
	var quantity = quantitySelect.options[quantitySelect.selectedIndex].text; 
	window.location = '../../checkout/Purchase_from_url.aspx?q=' + quantity + '&prdcode=' + SKU;
}

function AddToBag_club_men(SKU)
{
	var mf = GetMainFormName();

	var quantitySelect = GetElement("quantity_" + SKU,mf); 
	var quantity = quantitySelect.options[quantitySelect.selectedIndex].text; 
	window.location = '../../../checkout_men/Purchase_from_url.aspx?q=' + quantity + '&prdcode=' + SKU;
}

function GetRetailerLocation(code,qty)
{
	externalurl = "http://staging.macys.com/bag/addto.ognc?AddToBagCall=External&Brand=Biotherm&";
	externalurl += "Upc=" + code + "&";
	externalurl += "Quantity="+ qty +"&";
	externalurl += "PartnerURL=" + urlEncode(document.location);
	return externalurl;
}

function poplog()
{
	//var winl = (screen.width - 400) / 2;
	//var wint = (screen.height - 450) / 2;
	openPopup("../club/popup_login_product.aspx", 430,450);
}	
	
review_width  = 520
review_height = 550;	

function openPopup_Review(url) {
	openPopup(url, review_width, review_height);
}
	
function poplog_review()
{
	openPopup("../club/popup_login_review.aspx", 430,450);
	//var winl = (screen.width - review_width) / 2;
	//var wint = (screen.height - review_height) / 2;
	//window.open("../club/popup_login_review.aspx",'popup_login',"width="+review_width+",height="+review_height+",top=" + wint + ",left=" + winl + ",resizable=0,toolbar=0,scrollbars=0,status=0,menubar=0");
}

function position_review()
{
//	window.resizeTo(review_width,review_height);	
//	var winl = (screen.width - review_width) / 2;
//	var wint = (screen.height - review_height) / 2;	
//	window.moveTo(winl,wint);
}

var myimages=new Array()

function MM_preloadImages() { 
for (i=0;i<MM_preloadImages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=MM_preloadImages.arguments[i]
}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null)
{
document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
}
}

function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}
function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}

function GetSeal()
{
 document.write("<script src=https://seal.verisign.com/getseal?host_name=staging.biotherm-usa.com&size=S&use_flash=YES&use_transparent=YES&lang=en></script>") ;	
}




