/***
E-commerce site version 1.3.1
-----------------------------
FINISHED: 9-4-2006 by Samuel Fullman
FILE: common_i2_v100.js, build 0001
NOTES: contains functions g(), gCookie, and sCookie, more to be added later

***/
function g(x){ return document.getElementById(x); }
function gCookie(ck){
	var cVal = document.cookie;
	var cStart = cVal.indexOf(" " + ck + "=");
	if(cStart==-1)	cStart = cVal.indexOf(ck + "=");
	if(cStart == -1){
		cVal = null;
	}else{
		cStart = cVal.indexOf("=", cStart) + 1;
		var cEnd = cVal.indexOf(';', cStart);
		if(cEnd==-1) cEnd=cVal.length;
		cVal = unescape(cVal.substring(cStart,cEnd));
	}
	return cVal;
}
function sCookie(cName,cVal,cExp,cPath){
	cVal = escape(cVal);
	if(typeof cExp == 'undefined'){
		var nw = new Date();
		nw.setMonth(nw.getMonth() + 6);
		var expiry= ";expires="+nw.toGMTString();
	}else if(cExp==0){
		var expiry='';
	}else{
		var expiry=';expires='+cExp;
	}
	if(typeof cPath == 'undefined'){
		var path=';Path=/';
	}else{
		var path = ";Path="+cPath;
	}
	//if(testmode==1) alert(cName + "="+cVal + expiry+path);
	document.cookie = cName + "="+cVal + expiry+path;
}
function addCartVis(ID,qty){
	try{
	for(i in currentProducts){
		if(currentProducts[i]==ID){
			g('prod'+currentProducts[i]).style.backgroundColor='#E1DDDD';
			g('added'+currentProducts[i]).style.visibility='visible';
		}else{
			g('prod'+currentProducts[i]).style.backgroundColor='#FFF';
			g('added'+currentProducts[i]).style.visibility='hidden';
		}
	}
	}catch(e){ }
	//g('orderQty').innerHTML=qty;
}
var wins=new Array();
function ow(href,w,p){
	/* v1.00
	 work to do:
	determine if the window is open and if there is unsaved data in it
	indicate in open window that a new url is coming up (gray out over window and text, moving icon pending)
	remember positions only if it works
	*/
	var params;
	if(typeof w=='undefined'){
		//develop - this is a "new" and distinct object
	}
	var reg=/^[0-9]+,[0-9]+$/;
	if(p.match(reg)){
		var a=p.split(',');
		params='width='+a[0]+',height='+a[1]+',resizable,scrollbars,menubar,statusbar';
	}else{
		params=p;
	}
	wins[w]=window.open(href,w,params);
	wins[w].focus();
	return false;
}

