
function Util(){};

Util.changeDiv = function(id_1, id_2){

	$(id_1).hide();
	$(id_2).show();

};

Util.radioEvent = function(id_1, id_2) {

	if ($(id_1).checked) {
		$(id_2).checked = false;
	}

}

Util.checkDate = function(y, m, d) {
	 
	d = parseInt(d,10);
 	m = parseInt(m,10)-1;

 	var dat = new Date(y, m, d);

 	if (dat.getDate()==d && dat.getMonth()==m && dat.getFullYear()==y) {
     	return true; 
	} 
	return false;
	
}

Util.checkInt = function(val) {

	reg_ex=/\d$/;
	isnum = reg_ex.test(val);

	if (!isnum || isNaN(val)) {
		return false;
	}
	return true;

};

Util.isEmail = function(val) {

	if (Util.isEmpty(val)) { return true; }

	reg_ex=/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/;
	isemail = reg_ex.test(val);

	if (!isemail) {
		return false;
	}
	return true;

};

Util.checkEmail = function(email) {
  var proto  = "(mailto:)?";
  var usr    = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
  var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
  var regex  = "^" + proto + "?" + usr + "\@" + domain + "$";

  var rgx    = new RegExp(regex);
  return rgx.exec(email) ? true : false;
};

Util.isEmpty = function(val){

	if (val.length == 0 || val.match(/^\s+$/)) {
		return true;
	}
	return false;

};


Util.removeReadonly = function(obj) {

	obj.style.backgroundColor = "#ffffff";
	obj.removeAttribute('readonly');
	obj.focus();

};

Util.setReadonly = function(obj) {

	obj.setAttribute('readonly','readonly');
	obj.style.backgroundColor = "#CCCCCC";

};
Util.randomNumber = function(offset, limit)
{
	return Math.floor(Math.random()*(limit+1)) + offset;
};
Util.click_ = function(obj)
{
	if (!$(obj)) { return; }

	if (document.createEvent && $(obj).dispatchEvent) { // Firefox usw.
		var evt = document.createEvent("MouseEvents");
		if (evt && evt.initMouseEvent) evt.initMouseEvent("click",true,true,document.defaultView,1,0,0,0,0,false,false,false,false,0,null);
		$(obj).dispatchEvent(evt);
	}
	else { // IE ...
		$(obj).click();
	}
};

Util.GetParam = function(str)
{
	var start = location.search.indexOf("?"+str+"=");
	if (start<0) start=location.search.indexOf("&"+str+"=");
	if (start<0) return '';
	
	start += str.length+2;
	var end=location.search.indexOf("&",start)-1;
	if (end<0) end=location.search.length;
	  
	var result='';
	for(var i=start; i<=end; i++) 
	{
		var c=location.search.charAt(i);
			result=result+(c=='+'?' ':c);
	}
	  
	return unescape(result);
};


