/**
 * Generic Functions
 */

function Display(layer)
{
	document.getElementById(layer).style.display = "block";
}

function NoDisplay(layer)
{
	document.getElementById(layer).style.display = "none";
}

function Hide(layer)
{
	document.getElementById(layer).style.visibility = "hidden";
}

function Show(layer)
{
	document.getElementById(layer).style.visibility = "visible";
}

function UpdateBasket(productid, minqty)
{
	var intcheck = /^[0-9]+$/;
	var http = false;
	var items = "NONE";
	var itemsname = "product"+productid;

	if (!intcheck.test(productid))
		return false;

	if (document.getElementById(itemsname))
	{
		items = document.getElementById(itemsname).value;
		if (items == "")
		{
			items = 0;
		}
	}

	if (!intcheck.test(items))
		return false;

	if ((items > 0) && (items < minqty))
	{
		document.getElementById(itemsname).value = minqty;
	}

	if (items == 0)
	{
		document.getElementById(itemsname).value = "";
	}

	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}

	http.open("GET", "/ajax_basket.php?productid=" + productid + "&items=" + items);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
			document.getElementById('basket').innerHTML = http.responseText;
			if (document.getElementById('floatingbasket'))
			{
				document.getElementById('floatingbasket').innerHTML = "<p>"+http.responseText+"</p>";
			}
		}
	}
	http.send(null);
}

/**
 * Custom Function
 */

function ProductDescriptionShow(layer)
{

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

//	document.getElementById(layer).style.top = Math.round(myHeight / 2) + "px";
	document.getElementById(layer).style.left = Math.round(myWidth / 2 - 460) + "px";

	Display(layer);
	Show(layer);
}

function ProductDescriptionHide(layer)
{
	Hide(layer);
}