function xigajax(xPhpFile,xElementId,doIt,reFocus){
		if (doIt) {
		if (reFocus) // scrolls window to top
		{
		  window.scroll(0,0);
		}
		 var onDate = new Date(); // to kill cache
			 sendtotext(xPhpFile+'&rand='+onDate, xElementId);
		}

return false;
	}
		function resetiframe(){
	//alert('reload');
	document.getElementById("currencylist").style.display = 'none';
	theframe.location.reload(); 
	}


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/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 add_tag (item,area)
{
  if (area == 'page')
	  var element = document.getElementById ('tags-input');
	else
	  var element = document.getElementById (area);
	  
	var word = $(item).innerHTML;
	
	// Does this tag already exist?
	if (element.value.indexOf (word) == -1)
	{
		if (element.value.length > 0)
			element.value += ',';
			
		element.value += word;
		$(item).className = 'enabled';
	}
	else
	{
		element.value = element.value.sub (word, '');
		element.value = element.value.sub (' , ', ', ');
		element.value = element.value.sub (',,', ', ');
		element.value = element.value.sub ('  ', ' ');
		element.value = element.value.strip ();
		
		if (element.value.charAt (element.value.length - 1) == ',')
			element.value = element.value.substr (0, element.value.length - 1);

		if (element.value.charAt (0) == ',')
			element.value = element.value.substr (1);
		
		element.value = element.value.strip ();
		$(item).className = 'disabled';
	}
}

function add_cross(item)
{
	  var element = document.getElementById ('crosspromote');
	var word = $(item).innerHTML;
		element.value += word;
}
function createprice()
{
var ourcost = document.getElementById('RetailPrice').value;
var newsell = ourcost*1.8626;
document.getElementById('MembersPrice').value = newsell.toFixed(1)+"7";
}
// addto('Features','<li>Material: <b></b>')
function addto(d,code)
{
	var there = document.getElementById(d);
	if (there){
	there.value = there.value + code +"\n";
	}else{
		there.value = code +"\n";
	}
}
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 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
	worker.location.href= "/chess_workerbee.php?verifyvsdb=1&area=customers_email_address&value="+str;
}
if (a == "entry_phonenumber"){
	var str = document.getElementById("entry_phonenumber").value;
//alert("phonenumber, value="+str);
	if (str == "") {
		alert("You didn't enter a phone number, which is required for delivery");
		return false;
	}
}

}
function copyclip(texto){
window.clipboardData.setData('text',texto);
}