function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function openwin(url,wh) { 
	try { pw.close(); }	catch (exception) {};
	pw= open(url, "pw1", wh+",status=no,toolbar=no,menubar=no,scrollbars=no");
}

function add(id) {
	location.href=location.href.replace(/&put.*/, '')+"&put["+id+"]="+parseInt(document.getElementById('gnum'+id).value)
}

function pop(id) {
	location.href=location.href.replace(/&(put|pop).*/, '')+"&pop["+id+"]=0"
}

function clear2() {
	document.getElementById('author').value=''
	document.getElementById('phone').value=''
	//return false
}

function calc(gid) {

	var sum=0

  if (document.getElementById) { 
    table = document.getElementById('glist')
        trs = table.getElementsByTagName('tr')

	kol=0
	for (i=1;i<trs.length-1;i++) {
		tds = trs[i].getElementsByTagName('td')
			
		inp = tds[2].getElementsByTagName('input')
		s=parseInt(inp[0].value)
		inp[0].value=s

		if(typeof(s)=='number' && !isNaN(s) && s>0){
			st=Math.round(parseFloat(tds[1].innerText)*s*100)/100
			tds[3].innerText=st
//				sum=sum+parseFloat(tds[3].innerText)
			sum=sum+st
//alert(tds[3].innerText +' - '+sum)
			kol=kol+s
		}else{
			inp[0].value=''
			tds[3].innerText=' '
		}

	}
	document.getElementById('total').innerText=Math.round(sum*100)/100



	var bi=document.getElementById('binfo')

	var a = bi.getElementsByTagName('span')
	a[0].innerText=a[0].innerText.replace(/^[0-9]+(\.[0-9]*)?/, sum)

	a = bi.getElementsByTagName('a')
	a[0].innerText=a[0].innerText.replace(/^[0-9]+(\.[0-9]*)?/, kol)
  }



	var val=''
	var found=false
	inps = document.getElementsByTagName('input')
	for (i=0;i<inps.length;i++) {
		if (inps[i].name=="num["+gid+"]" ){
			val=inps[i].value
			found=true	
		}
	}



	if(found){
//alert ("?m=basket&set["+gid+"]="+val)
		send_get("?m=basket&set["+gid+"]="+val)

	}
}

function sub2(){
	mess=''
	if (document.getElementById('author').value=='') mess+="\nНе заполнено поле Фамилия, имя, отчество";
	if (document.getElementById('phone').value=='') mess+="\nНе заполнено поле Ваш адрес, телефон";

//alert("+"+document.getElementById('phone')+"+")

	if (mess=='')
		document.getElementById('basketf').submit()
	else
		alert(mess);

}


function send_get(url){

if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	http_request = new XMLHttpRequest();
	http_request.overrideMimeType('text/xml');
} else if (window.ActiveXObject) { // IE
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
}

//	http_request.onreadystatechange = function() { receive_get(http_request, url); };

//	http_request.open('POST', url, true);
//	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//	http_request.send(paramString); 


	http_request.open('GET', url, true);
	http_request.send(null);
}



/*
function receive_get(http_request, url){

	if (http_request.readyState == 4)
	if (http_request.status == 200) {
		z=http_request.responseText
alert('z[3]='+z)
	}
}
*/




function print2() { 
	if(document.getElementById('author').value==''){
		alert('Не заполнено поле Фамилия, имя, отчество')
		return
	}
	if(document.getElementById('phone').value==''){
		alert('Не заполнено поле Ваш адрес, телефон')
		return
	}

	print()
}


function printVersion() {
	if(document.getElementById('author').value==''){
		alert('Не заполнено поле Фамилия, имя, отчество')
		return
	}
	if(document.getElementById('phone').value==''){
		alert('Не заполнено поле Ваш адрес, телефон')
		return
	}

	location.href=location.href.replace(/\?.*/,'')+"?m=basketprint&p1="+document.getElementById('author').value+"&p2="+document.getElementById('phone').value 
}

