/*
function setCookie(name, value, expires, path, domain, secure) {
 var curCookie = name + "=" + escape(value) +
     ((expires) ? "; expires=" + expires.toGMTString() : "") +
     ((path) ? "; path=" + path : "") +
     ((domain) ? "; domain=" + domain : "") +
     ((secure) ? "; secure" : "");
 document.cookie = curCookie;
}
*/
function SetCookie (name, value) { 
alert(name) 
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;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function popLoading()
{
//var exp = new Date(); 
//exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
//SetCookie("LOADING", "load");
var attributes;	
	{
		var popup_width=280;
		var popup_height=150;
		var screen_width=window.screen.width;
		var screen_height=window.screen.height;
		var popup_left=Math.round((screen_width-popup_width)/2);
		var popup_top=Math.round((screen_height-popup_height)/2);    
		attributes = "scrollbars=0,resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,height=" + popup_height + ",width=" + popup_width + ",top="+popup_top+",left=" + popup_left; 
	}	
//setCookie("LOADING", "load", now);
LoadWin = window.open('includeGen/loading.asp','LoadingWin',attributes);
}
function popLoadingClose()
{
window.open('','LoadingWin').close();
}
function openWindow(pageUrl,pageName,attributes)
{
//popLoading();	
//	var popup_win = window.open(pageUrl,pageName,attributes);
//	popup_win.focus();
document.goon.action=pageUrl; document.goon.submit();
//window.location.href = pageUrl;	 
}

function sortProductsBy(resort,currentQstring)
{
	var tmpSearch;
	if(resort != '')
	{	
		
		if(currentQstring == '' || currentQstring == 'undefined')
		{
			tmpSearch = 'productSortBy=' + resort;
		}
		
		else
		{	
			tmpSearch = 'productSortBy=' + resort + currentQstring;
		}
		
		window.location.search = tmpSearch;

	}
}

function ShowCat(categoryID,windID)
{
	//if (document.images["b"+i].src == url0+"button/but_x.jpg") 
	if(categoryID.style.display=='none')
	{
		categoryID.style.display='';
		//ChangeWind(windID);
	}
	else
	{
		categoryID.style.display='none';
		//ChangeWind(windID);
	}	
}

function ChangeWind(windID)
{
	if(windID.className == "wind1")
		windID.className = "wind"
	else
		windID.className = "wind1"
}


function dologin(inForm,FailReturnTo,SuccessReturnTo)
{
	if(inForm.username.value=='') 
	{
		//alert("בצוע לוגין : שם משתמש חובה");
		alert("Please enter user name");
		inForm.username.focus();
	}
	else if(inForm.password.value=='') 
	{
		//alert("בצוע לוגין : סיסמא חובה");
		alert("Please enter password");
		inForm.password.focus();
	}
	
	else
	{
	//	popLoading();
		inForm.FailReturnTo.value = FailReturnTo;
		inForm.SuccessReturnTo.value = SuccessReturnTo;
		inForm.submit();
	}	
}
function dologin_update(inForm,FailReturnTo,SuccessReturnTo)
{
//	inForm.FailReturnTo.value = FailReturnTo;
//	inForm.SuccessReturnTo.value = SuccessReturnTo;
	inForm.submit();
}

function dologout(inForm)
{
//	inForm.FailReturnTo.value = window.location;
//	inForm.SuccessReturnTo.value = window.location;
	inForm.submit();
}

 
function openHelp(url, name,reqWidth) 
{
var winPar = 'scrollbars=1,left=10,top=20 resizable=1,height=400,width='+parseInt(reqWidth)  
	popupWin = window.open(url, name,winPar )
	popupWin.focus(); 
} 

function cleanNumber(checkVal)
{
	var checkValLen = checkVal.length;	
	if(checkValLen == 0)
	{
		return 0;
	}
	var num = "";
	for(var i = 0 ; i <	checkValLen ; i++)
	{
	if(isFloatDigit(checkVal.charAt(i)))
		{
		num = num + checkVal.charAt(i)
		}	
	}
	return num;
}
function isFloatDigit(character)
{
var digit_characters = "0123456789.0"
	if (digit_characters.indexOf(character) == -1)
		{
		return false
		}
	return true
}
var buttonFocusColor;
var buttonFocusFontColor;
function buttonFocus(obj,bcolor,fcolor)
{
obj.style.cursor='hand';
buttonFocusColor=obj.style.backgroundColor
buttonFocusFontColor=obj.style.color
obj.style.backgroundColor=bcolor
obj.style.color = fcolor
//style.textDecoration
if(document.getElementById("buttonsound"))
document.buttonsound.play();
}
function buttonOut(obj)
{
obj.style.cursor='auto';
obj.style.backgroundColor = buttonFocusColor
obj.style.color = buttonFocusFontColor;
}
function rightProtect(e) {
//var msg = "Sorry, you don't have permission to right-click.";
var msg = "All Rights Reserved";
if (navigator.appName == 'Netscape' && e.which == 3) {
alert(msg);
return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
alert(msg);
return false;
}
else return true;
}
function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);	
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;	
	return s;
}

function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)	
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];	
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;	
	return amount;
}