﻿// JScript File
Date.prototype.toString = function () {
    return isNaN (this) ? 'NaN' : [this.getFullYear(), this.getMonth() > 8 ? this.getMonth() + 1 : '0' + (this.getMonth() + 1), this.getDate() > 9 ? this.getDate() : '0' + this.getDate()].join('-') + ' ' + this.getHours() + ':' + this.getMinutes() + ':' + this.getSeconds()
}

function hasClass(ele,cls) {
    return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
    if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
    if (hasClass(ele,cls)) {
	    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
	    ele.className=ele.className.replace(reg,' ');
    }
}

function roundNumber(rnum, rlength) {
    var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
    return newnumber;
}

function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
	    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}
      
function resetPriceRowStyle(id)
{
    var obj = document.getElementById(id);
    removeClass(obj, "row_down");
    removeClass(obj, "row_up");
    clearInterval(obj.timer);
    obj = null;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function CheckEmail(email) {
    email=email.toLowerCase();
    return (email.search(/^[a-zA-Z]+([_\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.[a-zA-Z]{2,4})+$/) != -1);
}

function StripHTML(str){
    str = str.replace(new RegExp( "\\n", "g" ), ' ');
 	return str.replace(/<\/?[^>]+(>|$)/g, '');	
}



function menuover(menuid)
{
    if( document.getElementById("sub"+menuid) != null )
     document.getElementById("sub"+menuid).style.visibility = 'visible';

    document.getElementById("btn"+menuid).className = 'btn_mouseover';
    

}

function menuout(menuid)
{
 if( document.getElementById("sub"+menuid) != null )
     document.getElementById("sub"+menuid).style.visibility = 'hidden';
     
      document.getElementById("btn"+menuid).className = 'btn';
      
      
      
}

function submenuover(menuid, settop)
{
    document.getElementById("c"+menuid).style.visibility = 'visible';
    document.getElementById("c"+menuid).style.top = settop * 23; 

}

function submenuout(menuid)
{
     document.getElementById("c"+menuid).style.visibility = 'hidden';
}

