<!-- hiding code from bad browsers
// this is for any index pages

// Atlas landing page code 
// added 7/5/2005
// atlas code moved to actual pages
// atlas code moved to actual pages


// added to cookie customer info 
// passed as ?b=1001&cinfo=fn:eric|ln:tester|adr:123+fake|cty:NY|st:NY|zp:11111|ctry:CA|em:ere@test.com|ph:212-222-2222
var cinfo = "";
cinfo = Get_Parm('cinfo');
if( (cinfo != "") && (cinfo != null) ) {
  SimpleCookie('cinfo',cinfo,60*24*30,"/");
//  alert('set cinfo to '+ cinfo);
}

// modified per Matt req by ericw 4/8/2004

var AFFILIATE_IF_BLANK = "NA";
var NEW_AFFILIATE_OVERWRITES = true;

var banner = GetCookie('affiliate');
var idnum = "";
var pid="";

// don't overwrite affiliates
if(!(NEW_AFFILIATE_OVERWRITES) && (banner != null) && (banner != "")  ) {
  idnum = banner;
} else {
  idnum = Get_Parm("b");

  if( (idnum == null) || (idnum == "") ) {
    // idnum = AFFILIATE_IF_BLANK;
  } else {
    pid=Get_Parm('pid');
  }
}

// old schema
/*
var banner = GetCookie('affiliate');
var idnum = Get_Parm("b"); 
var pid=Get_Parm('pid');
*/
var days2expire=60; // cookie expires in 60 days

var testing = "n";

function Get_Parm(name) {
    SCH = document.location.search;
    // alert('SCH = ' + SCH);
    var start = SCH.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != SCH.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = SCH.indexOf("&",len);
    if (end == -1) end = SCH.length;
    return unescape(SCH.substring(len,end));
}
function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var delay = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires)) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((delay == null) ? "" : ("; delay=" + delay)) +
        ((secure == true) ? "; secure" : "");
}
function SimpleCookie (cookieName, cookieValue, expires_in_minutes,path) {
  var expDate = new Date();
  expDate.setTime( expDate.getTime() + (expires_in_minutes * 60 * 1000) );
  SetCookie(cookieName,cookieValue,expDate.toGMTString(),path);
}

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 DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function SimplePopUnder(pageURL,h,w){
    h = parseInt(h);
    w = parseInt(w);
    if( (h == null) || (h == "") || (h == 0) || isNaN(h)) {
	  h=465;
	}
	if( (w == null) || (w == "") || (w == 0) || isNaN(w)) {
	  w=350;
	}
	
	var top='',left='';
	var smnNavUA = navigator.userAgent.toLowerCase();
	var	smnIE = (smnNavUA.indexOf('msie')>-1) && (smnNavUA.indexOf('opera')==-1) && (smnNavUA.indexOf('aol')==-1) && (smnNavUA.indexOf('webtv')==-1);
	var sOpt = 'width=' + w + ',height=' + h;
	if((parseInt(navigator.appVersion)>=5)&&!smnIE) sOpt += ',location=1';
	if(navigator.appVersion.indexOf("AOL") > 0) {
	  return;

        	}
	// alert('name:' + navigator.appName + '\n' + 'version:' + navigator.appVersion + '\ncode:' + navigator.appCodeName);
	var top=((screen.height-h)/2);
	top -= Math.round(top * smnTOffset);
	var left=((screen.width-w)/2);

	if (smnIE) sOpt += ',top=4000,left=4000';
	else sOpt += ',top=' + top + ',left=' + left;

	var nw = window.open('about:blank','nw',sOpt);

	// self.focus();
	// setTimeout("this.window.focus()",2000);

	if (nw.window.moveTo) nw.window.moveTo(left,top);
	nw.window.location = pageURL;
	nw.blur();
	// self.focus();
}

function affiliate2form() {
// in a form, use this: 
  var banner = GetCookie('affiliate');
  if( (banner != null) && (banner != "") ) {
	document.write('<input type="Hidden" name="affiliate" value="'+ banner+'">');
  } else {
	document.write('<input type="Hidden" name="affiliate" value="0">');
  }
}

function MAP_pixel(siteAcct) { // changed to use myaf_tracked cookie, and not require b on the url string
  var idnum = Get_Parm("b"); // only set the map pixel when passed in this way
  var subid = Get_Parm("sub");
  var myaf_tracked = GetCookie('myaf_tracked');
  if( (idnum != null) && (idnum != "") ) {
    SimpleCookie('myaf_tracked',idnum,60*24*days2expire,"/"); // simple cookie uses minutes
    document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +idnum+ '&sub=' + subid +'" height=1 width=1 border=0>');
    //alert('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +idnum+ '" height=1 width=1 border=0>"');
  } else if( (banner != null) && (banner != "") && (banner != myaf_tracked) ) {
    SimpleCookie('myaf_tracked',banner,60*24*days2expire,"/"); // simple cookie uses minutes
    document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +banner+ '&sub=' + subid +'" height=1 width=1 border=0>');
    // alert(idnum);
  }
}


function MAP_pixel_talk(siteAcct) {

 // alert('idnum=');    
 // return;

//  var idnum = Get_Parm("b"); // only set the map pixel when passed in this way
 if( (idnum != null) && (idnum != "") ) {
   document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +idnum+ '" height=10 width=10 border=2>');
   //alert('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +idnum+ '" height=10 width=10 border=2>');
 } else {
   // alert(idnum);
 }
}

// end functions always check for affiliate here


if (idnum && (idnum != "") && (idnum != null) ) {
  SimpleCookie('affiliate',idnum,60*24*days2expire,"/"); // simple cookie uses minutes
  document.write('<img src="http://www.miracleburn.com/eScripts/setcookie.php?b=' + idnum + '&pid=' + pid + '" height=1 width=1 border=0>');
} 


if(pid && (pid != null) && (pid != "")) {
   SimpleCookie('partnerUNID',pid,60*24*days2expire,"/");
} 

// save subid from MyAffiliate program links to pass on orderform redirect
var subidMyAffiliate = Get_Parm("sub");
if( (subidMyAffiliate != null) && (subidMyAffiliate != "") ) {
  SimpleCookie('subidMyAffiliate',subidMyAffiliate,60*24*days2expire,"/"); // simple cookie uses minutes
}

// end hiding -->

