
var preloadFlag = false;
function preloadImages()
{
	if (document.images) {
		Leaf1_over = newImage("design/navigation/" + Language + "/Leaf1-over.gif");
		Leaf1_down = newImage("design/navigation/" + Language + "/Leaf1-down.gif");
		Leaf2_over = newImage("design/navigation/" + Language + "/Leaf2-over.gif");
		Leaf2_down = newImage("design/navigation/" + Language + "/Leaf2-down.gif");
		Leaf3_over = newImage("design/navigation/" + Language + "/Leaf3-over.gif");
		Leaf3_down = newImage("design/navigation/" + Language + "/Leaf3-down.gif");
		Loading	   = newImage("design/images/daisy_load.gif");
		preloadFlag = true;		
	}
}

function updateDiv(Get,Post,Div)
{	
	httpPost("ajax.php"+Get,Post,Div,Updating);
}

function txtFocus(Identity)
{
if (Identity=="Search")
{
	if (document.Search.SC.value==Search)
	{
		document.Search.SC.value="";
		document.Search.SC.style.color = "#000000";
	}
}
if (Identity=="Email")
{
	if (document.frmLogon.Email_Login.value==EmailAddress)
	{
		document.frmLogon.Email_Login.value="";
		document.frmLogon.Email_Login.style.color = "#000000";
	}
}
if (Identity=="Password")
{
	if (document.frmLogon.Password_Login.value==Password)
	{
		document.frmLogon.Password_Login.value="";
		document.frmLogon.Password_Login.style.color = "#000000";
	}
}
}
function txtBlur(Identity)
{
if (Identity=="Search")
{
	if (document.Search.SC.value=="")
	{
		document.Search.SC.value=Search;
		document.Search.SC.style.color = "#CCCCCC";
	}
}
if (Identity=="Email")
{
	if (document.frmLogon.Email_Login.value=="")
	{
		document.frmLogon.Email_Login.value=EmailAddress;
		document.frmLogon.Email_Login.style.color = "#CCCCCC";
	}
}
if (Identity=="Password")
{
	if (document.frmLogon.Password_Login.value=="")
	{
		document.frmLogon.Password_Login.value=Password;
		document.frmLogon.Password_Login.style.color = "#CCCCCC";
	}
}
}

function CheckHash()
{

if (window.location.hash=="#Collection")
{
loadAjaxPage("Collection",Loading);
}
if (window.location.hash=="#FullBasket")
{
loadAjaxPage("FullBasket",Loading);
}
if (window.location.hash=="#Shops")
{
loadAjaxPage("Shops",Loading);
}
}

function visible(Element,Visibility) { 

if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(Element).style.visibility = Visibility; 
} 
else { 
if (document.layers) { // Netscape 4 
document.Element.visibility = Visibility; 
} 
else { // IE 4 
document.all.Element.style.visibility = Visibility; 
} 
} 
} 

function loadAjaxPage(Command,LoadingMessage,SubCommand)
{	
	window.location.hash=Command;
  if (typeof SubCommand == "undefined") {
    httpPost("ajax.php?C="+Command,"Command="+Command,"Body",LoadingMessage);
  }
  else
  {
	httpPost("ajax.php?C="+Command+"&SC="+SubCommand,"Command="+Command+"&SubCommand="+SubCommand,"Body",LoadingMessage);
  }
}
function loadAjaxCart(Command,LoadingMessage,SubCommand)
{	
	httpPost("ajax.php?C=SmallBasket&"+Command+"="+SubCommand, Command+"=" + SubCommand,"Basket",LoadingMessage);
}


function httpPost(strURL,queryString,element,loadingmessage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open("POST", strURL, true);
    self.xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			updatepage(self.xmlHttpReq.responseText,element);
			visible('LoadingContainer','hidden');
			//setTimeout("visible('LoadingContainer','hidden');",1500);
        }
		else
		{
			updatepage(loadingmessage,'Loading');
			visible('LoadingContainer','visible');
		}
    }
    self.xmlHttpReq.send(queryString);
}



function updatepage(str,element){
    document.getElementById(element).innerHTML = str;
}



function newImage(arg) {

	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {

	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

