function xigajax(xPhpFile,xElementId,doIt){
		if (doIt) {
		if (xElementId=="detailzone" || xElementId=="mainzone")
		{
		  window.scroll(0,0);
		}
		  //alert(xPhpFile);
		 var onDate = new Date(); // to kill cache
			 if (xElementId){
				if (xElementId=="detailzone")
					xElementId="mainzone";	// to kill any calls to the old detailzone		
				
				if (xElementId=="mainzone") {
					// show the loading image. We want that ONLY in the mainzone.
					document.getElementById(xElementId).innerHTML='<div style="text-align:center; padding-top:30px"><img src="/usa/templates/default/images/loading.gif" border="0"></div>';
				} else {
					document.getElementById(xElementId).style.display = "";
				}
			 }
			 sendtotext(xPhpFile+'&rand='+onDate, xElementId);
		} else {
		
			document.getElementById("theframe").src="/usa/helper3.htm?"+xPhpFile+"~"+xElementId;
		}
	
	return false;
	}
		function resetiframe(){
	//alert('reload');
	document.getElementById("currencylist").style.display = 'none';
	theframe.location.reload(); 
	}

	
	function showdetail() {
		var o=document.getElementById("detailzone");
		
		if (o.style.display=="none") {
			// clear detailzone before showing it if it wasn't visible already
			// that should help avoid seeing previous, old details
			document.getElementById("detailcontent").innerHTML="";			
		}
		document.getElementById("mainzone").style.display="none";
		o.style.display="block";
	}
	
	function showmain() {
		document.getElementById("detailzone").style.display="none";
		document.getElementById("mainzone").style.display="block";
	}

function URLEncode(t)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = t;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};
	function lookupship(){
	var shipcountry = document.getElementById("shippingcountry").value;
	xigajax("/usa/con_workerbee.php?lookupshipping=1&entry_country="+shipcountry,"lookupshipdata");
	return false;
	}
	function flashsuccess(prodID,x){
		document.getElementById("productsucmsg"+prodID).style.display = "block";
		document.getElementById("productsucmsg"+prodID).innerHTML = "<strong>Adding to "+x+"...</strong>";
		setTimeout('document.getElementById("productsucmsg'+prodID+'").innerHTML = ""',1000);
		setTimeout('document.getElementById("productsucmsg'+prodID+'").style.display = "none"',1005);
	}
	function switchpull(o){
	//	document.getElementById("prodtype").select.selectedIndex = o;
	document.forms[0].prodtype.selectedIndex = o;
	}
	function resetsearch(){
	var s = document.getElementById("searchbox").value;
	if (s == "Search the site"){
	document.getElementById("searchbox").value = '';
	}
	}
/// NEW
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}
function hidebask(){
	document.getElementById("theshoppingcartcontents").style.display = "none";
}

var closebask;
function togglebasket(f){

if (f == "addtobask"){
	clearTimeout(closebask); // clear any outstanding close ...
	document.getElementById("theshoppingcartcontents").style.display = "block";
	opacity("theshoppingcartcontents", 0, 100, 300); // show in 200 milliseconds

}else if (f == "off"){
	opacity("theshoppingcartcontents", 100, 0, 300); // show in 200 milliseconds
	setTimeout('hidebask()',301); // show div
	
} else {
	// is the basket showing or hidden?
	var curr = document.getElementById("theshoppingcartcontents");
	if (curr.style.display == "none" || curr.style.display == "")
	{
	// hidden // opacity off
	curr.style.display = "block"; // show div
	opacity("theshoppingcartcontents", 0, 100, 300); // show in 200 milliseconds
	}else{
	opacity("theshoppingcartcontents", 100, 0, 300); // show in 200 milliseconds
	setTimeout('hidebask()',301); // show div
	}
}
}
	function showbasketfade(){
		window.scroll(0,0);
		togglebasket("addtobask");
		closebask = setTimeout('togglebasket("off")',4700);
	}
		function showwishfade(){
		document.getElementById("wishlistresponse").style.display = "block";
		opacity("wishlistresponse", 100, 0, 5000);
		setTimeout('document.getElementById("wishlistresponse").style.display = "none"',5001);
	}
function mySelect(){
document.getElementById("matchstudio").value = document.getElementById("mySelector").value;
}
function emptyme(s){
	opacity(s, 100, 0, 500); 
	setTimeout('document.getElementById("'+s+'").innerHTML = ""',501);
	setTimeout('document.getElementById("'+s+'").style.display = "none";',510);
}
function toggle(e)
{
var curr = document.getElementById(e);
if (curr.style.display == "none" || curr.style.display == "")
{
	if (navigator.appName == "Microsoft Internet Explorer") {
	curr.style.display="block";
	}else{
	curr.style.display="table-row";
	}
}else{
	curr.style.display="none";
}

}
	function findsugg(i){
	xigajax("/usa/con_suggest.php?productid="+i,"thesuggestions","1");
	return false;
	}
        function grabfilmcrave(e){
	xigajax("/usa/con_filmcrave.php?title="+e,"filmcravetrailer","1");
	return false;
        }
function toggleall(curID)
{
// length of the target:
var tlength = curID.length;
		var i;
		var divs=document.getElementsByTagName("TR");
		for(i=0;i<divs.length;i++) {
		var curselect = divs[i].id;
		var tarea = curselect.substring(0,tlength); // isolates the look zone to on the curID part
 			if(tarea==curID) {
						if (navigator.appName == "Microsoft Internet Explorer") {
								document.getElementById(curselect).style.display="block";
						}else{
								document.getElementById(curselect).style.display="table-row";
						}
			}
		}
}
function highlight_ship(profileID)
{
		var divs=document.getElementsByTagName("DIV");
		for(i=0;i<divs.length;i++) {
 			if(divs[i].id.indexOf("shipprof_")==0) {
				divs[i].style.backgroundColor="#F2F2F2";
			}
		}
		document.getElementById("shipprof_"+profileID).style.backgroundColor="#FFFFF3";
	
}
function quickcheck(a) {
if (a == "emailaddress"){ 
	var str = document.getElementById("customers_email_address").value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; //*
    	if (!str.match(re)) { 
			document.getElementById("email_label").style.backgroundColor = "#FF0000"; 
			document.getElementById("submitform").disabled = true;
			document.getElementById("showfix").style.display = "";
			document.getElementById("emailerror").style.color = "White";
			document.getElementById("emailerror").innerHTML = "<br>invalid email";
			return false;
		} else {
 			document.getElementById("email_label").style.backgroundColor = ""; 
			document.getElementById("submitform").disabled = false;
			document.getElementById("showfix").style.display = "none";
		} 
// everything ok .. check vs DB
	theframe.location.href= "/usa/workerbee.php?verifyvsdb=1&area=customers_email_address&value="+str;
}
}