
// wrapper
function adP(gtype,loctype) {
	if (loctype==1) adCreate('/ee.php/pop/ad?group='+gtype+'&r'+jsRandom(1,99999)+'=1');
	if (loctype==2) adCreate('/ru.php/pop/ad?group='+gtype+'&r'+jsRandom(1,99999)+'=1');
}


function adCreate(uri) {
	W = 760; H = 620; X = (screen.width -W) / 2; Y = (screen.height -H) / 2;
	var adwin = window.open(uri, 'adCreateW', 'scrollbars=0,menubar=0,resizable=0,background=white,toolbar=0,status=0,top='+Y+',left='+X+',height='+H+',width='+W);
	rePos(adwin, W, H, X, Y);
}



// wrapper
function adU(loctype,id) {
	if (loctype==1) {
		adUpdate('/ee.php/pop/up?id='+id+'&r'+jsRandom(1,99999)+'=1');
	} else {
		adUpdate('/ru.php/pop/up?id='+id+'&r'+jsRandom(1,99999)+'=1');
	}
}

function adUpdate(uri) {
	W = 400; H = 380; X = (screen.width -W) / 2; Y = (screen.height -H) / 2;
	var upwin = window.open(uri, 'adUpdateW', 'scrollbars=0,menubar=0,resizable=0,background=white,toolbar=0,status=0,top='+Y+',left='+X+',height='+H+',width='+W);
	rePos(upwin, W, H, X, Y);
}


function rePos(winname, wW, wH, wL, wT) {
	winname.resizeTo(wW, wH);
	winname.moveTo(wL, wT);
	winname.focus();
}



// wrapper
function iW(loctype,imgurl,dname) {
	if (loctype==1) {
		imagePop('/ee.php/pop/photo?i='+imgurl+'&n='+dname+'&r'+jsRandom(1,99999)+'=1');
	} else {
		imagePop('/ru.php/pop/photo?i='+imgurl+'&n='+dname+'&r'+jsRandom(1,99999)+'=1');
	}
}

function imagePop(uri) {
	var X =  (screen.width - 500) / 2;
	var Y = (screen.height - 500) / 2;
	wind = window.open(uri, 'bigimg', 'resizable=1,height=500,width=500,top='+Y+',left='+X);
	wind.moveTo(X, Y);
} 

function openW(uri,nam,w,h,params) {
	window.open(uri, nam, 'scrollbars=0,menubar=0,resizable=1,toolbar=0,status=0,width='+w+',height='+h);
} 

function xmeil(tld,domain,name) {
	document.write('<a href="mailto:'+name+'@'+domain+'.'+tld+'">'+name+'@'+domain+'.'+tld+'</a>');
}
 
function tryCode(code) {
	R = makeRequest('/getcode.php?c='+ code);
	if (R=='err') return setTimeout('tryCode("'+code+'")', 3000);
	
	document.getElementById('smsval').value =R;
	document.getElementById('status').innerHTML = '<b>SMS OK!</b>';
	document.getElementById('submitter').disabled = false;
	document.getElementById('submitter').className = 'button';
	
}

function ed(id) {
	W = 640; H = 620; X = (screen.width -W) / 2; Y = (screen.height -H) / 2;
	var editW = window.open('/edit/?id='+id +'&r'+jsRandom(1,99999) +'=1', 'edit', 'scrollbars=1,menubar=0,resizable=1,background=white,toolbar=0,status=0,top='+Y+',left='+X+',height='+H+',width='+W);
	rePos(editW, W, H, X, Y);
}

function jsRandom(min,max) {
   return (Math.round(Math.random()*(max-min)))+min;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,'');
} 

