var et, tr, root;
var cba="#FFDAD9";

function ShowFoto(img){	if (!root) root='';	ad(root+'/img.php?img='+img+'&root='+root)}
function ad(url) {
	if (document.getElementById('ax111')) document.body.removeChild(document.getElementById('ax111'));
	var jsel=document.createElement('SCRIPT');
	jsel.type='text/javascript';
	jsel.id='ax111';
	jsel.src=url;
	document.body.appendChild(jsel);
	return true;
}
function changevip(s,eur){ad('model_popup.php?change='+s+'&eur='+eur)}
function addfav(s,ln){if (!root) root=''; ad(root+'/common/modules/favourites.php?ln='+ln+'&s='+s)}
function check_fill(obj,mail,descr) {
	var msg='';
	if (!descr) descr='';
	et=0;
	for (i=0;i<obj.length;i++) {
		o=obj[i];
		if (o.value.length==0) {
			 et=1;
			 o.style.backgroundColor=cba;
			 if (descr[i]) msg = msg+'- '+descr[i]+"\n";
		}
		else 
			 o.style.backgroundColor="";
	}
	if (mail!='' && mail!=undefined && mail.value.length>0) {
		CheckEmail(mail.value)
		if (!tr) {
			mail.style.backgroundColor=cba; 
			alert('- Mail');
			return false;
		}
	}
	if (msg) alert(msg);
	if (et) return false;
}
function CheckEmail(field){
	var str=field
	var filter=/^.+@.+\..{2,4}$/
	if (filter.test(str)) tr=true;
	else tr=false;
}
function chv(obj,nova,old) {if (obj.value==old) obj.value=nova;}

function popupwin(fileurl,w,h,add) { // Make popup win
	if (w<=1) var iWidth=screen.width*w;
	else var iWidth=w;
	if (h<=1) var iHeight=screen.height*h;
	else var iHeight=h;
	var iLeft=(screen.width-iWidth)/2 ;
	var iTop=(screen.height-iHeight)/6;
	var sOptions="toolbar=0,status=0,resizable=1,scrollbars=1"+add+",width="+iWidth+",height="+iHeight+",left="+iLeft+",top="+iTop;
	var mytxt=fileurl;
	var oWindow=window.open(mytxt, "ModelLive", sOptions) ;
	oWindow.focus();
}
function chars(obj) {
	var add='';
	if (obj.length>254) {
		add='<span class="red b">!!! </span>';
	}
	document.getElementById('chars').innerHTML=add+obj.length;
}
function cf(val) {
	document.getElementById('mf').src=val;
}