jQuery.checkType = function(value, type){
	if (type=="DD/MM/YYYY"){
		boo_type = false;
		if (splitteddate = $.splitDate(value,'/')){
			if (splitteddate.day+'/'+splitteddate.month+'/'+splitteddate.year == value){
				boo_type=true;
			}
		}
	}else{
		if(type=="int")
	  		str_valid = "0123456789";
	  	else if(type=="string")
	  		str_valid = "abcdefghijklmnopqrstuvwxyz- ëïüéè";
	  	else if(type=="date")
	  		str_valid = "0123456789/";
	  	lngth = value.length;
	  	boo_type = true;
	  	for(s=0;s<lngth;s++){
	  		if(str_valid.indexOf(value.substring(s,s+1))==-1)
	  			boo_type = false;
	  	}
	}
  	return boo_type;
};
jQuery.splitDate = function( datestring, sign, yearcorrection, birthdatecorrection ){
	if (yearcorrection!==false){
		yearcorrection = true;
	}
	//dd/mm/yyyy to array of day month year

	//possible date formats:
	//DD(.)MM, DD(.)MM(.)YY, DD(.)MM(.)YYYY, D.M.Y where '(.)' is optional and '.' is '/' or '-'

	splitted = new Array();
	datestring = datestring.replace(/-/g,sign);

	if (datestring.length == 8 && datestring.indexOf('/')<0){
		datestring = datestring.substr(0,2) + '/' + datestring.substr(2,2) + '/' + datestring.substr(4,4);
	}
	if (datestring.length == 6 && datestring.indexOf('/')<0){
		datestring = datestring.substr(0,2) + '/' + datestring.substr(2,2) + '/' + datestring.substr(4,2);
	}
	if (datestring.length == 4 && datestring.indexOf('/')<0){
		datestring = datestring.substr(0,2) + '/' + datestring.substr(2,2);
	}

	splitstring = datestring.split("/");
	if (splitstring[1]&&!splitstring[2]){
		dt = new Date;
		if (yearcorrection&&(splitstring[1]<=dt.getMonth()||(splitstring[1]==dt.getMonth()+1&&splitstring[0]<dt.getDate()))){
			splitstring[2] = dt.getFullYear() + 1;
		}else{
			splitstring[2] = dt.getFullYear();
		}
	}
	if (splitstring[2]){
		if (splitstring[0].length<2) splitstring[0] = '0'+splitstring[0];
		if (splitstring[1].length<2) splitstring[1] = '0'+splitstring[1];
		if (splitstring[2].length<2) splitstring[2] = '0'+splitstring[2];
		if (splitstring[2].length<3){
			dt = new Date;
			if (birthdatecorrection &&
					((2000+parseInt(splitstring[2],10))>dt.getFullYear()||
					((2000+parseInt(splitstring[2],10))==dt.getFullYear()&&splitstring[1]>dt.getMonth()+1)||
					((2000+parseInt(splitstring[2],10))==dt.getFullYear()&&splitstring[1]==dt.getMonth()+1&&splitstring[0]>dt.getDate()))){
				splitstring[2] = '19'+splitstring[2];
			}else{
				splitstring[2] = '20'+splitstring[2];
			}
		}
		if (checkdate(splitstring[1],splitstring[0],splitstring[2])){
			splitted['day'] = splitstring[0];
			splitted['month'] = splitstring[1];
			splitted['year'] = splitstring[2];
			return splitted;
		}
	}
	return false;
};


jQuery.fn.extend({
  switchClass: function(class1,class2) {
	this.removeClass(class1);
 	this.addClass(class2);
  },
  check: function() {
    return this.each(function() { this.checked = true; });
  },
  uncheck: function() {
    return this.each(function() { this.checked = false; });
  },
  isChecked: function() {
    return this.is(":checked");
  },
  disable: function() {
    return this.each(function() { this.disabled = true; });
  },
  enable: function() {
    return this.each(function() { this.disabled = false; });
  },
  isType:function(type){
  	value = this.val().toLowerCase();
  	return $.checkType(value,type);
  },
  simulateChBox:function(obj){
  	if($("#"+obj+":checked").size()==1)
  		$("#"+obj).uncheck();
  	else if($("#"+obj+":checked").size()==0)
  		$("#"+obj).check();
  },
  simulateRDbutton:function(name,total,me){
  	for(c=0;c<=total;c++){
		if(c!=me)
			$("#"+name+"_"+c).uncheck();
	}
	$("#"+name+"_"+me).check();
  }
});