function SetCookie(name,value){
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3 ) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	var curCookie = name + '=' + escape(value)+
	((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +
	((secure == true) ? '; secure' : '');
	document.cookie = curCookie;
}
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 DeleteCart(){
	x = confirm("Empty your Cart?")
	if(x){
		var exp = new Date();
		exp.setTime (exp.getTime() - 1000000000);
		var cval = GetCookie('cart');
		document.cookie='cart' + '=' + cval + '; expires=' + exp.toGMTString();
	}	
}


function DeleteCart2(){
	var x = 1;
	if(x){
		var exp = new Date();
		exp.setTime (exp.getTime() - 1000000000);
		var cval = GetCookie('cart');
		document.cookie='cart' + '=' + cval + '; expires=' + exp.toGMTString();
	}	
}










function AddtoCart(Name,value){
	theprice = value.split('&')		
	if(theprice[1] !='Call'){
		x = 1 
//confirm("Add this item to your cart?")

		if(x){
			if(GetCookie('cart') != null)
				oldvalue = GetCookie('cart');
				if(GetCookie('cart') != null)
				value = oldvalue + '&' + value;
				var expdate= new Date();
				expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
				SetCookie(Name, value, expdate);
				return
			}
		}
	else {
		var popup = null
		popup = window.open('', 'popupnav', 'width=200,height=170,top=80,left = 80,resizable=1,scrollbars=auto');
		popup.document.write("Please call <font color = 'red'> 1-877-361-0091<br></font>to order this item<br>Item Number "+theprice[0]+"<br>This item has not been added to your cart");			


	}


}


function AddtoCart2(Name,value){
	theprice = value.split('&')		
	if(theprice[1] !='Call'){
		x = 1 
	alert(theprice[0]+" added to cart")

		if(x){
			if(GetCookie('cart') != null)
				oldvalue = GetCookie('cart');
				if(GetCookie('cart') != null)
				value = oldvalue + '&' + value;
				var expdate= new Date();
				expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
				SetCookie(Name, value, expdate);
				return
			}
		}
	else {
		var popup = null
		popup = window.open('', 'popupnav', 'width=200,height=170,top=80,left = 80,resizable=1,scrollbars=auto');
		popup.document.write("Please call <font color = 'red'> 1-877-361-0091<br></font>to order this item<br>Item Number "+theprice[0]+"<br>This item has not been added to your cart");			


	}


}





function ReviewCart(){
	if(GetCookie('cart') !=null){
		var cartstring = GetCookie('cart');
		var cartobj = new String(cartstring);
		alert('cartstring = ' + cartstring);
		alert('cartobj = ' + cartobj);
		var items = cartstring.split('&');
		return items
	}
}


function ShowItems(items){
	document.write(items);
}


function Remove(item,index){
	var tcart = '';
	var tmpcart = GetCookie('cart');
	var tmpitems = tmpcart.split('&');

	if(tmpitems.length==4){
		DeleteCart();
		return;
	}
	x = confirm("Remove Item " + item);
	if(x){
		for(f = 0; f<tmpitems.length;f=f+4){
			if(f != index){
				tcart = tcart + tmpitems[f] +'&'+tmpitems[f+1]+'&'+tmpitems[f+2]+'&'+tmpitems[f+3];
				tcart=tcart+'&';
				
			}

		}			
		tcart2 = tcart.slice(0,-1)
		tcart = tcart2
		var expdate= new Date();
		expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
		SetCookie('cart', tcart , expdate);

	}
}


function format(expr, decplaces) {
	var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces))
	while (str.length <= decplaces){
		str="0" + str
	}
	var decpoint = str.length - decplaces
	return str.substr(0,decpoint) + "." + str.substring(decpoint,str.length);
}


function sendurl(){
	items = GetCookie('cart');
	var exp = new Date();
	exp.setTime (exp.getTime() - 1000000000);
	var cval = GetCookie('cart');
	//document.cookie='cart' + '=' + cval + '; expires=' + exp.toGMTString();

	if(items != null){

		items = escape(items);
		items = "?" + items;
		newwin = window.open();
		newwin.location.href="cart.asp" +items;
	}
	else document.write("<font color = 'red'>Your Cart is Empty</font>");
}

function GetItems(){
	var items = unescape(location.search.substr(1))
	alert(items)
}

function checkFrames(){
	var minNav3 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >=3 )
	var minIE4 = (navigator.appName.indexOf("Mircosoft") >= 0 && parsInt(navigator.appVersion) >= 4 )
	var minDOM = minNav3 || minIE4
	var isNav4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4)
	if (parent == window){
		if (isNav4 && window.innerWidth ==0){
			return
		}
		if (minDOM){
			window.location.replace("showroom.htm")
		}else{
		window.location.href = ("showroom.htm")
		}
	}
}

		
