
//this sets directory location of images
//var iu='img/';
var jspBase="/webapp/wcs/stores/servlet/ConsumerDirect";
var cmdBase="/webapp/wcs/stores/servlet";



//this mouseover and mouseout function rely on two things:
// 1. the over and out states of the images are represented by _on.gif and _off.gif suffixes
// 2. that the _off.gif state image is located in the same directory as the _on.gif state image

function mOver (imgName) {
	var currentImage = eval("window.document." + imgName);
	var imgSource = currentImage.src;
	var num = imgSource.indexOf("_off.gif");
	currentImage.src = imgSource.slice (0, num) + "_on.gif";
}

function mOut (imgName) {
	var currentImage = eval("window.document." + imgName);
	var imgSource = currentImage.src;
	var num = imgSource.indexOf("_on.gif");
	currentImage.src = imgSource.slice (0, num) + "_off.gif";
}

//OLD VERSION - preload functions for various groups of rollovers depending on template
/*function preload() {
	preload1valsall=new Array (iu+'btn_home_.gif',iu+'btn_about_on.gif',iu+'btn_shop_on.gif',iu+'btn_partnership_on.gif',iu+'btn_customer_on.gif',iu+'btn_contact_on.gif',iu+'btn_store_on.gif',iu+'btn_francais_on.gif',iu+'btn_english_on.gif');
	preload1=new Array (preload1valsall.length);
	for (var i=0; i < preload1.length; i++){
		preload1[i]=new Image();
		preload1[i].src=preload1valsall[i];
	}
}*/

//NEW VERSION - preload functions for various groups of rollovers depending on template
function preload() {
	preload1valsall=new Array (iu+'btn_home2_on.gif',iu+'btn_about_on.gif',iu+'btn_shop2_on.gif',iu+'btn_partnership_on.gif',iu+'btn_customer_on.gif',iu+'btn_contact_on.gif',iu+'btn_store2_on.gif',iu+'btn_francais_on.gif',iu+'btn_english_on.gif',iu+'btn_flyers_on.gif');
	preload1=new Array (preload1valsall.length);
	for (var i=0; i < preload1.length; i++){
		preload1[i]=new Image();
		preload1[i].src=preload1valsall[i];
	}
}


//popup new window for delivery options

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=400,left = 255,top = 232');");
}

// global functions for links
function popup(link){
	window.open(link, 'MainWin');		
}
function go(link){
	//location.href=link;
	window.open(link, 'WCMainWindow');
}

function switchLanguage(fromLang, toLang){
	var url=document.location.href;
	if (url.indexOf('langId='+fromLang)>0){
		document.location.href=url.replace('langId='+fromLang, 'langId='+toLang);
	}
	else if(url.indexOf('langId=')>0){
		var idxStart=url.indexOf('langId=');
		var idxEnd=url.indexOf('&', idxStart);
		var langString="";
		if (idxEnd>0){
			langString=url.substring(idxStart, idxEnd);
		}
		else{
			langString=url.substring(idxStart);
		}
		document.location.href=url.replace(langString, 'langId='+toLang);
	}
	else if (url.indexOf('/en_US/')>0 ||url.indexOf('/fr_FR/')>0){
		document.location.href=url.replace('/'+fromLang+'/', '/'+toLang+'/');
	}
	else{	
		if (url.indexOf('?') < 0){
			document.location.href=url+"?langId="+toLang;
		}
		else{
			document.location.href=url+"&langId="+toLang;
		}
	}
}

function stripChars (input, filteredValues) {
	s = input.value;	
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (filteredValues.indexOf(c) == -1) returnString += c;
	}
	input.value = returnString;
}

function onlyNumeric (input) {
	s = input.value;
	filteredValues = "1234567890";     // Anything other than this is stripped out
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (filteredValues.indexOf(c) != -1) returnString += c;
	}	
	input.value = returnString;
}


	
function OpenWindow(gotoURL,width,height,WinOptions){OpenWindowAdv(gotoURL,width,height,WinOptions,"")}

function OpenWindowAdv(gotoURL,width,height,WinOptions, WinName) 
	{	if (WinOptions=="") WinOptions = "resizeable=no,scrollbars=yes,menubar=no,toolbar=no,status=no";if (WinName=="") WinName = "NEW";
		if (gotoURL.indexOf("Abstract")==-1){gotoURL+='&Abstract=True';}popupWin=window.open(gotoURL, WinName ,WinOptions+',width='+width+',height='+height);
	}

	