/* -- ajax functions ----------------------------------------*/
var http = createRequestObject();

//checks the browser and creates an appropriate request object
function createRequestObject() 
{
var requestObject;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
	{
    requestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
else
	{
    requestObject = new XMLHttpRequest();
    }
return requestObject;
}

/*-- standard mbd functions -----------------------------------*/
function getStyleObject(objectId) 
{
// checkW3C DOM, then MSIE 4, then NN 4.
//
	if(document.getElementById && document.getElementById(objectId))
		return document.getElementById(objectId).style;
	else if (document.all && document.all(objectId))
		return document.all(objectId).style;
	else if (document.layers && document.layers[objectId])
		return document.layers[objectId];
	else
		return false;
}

function show(obj) 
{
	style = getStyleObject(obj);
	style.display = 'block';
	style.visibility= 'visible';

}
function clearIt(obj) 
{
	style = getStyleObject(obj);
	style.display = 'none';
	style.visibility= 'hidden';
}
//Timed image swap function
function nextImage(subFolder)
{
if(!subFolder)
	{
	subFolder = "standard";
	}
if (document.images)
  {
  if(imageIndex == (theImages.length - 1))
	{
	imageIndex = 0;
	}
  else
	{
	imageIndex++;
	}
  var target;
  target=document.getElementById('product_big_image');
  if (target)
	{
    target.src= "uploads/products/"+subFolder+"/" + theImages[imageIndex];
    }
  }
}

//manual image swap
function swapPicture(theImage)
{
if (document.images)
  {
  var target;
  target=document.getElementById('product_big_image');
  if (target && theImages[theImage])
	{
    target.src= "uploads/products/standard/" + theImages[theImage];
	imageIndex = theImage;
    }
  }
}

//Popup function
function thePop(URL) 
{
window.open(URL,"porsellidancewear","status = 1, height = 600, width = 600, resizable = 0,scrollbars=1");
}

//for changing text in the teg with the right id to the value specified
function colourname(id,colourname,id2,theDiff) 
{
document.getElementById(id).innerHTML = colourname;
style = getStyleObject(id2);

var theLength = style.width.length - 2;
var myWidth = style.width.substr(0,theLength);
var newWidth = (myWidth*1) + (theDiff*1);

style.width = newWidth+'px';
//alert("The mywidth is: "+myWidth +" and the length is: " + newWidth);
}

function doFilter(theId,theElement,cancel)
{
if(cancel != '0')
	{
	document.forms['filterproducts'].elements[cancel].value = '';
	}
document.forms['filterproducts'].elements[theElement].value = theId;
document.forms['filterproducts'].submit();
}


function clearKey()
{
var theVal = document.forms['topsearch'].elements['keysearch'].value;
if(theVal == "search here")
	{
	document.forms['topsearch'].elements['keysearch'].value='';
	}
}

function clearBottKey()
{
var theVal = document.forms['subscriber'].elements['email_address'].value;
if(theVal == "Enter Email")
	{
	document.forms['subscriber'].elements['email_address'].value='';
	}
}


