// set the popup window width and height



// set the screen position where the popup should appear

// set the url of the page to show in the popup

// var urlPop = wsurl2;

// set the title of the page



// set this to true if the popup should close
// upon leaving the launching page; else, false



// ============================
// do not edit below this line
// ============================



function openFrameless(urlPop, windowW, windowH){
// var windowW=700 // wide
// var windowH=600 // high
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
var title =  "Beauty Trends"
var autoclose = true
s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false

  if (beIE){
    NFW = window.open("","popFrameless","resizable=yes,fullscre,"+s)     
    NFW.blur()
    window.focus()       
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
    var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame marginwidth=0 marginheight=0 name='top' src='"+urlPop+"'>"+
"<frame marginwidth=0 marginheight=0 name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
    NFW.document.open();
    NFW.document.write(frameString)
    NFW.document.close()
  } else {
    NFW=window.open(urlPop,"popFrameless","resizable=yes,"+s)
    NFW.blur()
    window.focus() 
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
  }   
  NFW.focus()   
  if (autoclose){
    window.onunload = function(){NFW.close()}
  }
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

var url = location.href;

if (url.indexOf("avad=") > 0) {
	var affdata;
	var merchant_id = 10121;
	var cookie_name = 'avant_' + merchant_id;
	var cookie_days = 120;
	var cookie_domain = '.beautytrends.com';
	var aUrl = url.split("avad=");

	// Delete any existing cookie
	delete_cookie(cookie_name);

	// Parse out tracking data from the url
	if (aUrl[1].indexOf("&") > 0) {
		affdata = aUrl[1].substring(0, aUrl[1].indexOf("&"));
	}
	else {
		affdata = aUrl[1];
	}

	var expdate = new Date();
	expdate.setTime(expdate.getTime() + cookie_days*24*60*60*1000);
	document.cookie = cookie_name + "=" + escape(affdata) + "; expires=" + expdate + "; path=/; domain=" + cookie_domain + ";";
}
