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


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

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

if(!varIsDefined('banner')) {
  var banner = GetCookie('affiliate');
}
// var nr_banner = GetCookie('nr_affiliate');
var idnum = "";
var pid="";
var days2expire=60; // cookie expires in 60 days
var testing = "n";

if(!varIsDefined('show_alert')) {
  var show_alert="N";
}

// don't overwrite affiliates
if(varIsDefined('myaf_affiliate') && (myaf_affiliate !== null) && (myaf_affiliate != '') ) {
   idnum = Get_Parm_CPA("b"); // myaf_affiliate;
   debalert('26:idnum from Get_Parm_CPA(b)=' + idnum);
  
} else if(!(NEW_AFFILIATE_OVERWRITES) && (banner != null) && (banner != "")  ) {
  idnum = banner;
} else {
  idnum = Get_Parm_CPA("b");
  debalert('32:idnum from Get_Parm_CPA(b)=' + idnum);
  
  if( (idnum == null) || (idnum == "") ) {
    // idnum = AFFILIATE_IF_BLANK;
  } else {
    pid=Get_Parm_CPA('pid');
  }
}


// always check for affiliate here

if (idnum && (idnum != "") ) {
  SimpleCookie('affiliate',idnum,60*24*days2expire,"/"); // simple cookie uses minutes
  if(varIsDefined('myaf_domain') && (myaf_domain !== null) && (myaf_domain != '') ) {
    if(varIsDefined('myaf_affiliate') && (myaf_affiliate!== null) && (myaf_affiliate!='') ) {
      //noop
      var temp_affiliate=myaf_affiliate;
    } else {
      var temp_affiliate = idnum;
    }
    var tempurl = 'http://' + myaf_domain + '/eScripts/setcookie.php?b=' + temp_affiliate + '&pid=' + pid + '&MAT=Y';
    document.write('<img src="' + tempurl + '" height=1 width=1 border=0>');

    if(varIsDefined('show_alert') && (show_alert == 'Y') ) {
      document.write(tempurl + '<br>');
      alert(tempurl);
    }
  }
} 

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_CPA("sub");
if( (subidMyAffiliate != null) && (subidMyAffiliate != "") ) {
  SimpleCookie('subidMyAffiliate',subidMyAffiliate,60*24*days2expire,"/"); // simple cookie uses minutes
}



function varIsDefined(variable) {
  return (typeof(window[variable]) == "undefined") ?  false: true;
}
function TrackEventWArgs(sd,da,so,sm){
  if(so+''=='undefined'){
    so='';
  }
  if(sm+''=='undefined'){
    sm='';
  }
  gt_url = 'http://track.roiservice.com/track/LogToDb.asp.aspx';
  gt_url += '?merchantid=' + ROIID ;
  au('merchantsessionid', GTC);
  au('description', sd);
  au('pgurl', addCPArgs(document.URL));
  au('amount', da);
  au('orderid', so);
  au('cid', gt_cid);
  au('sm', sm);
  au('referer', document.referrer);
  au('nsid', sn);
  document.write('<!--wr img---><IMG' + ' sr' + 'c="' + gt_url + '" border="0" height="1" width="1">');
}

function addCPArgs(url) {
  url = url + '';
  var addArgs = '';
  if(varIsDefined('CP_ARGS')) {
    addArgs = CP_ARGS;
  }
  
  debalert('in addCPArgs:url=' + url + '\naddArgs=' + addArgs);
  if(addArgs == '') {
    return(url);
  }
  if(url.indexOf("?") >= 0) {
    url = url + '&' + CP_ARGS;
  } else {
    url = url + '?' + CP_ARGS;
  }
  debalert('in addCPArgs:return url=' + url);
  
  return(url);
}

