// utility function to retrieve an expiration date in proper
// format; pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire (or negative
// values for a past date); all three parameters are required,
// so use zeros where appropriate
function getExpDate(days, hours, minutes) {
    var expDate = new Date( );
    if (typeof days == "number" && typeof hours == "number" && 
        typeof hours == "number") {
        expDate.setDate(expDate.getDate( ) + parseInt(days));
        expDate.setHours(expDate.getHours( ) + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
        return expDate.toGMTString( );
    }
}
   
// utility function called by getCookie( )
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
	var c = decodeURIComponent(document.cookie.substring(offset, endstr));
	return c.replace("+"," ");
    return unescape(document.cookie.substring(offset, endstr));
}
   
// primary function to retrieve cookie by name
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 "";
}
   
// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
   
// remove the cookie by setting ancient expiration date
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";
    }
}

// check user authed or not
function isAuthed() {
    var cookie = getCookie("UserId");
    if (cookie >0) return 1;
    return 0;
}



function Round(a_Num , a_Bit) {
    var a,re,x,r,b;
	a = Math.round(a_Num * Math.pow (10 , a_Bit)) / Math.pow(10 , a_Bit) ;
	if(isNaN(a)){
		return null;
	}
    re = a.toString().lastIndexOf('.');
    if(re==-1){
        x = Math.pow(10,a_Bit);
        r = x.toString().replace('1','');
        a = a.toString()+'.'+r;
    }else{
		b = a_Bit - a.toString().substr(re+1).length;
		if(b>0){
			//a = a.toString();
			a = a.toString();
			x = Math.pow(10,b);
			r = x.toString().replace('1','');
			a = a.toString()+r;
		}
	}
    return a;
}


function AddToCart()
{
	if(isAuthed()==false)
	{
		//alert("ÇëÏÈµÇÂ½");
		//return false;
	}
}