var bSubmitted = false;
function nothing(){
}
function showLogoff(){
	/**
	window.document.forms["hoho"].action = "logoff.php"; 
	submitForm ("hoho", false, "");
	**/
	window.location.href='logoff.php'
}

function showLogin(){

	var URL_PAGE, NEW_WIN, ORDER_ID, EMAIL;

	URL_PAGE = "login.php";
	iHeight = "100";
	iWidth = "300";

	
	NEW_WIN = window.open(URL_PAGE, null,"height=" + iHeight + ",width=" + iWidth + ",status=no,scrollbars=no,toolbar=no,menubar=no,resizable=no,location=no");    
	NEW_WIN.focus();        		
}

function submitForm (_sFormName, _bConfirmation, _sMessage)
{    
    if (_sMessage == null || _sMessage.length == 0) {
        _sMessage = "Do you really want to proceed??";
    }
        
    var confirm;        
    if (_bConfirmation != null && _bConfirmation == false) {
        confirm = true;
    } else {
        confirm = window.confirm(_sMessage);
    }
        
    if (confirm == true) {
        if (bSubmitted == false) {            
            window.document.forms[_sFormName].submit();
            bSubmitted = true;                            
        }
    } else {

        return false;
    }
}

/**
 * If element of elementName is collection, check it all
 */
function check (elementName)
{
        var elements = document.getElementsByName (elementName);
        for (var i=0; i < elements.length; i++) {
                if(elements[i].disabled == false){                    
                    elements[i].checked = true;
                }
        }
}

/**
 * If element of elementName is collection, uncheck it all
 */
function uncheck (elementName)
{
        var elements = document.getElementsByName (elementName);
        for (var i=0; i < elements.length; i++) {
                elements[i].checked = false;
        }
}

function CheckDate(val){
	if(val.length>11) return '';
	else{
		var iDay = strDay(val);
		var iMonth = strMonth(val);
		var iYear = strYear(val);
		if(!isNaN(iDay) && iMonth>0 && !isNaN(iYear)){
			if(iMonth==2){if(iYear%4==1) if(iDay>28) return '';}
			else{
				if(iMonth==4 || iMonth==6 || iMonth==9 || iMonth==11){if(iDay>30) return '';}			
				else{if(iDay>31) return '';}
			}
			return val;
		}else{
			return '';
		}	
	}
}

function strMonth(dt){
	var iMonth = MonthNum((dt.substr(3,3)).toUpperCase());
	
	return iMonth;
}

function strDay(dt){
	var iDay = dt.substr(0,2)
	return iDay;
}

function MonthNum(val){
	val = val.toUpperCase();
	if(val=="JAN"){
		return 1;
	}
	if(val=="FEB"){
		return 2;
	}
	if(val=="MAR"){
		return 3;
	}
	if(val=="APR"){
		return 4;
	}
	if(val=="MAY" || val=="MEI"){
		return 5;
	}
	if(val=="JUN"){
		return 6;
	}
	if(val=="JUL"){
		return 7;
	}
	if(val=="AUG" || val=="AGT"){
		return 8;
	}
	if(val=="SEP"){
		return 9;
	}
	if(val=="OCT" || val=="OKT"){
		return 10;
	}
	if(val=="NOV" || val=="NOP"){
		return 11;
	}
	if(val=="DEC" || val=="DES"){
		return 12;
	}
	return 0;
}

function strYear(dt){
	var iYear = dt.substr(7,4)
	return iYear;
}

function formatCurrency(num,idname) {

		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();

		if(cents<10)
		cents = "0" + cents;

		////PUT VALUE WITHOUT ',' IN HIDDEN FIELD TO BE SENT TO DATABASE
		//document.getElementById(idname).value=num + '.' + cents;
		
		//document.all(idname).value=num;
		document.getElementById(idname).value=num;

		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));

		return (((sign)?'':'-') + num);
		
	//}
}

function trim(strMessage) {
	
	return (strMessage.replace(/^\s+|\s+$/g, ''));
}