// JavaScript Document
	var glbDiv = '';
	var glbAfterReturnFunction;
	function sendRequestDiv(div, posta, mode, file, fn)
	{
		/* DEBUG  
		alert("Div: " + div + "\r\n" + "posta: " + posta + "\r\n" + "mode: " + mode + "\r\n"  + "file: " + file + "\r\n"  + "fn: " + fn + "\r\n");
		/*   */
		glbDiv = div;
		glbAfterReturnFunction = fn;
		//$(div).innerHTML='<img src="icon/loading.gif" width="48px" style="padding:20px;"/>';
		//alert(posta);		
		new Ajax.Request("/includes/ajax/"+file+"?mode="+mode, 
		{ 			
			method: 'post',
			postBody: "tempp=1&"+posta,
			onComplete: showResponseDiv
		});			
		return false;
	}
	function showResponseDiv(req)
	{
		document.getElementById(glbDiv).innerHTML= req.responseText;
		glbAfterReturnFunction();
	}
function adjustShippingCost()
{
	//alert("PC: " + document.getElementById('postcode').value + "\r\n" + "PI: " + document.getElementById('products_id').value + "\r\n" + "Qt: " + document.getElementById('qty').value + "\r\n");
	if(document.getElementById('postcode').value.length == 4) { 
		sendRequestDiv('st_postage', 'postcode='+document.getElementById('postcode').value+'&productid='+document.getElementById('products_id').value+'&qty='+document.getElementById('qty').value, 'postagecost', 'product-ajax.php');
	}
}
function adjustCartCost()
{
	//alert("PC: " + document.getElementById('postcode').value + "\r\n" + "PI: " + document.getElementById('products_id').value + "\r\n" + "Qt: " + document.getElementById('qty').value + "\r\n");
	if(document.getElementById('postcode').value.length == 4) { 
		sendRequestDiv('st_postage', 'postcode='+document.getElementById('postcode').value, 'cartpostagecost', 'product-ajax.php', adjustSubTotal);
	}
}
function adjustSubTotal() {
	var subtotal = document.getElementById('subtotal_value').value;
	var shipping = document.getElementById('shipping_value').value;
	sendRequestDiv('st_subtotal', 'subtotal='+subtotal+'&shipping='+shipping, 'displaysubtotal', 'product-ajax.php');
}


function popUp(URL) {
day = new Date();
id = day.getTime();
//,left = 240,top = 312
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=400');");
}

function openWin( windowURL, windowName, windowFeatures ) {

    return window.open( windowURL, windowName, windowFeatures ) ;
}
function PlayFile(vname)
{
	var filename;
	filename = vname + ".swf";
	newwindow = openWin( '/playfile.php?filename=' + filename, 'Title','width=1080,height=760,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0' ); 
	newwindow.focus();

}
