var masterlink = false;
window.amcu_disable = false;
var urlenable = false;


function amcu_title(){
	tt=document.getElementsByTagName("TITLE")[0];
	if(tt!=null)return encodeURIComponent(tt.innerHTML.substring(0,100));
	else return"";
	}


//get cookie
function amcu_gc(name){if(document.cookie.length>0){start=document.cookie.indexOf(name+"=");if(start!=-1){start=start+name.length+1;end=document.cookie.indexOf(";",start);if(end==-1)end=document.cookie.length;return unescape(document.cookie.substring(start,end))}}return""}

//set cookie
function amcu_sc(name,val,endh){var exdate=new Date;endh=exdate.getHours()+endh;exdate.setHours(endh);document.cookie=name+"="+escape(val)+(endh==null?"":";expires="+exdate.toGMTString()+"; path=/;")}


function dch() {
	if (window.amcu_disable) {window.amcu_disable = false; return;}
	amcu_sc("amcuh",amcu_h,12);
	urlenable = true;
	document.body.setAttribute('onclick', '');
	if (masterlink) {
		//alert('link cu');
		if (OP_am) {
			window.open(masterlink, '_blank', "");
			window.open(turl, '_parent', "");
			} else {
				window.open(turl, 'wadvpop', "");
				window.open(masterlink, '_blank', "");
				}
		//window.open(turl, '_parent', "");
		} else {
			//alert('base cu');
			var pw = window.open(turl, '_blank', "");
			pw.blur();
			window.focus();
			}
	masterlink = false;
	}
	


function popinit(lmod) {
//alert(lmod);
document.body.setAttribute('onclick', 'dch();');
if (lmod) {
	var links = document.getElementsByTagName('a');
	for(i in links) {
		if (links[i].onclick == null)
		if (links[i].rel == '')
		if (links[i].href != '') {
			ou = links[i].href.toLowerCase();
			if(ou.indexOf("javascript:")==-1) {
				links[i].setAttribute('onclick','{masterlink = this.href; return urlenable;}'); 
				//links[i].setAttribute('target','_blank');
				}
			}
		}
	}
}



var ua = navigator.userAgent.toLowerCase();
var FF_am=ua.indexOf("firefox/")!=-1;
var OP_am=ua.indexOf("opera/")!=-1;
//alert(ua);

var amcu_cn=0;
var amcu_h=amcu_gc("amcuh");
if(!amcu_h){amcu_h=1;}else{amcu_h++;}
if (amcu_h==1){n=1;}else{n=2;}
var turl = "http://cu.am10.ru/in.php?u=10467&n="+n+"&loc="+escape(top.location.href)+"&title="+amcu_title()+"&ref="+escape(document.referrer.substring(0,1E3));

if(amcu_h==1 || amcu_h==4) popinit(FF_am || OP_am);
	else amcu_sc("amcuh",amcu_h,12);
//popinit(FF_am || OP_am);
//popinit(true);


