// ARC Graphics 11.2002 rev 7.2007
// define user language, either thru browser id or with HTTP POST // ARC Graphics 11.2002 rev 3.2005
var Lang=(navigator.language)?navigator.language.substring(0,2):(navigator.browserLanguage)?navigator.browserLanguage.substring(0,2):(navigator.userLanguage)?navigator.userLanguage.substring(0,2):"$SiteLang";
// custom
var StatusDefault	= "Art Fabrik Grenada - the best handpainted batik on the Caribbean Isle of Spice";
// Blend in & out a picture in a DIV (c)ARC Graphics 7.2007
var FadeInSpeed 	= 200;	// blend transition in milliseconds
var FadeOutSpeed	= 500;	// blend transition in milliseconds
var FadeInSteps 	= 50;	// blend steps
var FadeOutSteps	= 50;	// blend steps
var FadeOutDelay	= 200;	// delay to blend out in milliseconds
var FadeOut;	// initialize RestoreLargePict() handle
var FadeOutFrame	= new Array();	// define identifier of blending out function for stopping it with clearTimeout()
function DisplayLargePict(Caller)	{	// on mouse over thumbnail image, change 'Display'-DIV image to a larger version; on mouse out, restore original 'Display'-DIV image
	if ( typeof(Caller) != "undefined" ) {	// change the image in 'Display'-DIV to a large version of the mouseover-caller's A-tag thumbnail image
		ImgTag = GenerateImgTagLarge(Caller);	// generate IMG tag with new picture for 'Display'-DIV
		document.getElementById('Display').innerHTML = ImgTag;	// swap to new image in 'Display'-DIV
		clearTimeout(FadeOut);	// stop any previous blending back
		for(i = 0; i <= 100; i+=Math.round(100/FadeInSteps)) {
			clearTimeout(FadeOutFrame[i]);	// stop any previous blending out
		}
		for(i = 0; i <= 100; i+=Math.round(100/FadeInSteps)) {	// blend image
			setTimeout("ChangeOpacity("+(((100-i)<0)?0:(100-i))+",'Back');ChangeOpacity("+((i>100)?100:i)+",'Show');", (Math.round(FadeInSpeed/100)*((i>100)?100:i)) );	// setTimeout( "function()", after_milliseconds )
		}
	} else {	// no argument in DisplayLargePict(): restore original 'Display'-DIV image
		FadeOut	= setTimeout("RestoreLargePict()",FadeOutDelay);
	}
}
function RestoreLargePict() {	// blend back to original picture in 'Display'-DIV
	for(i = 0; i <= 100; i+=Math.round(100/FadeOutSteps)) {	// blend image
		FadeOutFrame[i]	= setTimeout("ChangeOpacity("+(((100-i)<0)?0:(100-i))+",'Show');ChangeOpacity("+((i>100)?100:i)+",'Back');", (Math.round(FadeOutSpeed/100)*((i>100)?100:i)) );	// setTimeout( "function()", after_milliseconds )
	}
}
function GenerateImgTagLarge(ImgTagSmall) {	// generate the IMG tag for the large picture of the thumbnail with the name format '«fullimagename»_«length»x«height».jpg' and with the same proportions
	ImgTagSPos	= ImgTagSmall.indexOf("src=");
	ImgTagEPos	= ImgTagSmall.indexOf(" ",ImgTagSPos);
	ImgTag	= ImgTagSmall.substring(ImgTagSPos+5,ImgTagEPos-1);
	ImgTag_Pos	= ImgTag.indexOf("_");
	ImgTagName	= ImgTag.substring(0,ImgTag_Pos);	// img name without _«length»x«height»
	ImgTagSize	= ImgTag.substring(ImgTag_Pos+1,ImgTag.indexOf(".jpg"));
	ImgTagWidth	= ImgTagSize.substring(0,ImgTagSize.indexOf("x")) /1;	// division by 1 necessary for IE to convert string to number
	ImgTagHeight	= ImgTagSize.substring(ImgTagSize.indexOf("x")+1,ImgTagSize.length) /1;	// division by 1 necessary for IE to convert string to number
	ImgName	= ImgTagName;
	//ImgWidth	= ImgTagWidth*4;
	//ImgHeight	= ImgTagHeight*4;
	if ( ImgTagWidth > ImgTagHeight ) {	// landscape
		ImgWidth	= 480;	// fixed size according to 'Display'-DIV
		ImgHeight	= Math.round( 480 * (ImgTagHeight/ImgTagWidth)/10 )*10 ;	// keep proportions, rounded to 10
	} else {	// portrait
		ImgHeight	= 480;	// fixed size according to 'Display'-DIV
		ImgWidth	= Math.round( 480 * (ImgTagWidth/ImgTagHeight)/10 )*10 ;	// keep proportions, rounded to 10
	}
	ImgSrc=ImgName+"_"+ImgWidth+"x"+ImgHeight+".jpg";	// generate SRC image filename
	ImgTag = "<IMG SRC=\""+ImgSrc+"\" ALT=\""+ImgSrc+"\" NAME=\"Show\" ID=\"Show\" WIDTH=\""+ImgWidth+"\" HEIGHT=\""+ImgHeight+"\" BORDER=\"0\" STYLE=\"opacity: 0; -moz-opacity: 0; -khtml-opacity: 0; filter: alpha(opacity=0);\">";
	return ImgTag;
}
function ChangeOpacity(Opacity, ID) {	// change the opacity for different browsers (from http://www.brainerror.net/scripts_js_blendtrans.php)
	var Object = document.getElementById(ID).style; 
	Object.opacity	= (Opacity/100);	// newer browsers
	Object.MozOpacity	= (Opacity/100);	// Netscape 6 & old Mozilla
	Object.KhtmlOpacity	= (Opacity/100);	// old Safari & Linux Konquerer 
	Object.filter	= "alpha(opacity="+Opacity+")";	// IE
}
function GenerateLargeImgArray() {	// finds in page all thumbnail pictures that have an 'onMouseOver' to change the 'Display'-DIV
	var ImgTagsLarge = new Array();
	for (var i = 0; i < document.getElementsByTagName("A").length; ++i) {	// for all A tags in document
		var ATagAttrib = document.getElementsByTagName("A")[i].getAttribute("onMouseOver") + "";	// all A tags with a 'onMouseOver' attribute (must add +"" for IE to have it converted to a string)
		if (ATagAttrib.indexOf("DisplayLargePict")>-1) {	// if this A tag has the 'onMouseOver' function 'DisplayLargePict()' 
			ATag = ImgTagsLarge.push(GenerateImgTagLarge(document.getElementsByTagName("A")[i].innerHTML));
		}
	}
	return ImgTagsLarge;
}
function GenerateLargeImgSqueezed() {	// finds in page all thumbnail pictures that have an 'onMouseOver' to change the 'Display'-DIV and generate am IMG with small size for preload in hidden DIV
	var ImgTagsLargeSqueezed = "";	// container for all squeezed images tags
	var ImgLargeSqueezedSize = 10;	// square size of squeezed image
	for (var i = 0; i < document.getElementsByTagName("A").length; ++i) {	// for all A tags in document
		var ATagAttrib = document.getElementsByTagName("A")[i].getAttribute("onMouseOver") +"";	// all A tags with an 'onMouseOver' attribute (must add +"" for IE to have result converted to a string)
		if (ATagAttrib.indexOf("DisplayLargePict")>-1) {	// if this A tag has the 'onMouseOver' function 'DisplayLargePict()' 
			var ImgTagLarge = GenerateImgTagLarge(document.getElementsByTagName("A")[i].innerHTML);
			var ImgTagLargeSqueezed = ImgTagLarge.replace(/HEIGHT="[0-9]+"/g, "HEIGHT=\""+ImgLargeSqueezedSize+"\"");
			ImgTagLargeSqueezed = ImgTagLargeSqueezed.replace(/WIDTH="[0-9]+"/g, "WIDTH=\""+ImgLargeSqueezedSize+"\"");
			ImgTagsLargeSqueezed += ImgTagLargeSqueezed;	// add to container
		}
	}
	return ImgTagsLargeSqueezed;
}
function ShowOrderInfo(State) {
	document.getElementById('OrderInfo').style.visibility=State;
}

