function DisplayFlash(path, width, height, wmode){

    text = "<object type=\"application/x-shockwave-flash\" data=\""+path+"\" width=\""+width+"\" height=\""+height+"\" wmode=\""+wmode+"\" quality=\"high\" allowScriptAccess=\"always\">\r\n";
    text += "<param name=\"movie\"	value=\""+path+"\" />\r\n";
    text += "<param name=\"wmode\" value=\""+wmode+"\" />\r\n";
    text += "<param name=\"quality\" value=\"high\" />\r\n";
    text += "<param name=\"allowScriptAccess\" value=\"always\" />\r\n";    
    text += "<param name=\"width\" value=\""+width+"\" />\r\n";
    text += "<param name=\"height\" value=\""+height+"\" />\r\n";
    text += "</object>";
    document.write(text);
}


function openWind(url,width,height) {
        number = Math.round(Math.random() * 100000000);
        auxWnd = window.open(url, 'newWindow_' + number,'width=' + width + ',height=' + height + ',resizable=no,scrollbars=1,scrollprint=yes,toolbar=no,menubar=no,location=no,status=no,directories=no,copyhistory=no,left=0,top=0');
}

function AddToOrder(item, reload) {
	var req = new JsHttpRequest();
	
	if(!item)
		return;

	var divid = "ord"+item;
	var countid = "count"+item;
	
	count = document.getElementById(countid).value;
	

	req.onreadystatechange = function() {
	if (req.readyState == 4) {
			
			var cartelem = document.getElementById("cart");
			if(cartelem)
				document.getElementById("cart").innerHTML = req.responseJS.basket;
			
			if(count>0){
				alert("Товар помещен в корзину");
				if(reload)
					opener.location.reload(); 
				
			}
			
			
	}
	}

	req.open(null, "/jslib/order.php", true);
	req.send( {item: item, count: count} );
}

function GetOrder(action) {

	var req = new JsHttpRequest();
      var items = "";
        

	

	var delitems = "";
        var inputs = document.item.getElementsByTagName('input');
        for (var i = 0; i < inputs.length; i++){
        	if(parseInt(inputs[i].value)){
                	items = items+inputs[i].name+"-"+inputs[i].value+" ";
                }
                else if(inputs[i].checked)
                        delitems = delitems+" "+inputs[i].name.replace("delete_", "");

        }



	req.onreadystatechange = function() {
	if (req.readyState == 4) {
           	//document.getElementById("orderbody").innerHTML = "";
		//document.getElementById("orderbody").innerHTML = req.responseJS.order;
		var elem = document.getElementById("orderbody");
		var orderbody = req.responseJS.order;
		if(orderbody&&elem)	
			elem.innerHTML = orderbody;

            document.getElementById("cart").innerHTML = req.responseJS.basket;
	}
        }

	req.open(null, "/jslib/getorder.php", true);
	req.send( {items: items, delitems: delitems, action: action} );
}

function Enter(evt) {
	var charCode = (evt.which) ? evt.which : evt.keyCode;

         if(charCode==13&&!evt.ctrlKey)
		document.loginform.submit();
	return false;
}

function SwapImage(target, fname) {
	document[target].src = fname;
}


