var printwidth=620;

function fl(src)
{
 document.write(src);
}


function submenu(id)
{
 if(document.getElementById('lid'+id).className=='')
 {
  for(var h=0;h<lid;h++) document.getElementById('lid'+h).className='';
  document.getElementById('lid'+id).className='act';
 }
 else document.getElementById('lid'+id).className='';
}


function winopen(src,x,y)
{
 window.open("/winopen.php?src="+src+"&w="+x+"&h="+y,"Image","width="+x+",height="+y+",status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no");
}

function winopen_swf(filename)
{
 window.open("/winopen_swf.php?filename="+filename,"Image","width=670,height=290,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
}


function selectModel()
{
 document.selectmodel.action="/"+city+"/autos/"+document.selectmodel.model.value+"/";
}


function forprint(src)
{
 window.open(src,"Print","width="+printwidth+",height=650,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
}


function rolfOver(src)
{
 document.getElementById('rolf-'+src).src='/i/rolf-'+src+'-act.gif';
}


function rolfOut(src)
{
 document.getElementById('rolf-'+src).src='/i/rolf-'+src+'.gif';
}


function showmodelselect()
{
 document.getElementById('ListModels').style.display='block';
 document.body.onclick=new Function('hidemodelselect();');
}


function hidemodelselect()
{
 document.getElementById('ListModels').style.display='none';
 document.body.onclick=new Function('');
}


 
 
function korzina(id,sId,el,time){
 	uploader_go('act=add&id='+id+'&salonid='+sId);
	alert('Товар добавлен в корзину');
}

function change_sum(){
	a=document.getElementById('zakaztable');
	spans=a.getElementsByTagName('SPAN');
	var newsum=0;
	for(var i=0;i<spans.length;i++){
		newzn=spans[i].innerHTML;
		newsum=parseFloat(newsum)+parseFloat(newzn);	
		newsum=Math.round(newsum,2);
	}
	document.getElementById('summa').innerHTML=newsum;

}

function checkform(){
	var fn=document.getElementById('fn');
	var fv=document.getElementById('vin');
	var fm=document.getElementById('marka');
	var ft=document.getElementById('ft');
	var chy="";
	if((ft.value)&&(ft.value!="")){
		chy="ok";
	}
	else{
		if((ft.innerHTML)&&(ft.innerHTML!="")){
			chy="ok";
		}

	}
	if((chy=="ok")&&(fn.value!="")&&(fv.value!="")&&(fm.value!="")){
		document.zap.submit();
	}
	else{	
        	alert("Необходимо заполнить все поля");
	}
}

function uploader_init () {
        uploader = new clUploadData('/upl.php');
}

function uploader_go (id) {
        uploader.upload(id);
}

function clUploadData ( thesrc ) {
	// устанавливаем адрес подгрузки
	this.src = thesrc;
	// подгружаться будет методом GET
	this.src += "?";
	//тип подгружаемого элемента - text/javascript
	this.type = "text/javascript";
	this.oldScript  = document.createElement("SCRIPT");
	this.oldScript.type = this.type;
	this.callId = 0;
	document.body.appendChild(this.oldScript);
	this.upload = function ( theparams ) {
		//Параметры передаются в виде par1=val1&par2=val2&...
		var tParams = theparams || "";
		var newScript = document.createElement("SCRIPT");
		newScript.type = this.type;
		this.callId += 1;
		var randnumber=Math.floor(Math.random()*100000);
		newScript.src  = this.src + "callid=" + String(this.callId) + "&randnumber=" + randnumber + "&" + tParams;
		// alert(newScript.src);
		document.body.replaceChild(newScript,this.oldScript);
		this.oldScript = newScript;
	}
}

