var sData = new Array();
var sTemp;
var sQueryString = document.location.search.substr(1);
var doubles =  sQueryString.split("&");
for (var i = 0; i < doubles.length; i ++){
	sTemp = doubles[i].split("=");
	window[sTemp[0]] = sTemp[1];
}

function Cookie(document, name, hours, path, domain, secure) {
	this.$document=document;
	this.$name=name;
	if (hours>0)
		this.$expiration=new Date((new Date()).getTime()+hours*3600000);
	else	this.expiration='Fri, 02-Jan-1970 00:00:00 GMT';//this.$expiration=null;
	if (path)	 this.$path=path;	else this.$path=null;
	if (domain)	 this.$domain=domain;	else this.$domain=null;
	if (secure)	this.$secure=true;	else this.$secure=false;
}

function _Cookie_store(){
	var cookieval="";
	for(var prop in this){
		if ((prop.charAt(0)=='$')||((typeof this[prop])=='function'))
			continue;
		if (cookieval!="")cookieval+='&';
		//cookieval+=prop+':'+escape(this[prop]);
		cookieval+=prop+':'+this[prop];
	}
	var cookie=this.$name+'='+cookieval;
	if (this.$expiration)
		cookie+= '; expires='+this.$expiration.toGMTString();
	if (this.$path) cookie+= '; path='+this.$path;
	if (this.$domain) cookie+= '; domain='+this.$domain;
	if (this.$secure) cookie+= '; secure';
	this.$document.cookie=cookie;
	//alert(this.$document.cookie+" = "+cookie);
}

function _Cookie_load(){
	var allcookies=this.$document.cookie;
	if (allcookies=="") return false;
	var start=allcookies.indexOf(this.$name+'=');
	if (start==-1) return false;
	start+=this.$name.length+1;
	var end=allcookies.indexOf(';', start);
	if (end==-1) end=allcookies.length;
	var cookieval=allcookies.substring(start, end);
	var a=cookieval.split('&');
	for (var i=0;i<a.length ;i++ ){
		a[i]=a[i].split(':');
	}
	//window['prods']=a[0][1];
	var prods=a[0][1];
	return prods;
}

function _Cookie_remove(){
	var cookie;
	cookie=this.$name+'=';
	if (this.$path) cookie+= '; path='+this.$path;
	if (this.$domain) cookie+= ';domain='+this.$domain;
	cookie+= '; expires=Sat, 01-Jan-2005 00:00:00 GMT';//expires=Fri, 02-Jan-1970 00:00:00 GMT';
	this.$document.cookie=cookie;
}

new Cookie();
Cookie.prototype.store=_Cookie_store;
Cookie.prototype.load=_Cookie_load;
Cookie.prototype.remove=_Cookie_remove;

var tempdata=new Cookie(document, 'tempdata', 24);

function setCookie(id, quant, colid){
	var temp=tempdata.load();
	if (temp!=false)
	{
		tempdata.prods="";
		prods=temp.split("$");
		for(i=0;i<prods.length;i++){
			elements=prods[i].split('/');
			if((elements[0]==id)&&(elements[2]==colid)){
				
				quant = parseInt(quant) + parseInt(elements[1]);
			}
			else {
				if((elements[0])&&(elements[1])&&(elements[2])){
					tempdata.prods+=elements[0]+'/'+elements[1]+'/'+elements[2]+'$';
				}
			}
		}
		tempdata.prods+=id+"/"+quant+"/"+colid+"$";
	}
	else
	{
		tempdata.prods=id+"/"+quant+"/"+colid+"$";
	}
	tempdata.store();
}

function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr)); 
}

function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break;
	} 
	return null; 
}

function DeleteCookie (name,path,domain) { 
	if (GetCookie(name)) { 
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
	} 
} 

function delCookie(){
	//var tempdata=new Cookie(document, 'tempdata',-1);
	//tempdata.store();
	if(navigator.userAgent.indexOf('Windows')>0)	DeleteCookie('tempdata',this.$path,this.$domain);
	else DeleteCookie('tempdata','','mmm2100.london21-verio.com');
	//tempdata.remove();
}

function delProd(id,quant,colid){
	all = tempdata.load();
	tempdata.prods="";
	prods=all.split("$");
	for(i=0;i<prods.length;i++){
		if(prods[i]==(id+"/"+quant+"/"+colid)){
			continue;
		}else{
			elements=prods[i].split('/');
			if((elements[0])&&(elements[1])&&(elements[2])){
				tempdata.prods+=elements[0]+'/'+elements[1]+'/'+elements[2]+'$';
			}
			tempdata.store();
		}
	}
}

function dynChange(treeitem){
	if (document.getElementById){
		list=document.getElementsByTagName("div");
		for (i=0;i<list.length;++i){
			if (list[i].id==""){
				continue;
			}
			temp = treeitem+"_table";
			if (list[i].id==temp){
				var tbl = document.all[treeitem+"_table"];
				if (tbl.style.display == ""){
					tbl.style.display = "none";
				}
				else{
					tbl.style.display = "";
					continue;
				}
			}
			if (list[i].id!=temp){
				var tbl2 = document.all[list[i].id];
				tbl2.style.display = "none";
			}
		}
	}
}

function frameChange(whichframe) {
	for ( i=0; i==maxcount; ++i)
	{
		if (i==whichframe)
		{
			document.iframe["edit_"+i].name = "idEditbox";
		}
		else
		{
			document.iframe["edit_"+i].name = "'"+i+"'";
		}
	}

}

function editText(content, secName){
	var newwin=window.open("../templates/editor.html", "editor", "width=550,height=350");
	newwin.creator=self;
	newwin.content=escape(content);
	newwin.secName=secName;
}

function basketCase() {
	window.parent.colours.document.location = "../leftpanel.html";
	window.parent.display.document.location = "http://www.cimac.net/cgi-local/shop.pl";
}

function check(oTD) {
     var el, i = 0;
     while (el = oTD.childNodes[i++]) 
            if (el.type == 'radio') el.checked = true;
}

function popup(page){
	switch (page){
		case 'contact':	var fullpage='contactuspopup.html';
		case 'login':		var fullpage='loginpopup.html';
		default:				break;
	}
	window.open(eval(fullPage),'_new','width=250,height=500,scrollbars=yes');
}
