function getURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	if(strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for(var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if(aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
		return strReturn;		
	}
	return false;
} 

function cancelKey(evt) {
	if (evt.preventDefault) {
		evt.preventDefault();
		return false;
	}else{
		evt.keyCode = 0;
		evt.returnValue = false;
	}
}

function stopRKey(evt) {
	var evt=(evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if(evt.keyCode == 13 && node.type!='textarea' && node.type!='text'){
		return false;
	}
}

function get_base_href()	{
	if(window.document.getElementsByTagName('BASE'))	{
		aBase=window.document.getElementsByTagName('BASE');
		for(i=0;i<aBase.length;i++)	{
			if(aBase[i].href)
				return aBase[i].href;
		}
	}
	return '';
}

function setCookie(NameOfCookie, value, expiredays){
	expiredays=2;
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	try {
		myCookie=NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + ExpireDate.toGMTString())+ ";path=/" + "";
		document.cookie = myCookie;
	}
	catch(e){
		alert('Failed to set cookie: '+e.description+ ' ('+NameOfCookie+')');
	}
}

function getCookie(NameOfCookie){
	if(document.cookie.length > 0){ 
	begin = document.cookie.indexOf(NameOfCookie+"="); 
	if(begin != -1){ 
		begin += NameOfCookie.length+1; 
		end = document.cookie.indexOf(";", begin);
		if(end == -1) 
			end = document.cookie.length;
		return unescape(document.cookie.substring(begin, end)); } 
	}
	return null; 
}

function delCookie(NameOfCookie){
	if(getCookie(NameOfCookie)){
		document.cookie = NameOfCookie + "=" +"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function checkCookie(){
	Set_Cookie('test','none','','/','','');	
	if(!Get_Cookie('test')){
		errorDialog.setTitle('');
		errorDialog.doShow('');
	}else{
			
	}
	
}

function image_swap(id,image){
	if(document.getElementById(id))
		document.getElementById(id).src=image;
}

function CurrencyFormatted(a){var i=parseFloat(a);if(isNaN(i)){i=0.00;}var m='';if(i<0){m='-';}i=Math.abs(i);i=Math.round(i*1000)/1000;i=Math.round(i*100)/100;s=new String(i);if(s.indexOf('.')<0){s+='.00';}if(s.indexOf('.')==(s.length-2)){s+='0';}s=s.replace('.',',');n=s.indexOf(',');if(n>3&&n<6){return m+s.substr(0,(n-3))+'.'+s.substr((n-3));}return m+s;}			
function IsNumeric(T){var V="0123456789.";var C;for(_i=0;_i<T.length;_i++){C=T.charAt(_i);if(V.indexOf(C)==-1){return false;}}return true;}	
function inArray(s,a){_f=false;_k=new Array(false,0);if(a.length==0)return false;for(_i=0;_i<a.length;_i++){_v=a[_i].toString();if(_v==s){_f=true;_k[1]++;if(_k[0]===false)_k[0]=_i;}}if(_f===true)return _k;return false;}
function sortNumber(a,b){return a-b;}
function preload_image(href){image=new Image();image.src=href;}		

errorDialog=function(){
	this.prefix='<li>';
	this.suffix='</li>';
	this.selector='#errorDialog';
	this.msg=null;
	this.set=function(msg){
		this.msg=msg;
		$(this.selector+" .content").append(this.prefix+msg+this.suffix);
	}
	this.setTitle=function(Title){
		$(this.selector+" h2").html(Title);
	}
	this.reset=function(){
		$(this.selector+" .content").empty();
	}
	this.show=function(){
		var _this=this
		$(function(){
			$(_this.selector+" .ui-dialog-content").css('height',$(_this.selector+" .content").height());
			$(_this.selector).dialog({
				closeOnEscape: true,
				dialogClass: "classError",
				draggable: false,
				resizable: false,
				width:475,
				buttons:{ "OK":function() { 
					$(this).dialog("close"); 
				}}
			});
			$(_this.selector).dialog("open");
		});			
	}
	this.doShow=function(msg){
		this.reset();
		this.set(msg);
		this.show();
	}

}
var errorDialog=new errorDialog();