function Get_Parm_CPA(name) {
    SCH = addCPArgs(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) {
 var use_af = Get_Parm_CPA("b");
 if(varIsDefined('myaf_affiliate') && (myaf_affiliate != '')) {
   if(idnum == banner) {
     debalert('myaf_af(' + myaf_affiliate + ') defined, id same as banner ('+banner+')');
     return;
   } else {
     debalert('myaf_af(' + myaf_affiliate + ') defined, idnum ' + idnum + ' not same as banner ' + banner);
   }
   // use_af = myaf_affiliate;
 } else if(idnum == banner) {
   debalert('myaf_af not defined, idnum same as banner('+banner+')');
   return;
 } else {
   // use_af = Get_Parm_CPA("b");
   debalert('myaf_af not defined, idnum not same as banner, use '+use_af+'');
   
 }
 var subid = Get_Parm_CPA("sub");
 if( (use_af != null) && (use_af != "") ) {
   debalert('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +use_af+ '" height=1 width=1 border=0>"');
   document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +use_af+ '&sub=' + subid +'" height=1 width=1 border=0>');
 } else {
   debalert('no use_af');
 }
}
function MAP_pixel_specific(siteAcct,myaf_affiliate,myaf_domain) {

 var idnum = Get_Parm_CPA("b"); // only set the map pixel when passed in this way
 var subid = Get_Parm_CPA("sub");
 var raf = GetCookie('raf');

 if( (idnum != null) && (idnum != "") ) {
   if( (myaf_affiliate != null) && (myaf_affiliate != "") ) {
     idnum = myaf_affiliate;
     // alert(idnum);
   }
   if( (raf=="") || (raf == null) || (raf != idnum) ) {

     if((myaf_domain != "") && (myaf_domain != null)) {
       document.write('<img src="http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid + '"height=1 width=1 border=0>');
     }

     document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +idnum+ '&sub=' + subid +'" height=1 width=1 border=0>');
     
   }
   SimpleCookie('raf',idnum,60*24*days2expire,"/");	
   // alert('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +idnum+ '" height=1 width=1 border=0>"');
 } else if( (myaf_affiliate != null) && (myaf_affiliate != "") ) {
   if( (raf=="") || (raf == null) || (raf != idnum) ) {
     idnum = myaf_affiliate;

     if((myaf_domain != "") && (myaf_domain != null)) {
       document.write('<img src="http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid + '"height=1 width=1 border=0>');
     }

     document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +idnum+ '&sub=' + subid +'" height=1 width=1 border=0>');

   }
   SimpleCookie('raf',idnum,60*24*days2expire,"/");
   
   // alert(idnum);
 }
}
function MAP_pixel_specific_talk(siteAcct,myaf_affiliate,myaf_domain,another) {

 var idnum = Get_Parm_CPA("b"); // only set the map pixel when passed in this way
 var subid = Get_Parm_CPA("sub");
 var raf = GetCookie('raf');

 if( (idnum != null) && (idnum != "") ) {
   alert('idnum='+idnum);
   if( (myaf_affiliate != null) && (myaf_affiliate != "") ) {
     idnum = myaf_affiliate;
     // alert(idnum);
   }
   if( (raf == null) || (raf != idnum) ) {
     if((myaf_domain != "") && (myaf_domain != null)) {
       document.write('<img src="http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid + '"height=1 width=1 border=0>');
       document.write('http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid);
	
     }
     document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +idnum+ '&sub=' + subid +'" height=1 width=1 border=0>');
     
   }
   SimpleCookie('raf',idnum,60*24*days2expire,"/");	
   // alert('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/b.asp?id=' +idnum+ '" height=1 width=1 border=0>"');
 } else if( (myaf_affiliate != null) && (myaf_affiliate != "") ) {

   if( (raf == "") || (raf == null) || (raf != idnum) ) {
     alert('myaf_affiliate='+myaf_affiliate + ', raf=' + raf + ', myaf_domain=' + myaf_domain);
     idnum = myaf_affiliate;
     if((myaf_domain != "") && (myaf_domain != null)) {
       document.write('<img src="http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid + '"height=1 width=1 border=0>');
       document.write('http://' + myaf_domain + '/eScripts/remote_cookie.html?b=' + idnum + '&sub=' + subid);
     }
     document.write('<img src="http://www.myaffiliateprogram.com/u/'+siteAcct+ '/t.asp?id=' +idnum+ '&sub=' + subid +'" height=1 width=1 border=0>');

   }
   SimpleCookie('raf',idnum,60*24*days2expire,"/");
   
   // alert(idnum);
 } else {
   alert('no cookie');
 }
}


function MAP_pixel_talk(siteAcct) {

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

//  var idnum = Get_Parm_CPA("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 


function varIsDefined( variable) {
   return (typeof(window[variable]) == "undefined")?  false: true;
}
function debalert(txt) {
  if(varIsDefined('show_alert') && show_alert == 'Y') {
    alert(txt);
  }
}

// end hiding -->

