function createCookie(name,value,days) {
	var docurl=document.URL;
	if(docurl.indexOf(".toptenreviews.com")>0)
		var dmn = "; domain=.toptenreviews.com;";
	else
		var dmn = ";";

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/"+dmn;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}

key_id='';newlandingpage='';
function tracker(bname,bid,key_id){ //bname=button name, bid=button id, key_id=client created id
//	if(bname) { bname = "&cid="+escape(bname); }
//	if(bid) { bid = "&bid="+escape(bid); }
//	var stprto="http";if(location.protocol == "https:"){stprto="https";}
//	document.t1x1gif.src=stprto+'://www.halstats.com/button.php?t=a'+bname+bid;
}

var first_access = readCookie("first_access");
if( first_access==null || first_access=="" ) {
	first_access = 1;
	createCookie('first_access', '1', 6)
} else {
	first_access++;
	createCookie('first_access', first_access, 6)
}

function build_ad_url(){
	var i=window;
	var ad_url = "http://www.toptenreviews.com/ads/js3.php?f="+escape(document.URL);
	if(typeof(i.ad_link_color)=="undefined"){ ad_url+="&link_clr=0000ff"; }else{ ad_url+="&link_clr="+i.ad_link_color; }
	if(typeof(i.ad_border)=="undefined"){ ad_url+="&bdr=0"; }else{ ad_url+="&bdr="+i.ad_border; }
	if(typeof(i.ad_caption_color)=="undefined"){ ad_url+="&capclr=333333"; }else{ ad_url+="&capclr="+i.ad_caption_color; }
	if(typeof(i.ad_text_color)=="undefined"){ ad_url+="&text_clr=333333"; }else{ ad_url+="&text_clr="+i.ad_text_color; }
	if(typeof(i.ad_background_color)=="undefined"){ ad_url+="&bg_clr=ffffff"; }else{ ad_url+="&bg_clr="+i.ad_background_color; }
	if(typeof(i.ad_border_color)=="undefined"){ ad_url+="&brdr_clr=999999"; }else{ ad_url+="&brdr_clr="+i.ad_border_color; }
	if(typeof(i.ad_location)=="undefined"){ ad_url+="&loc=R"; }else{ ad_url+="&loc="+i.ad_location; }
	if(typeof(i.ad_width)=="undefined"){ ad_url+="&wdth=120"; }else{ ad_url+="&wdth="+i.ad_width; }
	if(typeof(i.ad_height)=="undefined"){ ad_url+="&hght=900"; }else{ ad_url+="&hght="+i.ad_height; }
	if(typeof(i.ad_orientation)=="undefined"){ ad_url+="&tp=v"; }else{ ad_url+="&tp="+i.ad_orientation; }
	document.write ("<" + "script language='JavaScript' type='text/javascript' src='"+ad_url+"'><" + "/script>");
}

function splitURL(s) {
	s.match( /^([^\/]+\/\/)?([^\/]+)([^\?#]+)(.*$)/ );
	return RegExp.$1 + RegExp.$2 ;
}

function goPop(thePage){ window.open(thePage,'screen','width=378,height=600,scrollbars=yes,resizable=yes'); }
function goPopup(thePage,w,h){
	if(thePage=="http://www.toptenreviews.com/email-a-friend.php"){
		currentPage=escape(document.URL);
		//currentPageA=splitURL(currentPage);
		//thePage=thePage+'?rud='+currentPageA;
		thePage=thePage+'?rud='+currentPage;
	}
	if(thePage=="http://www.toptenreviews.com/email-a-friend2.php"){
		currentPage=escape(document.URL);
		//currentPageA=splitURL(currentPage);
		//thePage=thePage+'?rud='+currentPageA;
		thePage=thePage+'?rud='+currentPage;
	}
	window.open(thePage,'screen','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
}

float_NS6=false;
float_IE4=(document.all);
if (!float_IE4) {float_NS6=(document.getElementById);}
float_NS4=(document.layers);

function float_adjust() {
	if ((float_NS4) || (float_NS6)) {
		if (float_last_Y==-1) {
			float_last_Y=window.pageYOffset + float_Y;
		} else {
			var float_dy=Math.abs(window.pageYOffset+float_Y-float_last_Y);
			var float_c=Math.round(float_dy/10);
			if (window.pageYOffset+float_Y>float_last_Y) {float_last_Y=float_last_Y+1+float_c;}
			if (window.pageYOffset+float_Y<float_last_Y) {float_last_Y=float_last_Y-1-float_c;}
		}
		if (float_NS4){
			if(float_Y<(float_last_Y-float_Y+10)) {
				document.layers['float_layer'].pageY = float_last_Y-float_Y+10;
			} else {
				document.layers['float_layer'].pageY = float_Y;
			}
		}
		if (float_NS6){
			if(float_Y<(float_last_Y-float_Y+10)) {
				document.getElementById('float_layer').style.top = float_last_Y-float_Y+10;
			} else {
				document.getElementById('float_layer').style.top = float_Y;
			}
		}
	} else if (float_IE4) {
		if (float_last_Y==-1) {
			float_last_Y=document.body.scrollTop + float_Y;
		} else {
			var float_dy=Math.abs(document.body.scrollTop+float_Y-float_last_Y);
			var float_c=Math.round(float_dy/10);
			if (document.body.scrollTop+float_Y>float_last_Y) {float_last_Y=float_last_Y+1+float_c;}
			if (document.body.scrollTop+float_Y<float_last_Y) {float_last_Y=float_last_Y-1-float_c;}
		}
		if(float_Y<(float_last_Y-float_Y+10)) {
			document.all['float_layer'].style.posTop = float_last_Y-float_Y+10;
		} else {
			document.all['float_layer'].style.posTop = float_Y;
		}
	}
	setTimeout('float_adjust()',25);
}

function ad_adjust2(l_name,d,max_y,t) {
		if (float_NS4){	cur_y = document.layers[l_name].pageY;	}
		if (float_NS6){	cur_y = document.getElementById(l_name).style.top;	}
		if (float_IE4){	cur_y = document.all[l_name].style.posTop;	}

		if(d<0){
			if(cur_y>max_y) {
				cur_y+=(d*3);
				if (float_NS4){	document.layers[l_name].pageY = cur_y;	}
				if (float_NS6){	document.getElementById(l_name).style.top = cur_y;	}
				if (float_IE4){	document.all[l_name].style.posTop = cur_y;	}
				setTimeout('ad_adjust2("'+l_name+'",'+d+','+max_y+','+t+')',t);
			} else {
				timerhndl=0;
				if (float_NS4){	eval('document.'+l_name+'.visibility="hide";');	}
				if (float_NS6){eval('document.getElementById('+l_name+').style.visibility="hidden";');	}
				if (float_IE4){eval('document.all.'+l_name+'.style.visibility="hidden";');	}
			}

		} else {
			if(cur_y<max_y) {
				cur_y+=d;
				if (float_NS4){	document.layers[l_name].pageY = cur_y;	}
				if (float_NS6){	document.getElementById(l_name).style.top = cur_y;	}
				if (float_IE4){	document.all[l_name].style.posTop = cur_y;	}
				timerhndl=setTimeout('ad_adjust2("'+l_name+'",'+d+','+max_y+','+t+')',t);
			} else {
				timerhndl=0;
			}
		}
}

function float_define() {
	float_Y=ifloat_Y;
}

function layer_define(layer_name,html_var,x_var,y_var) {
	NS6=false;
	IE4=(document.all);
	if (!IE4) {NS6=(document.getElementById);}
	NS4=(document.layers);

	if (NS4) {document.write('<LAYER NAME="'+layer_name+'" LEFT="'+x_var+'" TOP="'+y_var+'">');}
	if ((IE4) || (NS6)) {document.write('<div id="'+layer_name+'" style="position:absolute; left:'+x_var+'; top:'+y_var+';">');}

	document.write(html_var);

	if (NS4) { document.write('</LAYER>'); }
	if ((IE4) || (NS6))  { document.write('</DIV>'); }
}

if(typeof(ntz)=="undefined"){
	var data,ntz;
	var currentUrl=top.document.location;
	if(top.document.location==document.referrer || (document.referrer == '' && top.document.location != '')){v_ref=top.document.referrer;v_srch=top.document.location;}else{v_ref=document.referrer;v_srch=document.location;}
	if(currentUrl=="http://credit-card-processing-review.toptenreviews.com/cardservice-international-review.html")
	{
	ccProcessingdetermine_kws(v_ref);
	}
	else if(currentUrl=="http://credit-card-processing-review.toptenreviews.com/cardservice-international-details.html")
	{
	ccProcessingdetermine_kws(v_ref);	
	}
	else if(currentUrl=="http://credit-card-processing-review.toptenreviews.com/")
	{
	ccProcessingdetermine_kws(v_ref);	
	}
	else if(currentUrl=="http://merchant-account-services-review.toptenreviews.com/")
	{
		ccProcessingdetermine_kws(v_ref);
	}
	ntz=new Date();
	data='ver=1&s='+escape(v_srch)+'&r='+escape(v_ref)+'&sl='+escape(navigator.systemLanguage)+'&av='+escape(navigator.appVersion.substring(0,3))+'&pf='+escape(navigator.platform);
	if(navigator.appVersion.substring(0,1)>'3'){data=data+'&cd='+screen.colorDepth+'&rs='+escape(screen.width+ 'x'+screen.height)+'&tz='+ntz.getTimezoneOffset();}
	var cookieEnabled=(navigator.cookieEnabled)? true : false;
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){document.cookie="testcookie";cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false;}
	data=data+'&ck='+(cookieEnabled?"Yes":"No");
	var stprto="http";if(location.protocol == "https:"){stprto="https";}
	document.write ("<" + "script language='javascript' src='"+stprto+"://www.halstats.com/page.php?"+data+"'></sc"+"ript>");
}

function ccProcessingdetermine_kws(link)
{
var stprto="http";if(location.protocol == "https:"){stprto="https";}
 link=escape(link);
 //var queryString=window.location.search.substring(1);
 var currentUrl=top.document.location;
 currentUrl=escape(currentUrl);
 var ppc="N";
 //if(link)
 if(link!='')
 {
 document.write ("<" + "script language='javascript' src='"+stprto+"://www.toptenreviews.com/scripts/determine_kws.php?ref="+link+"&url="+currentUrl+"'></sc"+"ript>");	
 }
}


if(top.document.location==document.referrer || (document.referrer == '' && top.document.location != '')) v_ref=top.document.referrer;
else v_ref = document.referrer;
determine_kws(v_ref);

function determine_kws(link){
	var stprto = 'http';
	if(location.protocol == 'https:') tprto = 'https';
	link = escape(link);
	var currentUrl = top.document.location;
	currentUrl = escape(currentUrl);
	if(link!='') document.write("<" + "script language='javascript' src='"+stprto+"://www.toptenreviews.com/scripts/db_kw_tracker.php?ref="+link+"&url="+currentUrl+"'></sc"+"ript>");
}


function track__Links(){
	for (var i=0; i<document.links.length; i++){
		r_href=document.links[i].href;
		if((r_href.indexOf('toptenreviews.com')==-1 && r_href.indexOf('hermanstreet.com')==-1 && r_href.indexOf('mailto:')==-1 && r_href.indexOf('javascript:')==-1) || r_href.indexOf('sc/ref.cgi')>0){
			document.links[i].href='http://www.halstats.com/button_press.php?url=' + escape(document.links[i].href);
		}
	}
}

function addLoadEvent(function_name) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = function_name;
	}else{
		window.onload = function() {
			if (oldonload) { oldonload(); }
			function_name();
		}
	}
}

//addLoadEvent(track__Links);
//addLoadEvent(function() {
  /* more code to run on page load */
//});
