var opswin;
var top_=10;
var left_=10;
var werds;
function adm_opwin(a,w,h){
	if (navigator.userAgent.toLowerCase().indexOf("opera")==-1 && opswin!=null && !opswin.closed)opswin.close();
	//tops(w,h);
	opswin=window.open(a,'',"height="+h+",width="+w+",status=yes,toolbar=no,menubar=no,location=yes,top="+top_+",left="+left_+",scrollbars=auto,resizable=yes");
	opswin.focus();
}
function tops(w,h){
	if(navigator.appName == "Netscape") {
		top_=window.innerHeight/2-h/2;
		left_=window.innerWidth/2-w/2;
	}
	else{
		top_=document.body.clientHeight/2-h/2;
		left_=document.body.clientWidth/2-w/2;
	}
	if(top_<0)top=0;
	if(left_<0)top=0;
}
var ind=0;
function iframe_href(a){
	window.frames['iframe_index'+ind].location.href='iframe_index.php?'+a;
	if(++ind>4)ind=0;
}
function iframe_href_select(a,i){
	window.frames['iframe_index'+i].location.href='/adm/iframe_index.php?'+a;
}
function popwin(nam,w,h){
	var linkk='/popwin.html?link='+nam;
	//tops(w,h);
	param = 'top='+top_+',left='+left_+',width='+w+',height='+h;
	if(navigator.userAgent.toLowerCase().indexOf("opera")==-1 && opswin!=null && !opswin.closed)opswin.close();
	opswin=window.open(linkk,'',param+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
	opswin.focus();
	return false;
}
var edit_layer_id_old='-';
function edit_layer_show(a){
	edit_layer_cleartimeout();
	if(edit_layer_id_old!='-' && document.getElementById('t'+edit_layer_id_old)){
		document.getElementById('t'+edit_layer_id_old).style.display='none';
		edit_layer_id_old='-';
	}
	if(document.getElementById('t'+a)){
		document.getElementById('t'+a).style.display='block';
		edit_layer_id_old=a;
	}
}
function edit_layer_hide(a){
	if(document.getElementById('t'+a))document.getElementById('t'+a).style.display='none';
}
var edit_layer_timeout;
function edit_layer_hide_timeout(a){
	edit_layer_timeout=setTimeout("edit_layer_hide('"+a+"')",500);
}
function edit_layer_cleartimeout(){
	clearTimeout(edit_layer_timeout);
}

/*function ident_form(a){
	var f=document.forms[0];
	f.select_name.value=a;
}
function submit_form(a){
	var f=document.forms[0];
	f.select_all.value=a;
	f.submit();
	f.select_all.value='';
}
function conf_func(a){
	return confirm('Подтвердите удаление:\n'+a);
}*/
//ipwrs-
//function openimagejp(linkk,name,w_,h_){
//linkk='/public/popwin1.php?link='+linkk+'&dir='+name;//popwin1_jp
function openimagejp(pid,dir,w_,h_){
linkk='/popwin1.php?pid='+pid+'&dir='+dir;
var up_=100;
var left_=100;
param = 'top='+up_+',left='+left_+',width='+w_+',height='+h_;
if (werd1==null||werd1.closed){
werd1=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
}
else{
werd1.close();
werd1=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
}
werd1.focus();
}
//-ipwrs
//added by ipwrs-
function opensalejp(linkk,name,w_,h_,t_){
	//if(document.user.num && document.user.num.value<99999)t_=document.user.num.value;
	linkk='/popwinsale_jp.php?id_product='+linkk+'&dir='+name+'&id_girls='+t_;
	var up_=100;
	var left_=100;
	param = 'top='+up_+',left='+left_+',width='+w_+',height='+h_;
	if (werds==null || werds.closed){
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	else{
		werds.close();
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	werds.focus();
}

function pdesc(name,h,w,pid){
  var url="pdesc.php?pid="+pid;
  var specs="directories=0,left=100,top=100,height="+h+",width="+w+",location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0";
	  window.open(url,name,specs,"replace=false");
}
//-added by ipwrs

function openopensale(linkk,name,w_,h_,t_){
	//if(document.user.num && document.user.num.value<99999)t_=document.user.num.value;
	linkk='/popwinsale.php?id_product='+linkk+'&dir='+name+'&id_girls='+t_;
	var up_=100;
	var left_=100;
	param = 'top='+up_+',left='+left_+',width='+w_+',height='+h_;
	if (werds==null || werds.closed){
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	else{
		werds.close();
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	werds.focus();
	
}

function openopensale_new(linkk,name,w_,h_,t_){
	if(document.user.num.value<99999)t_=document.user.num.value;
	linkk='/_popwinsale.php?id_product='+linkk+'&dir='+name+'&id_girls='+t_;
	var up_=100;
	var left_=100;
	param = 'top='+up_+',left='+left_+',width='+w_+',height='+h_;
	if (werds==null || werds.closed){
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	else{
		werds.close();
		werds=window.open(linkk,name, param+',status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
	}
	werds.focus();
	
}
function setElementValue() {
 if(document.getElementById(dphoto).checked==true) {
   document.getElementById(dphoto).value=1;
 }
 else {
   document.getElementById(dphoto).value=0;
 }
}//setElementValue()


function set_ddate(obj,spanid1) {
	//alert('func set_ddate');
   var url="/set_ddate.php?dtype_id="+obj.value;
   runFile2(url,spanid1);
}//set_ddate(obj)


//run file asynchronously
function runFile2(url,spanid2)
{
  	//for testing
	//alert('inside runFile2');
	var xmlHttp;
	try {   
		// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    
	}
	catch (e){
		// Internet Explorer
		try{     
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");     
		}
		catch (e){
			try{ 
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
		    catch (e){
				alert("Your browser does not support AJAX!");        
				return false;        
			} //catch3    
		}
	}//catch1
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
	          if (xmlHttp.status == 200){
				// customized-
				  document.getElementById(spanid2).innerHTML=xmlHttp.responseText;
				// -customized 
		  }
	    }
	}	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);  

}//runFile2()