function get_param(name){
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

String.prototype.isEmail = function () {
	var re = /^[\w_.-]+@[\w.-]+(\.\w+)+$/;
	return re.test(this);
};

String.prototype.isInteger = function () {
	return (isNaN(parseInt(this))) ? false : true;
};

String.prototype.isDate = function () {
	var err = 0
	a = this;
	if (a.length != 10) err=1
	b = parseInt(a.substring(0, 4),10)// year
	c = a.substring(4, 5)// '-'
	d = parseInt(a.substring(5, 7),10)// month
	e = a.substring(7, 8)// '-'
	f = parseInt(a.substring(8, 10),10)// day
	//basic error checking
	if (b<0 || b>3000 || isNaN(b)) err = 1
	if (c != '-') err = 1
	if (d<1 || d>12 || isNaN(d)) err = 1
	if (e != '-') err = 1
	if (f<1 || f>31 || isNaN(f)) err = 1
	//advanced error checking
	// months with 30 days
	if (d==4 || d==6 || d==9 || d==11){
		if (f==31) err=1
	}
	// february, leap year
	if (d==2){ // feb
		var g=parseInt(b/4)
		if (isNaN(g)) {
			err=1
		}
		if (f>29) err=1
		if (f==29 && ((b/4)!=parseInt(b/4))) err=1
	}
	if (err==1){
		return false;
	}else{
		return true;
	}
}

String.prototype.isAlphaNumeric = function () {
	var RE1 = new RegExp("[^0-9a-zA-Z_]");
	return (RE1.test(this)) ? false : true;
};

String.prototype.isPassword = function () {
	if (this.length < 5 || this.length > 8) {
		return false;
	} else {
		var RE1 = new RegExp("[^0-9a-zA-Z_]");
		return (RE1.test(this)) ? false : true;
	}
};

String.prototype.isDoc = function () {
	if (this.lastIndexOf(".doc") > 0) return true;
	if (this.lastIndexOf(".DOC") > 0) return true;
	if (this.lastIndexOf(".pdf") > 0) return true;
	if (this.lastIndexOf(".PDF") > 0) return true;
	if (this.lastIndexOf(".ppt") > 0) return true;
	if (this.lastIndexOf(".PPT") > 0) return true;
	return false;
};

String.prototype.isImg = function () {
	if (this.lastIndexOf(".gif") > 0) return true;
	if (this.lastIndexOf(".jpg") > 0) return true;
	if (this.lastIndexOf(".GIF") > 0) return true;
	if (this.lastIndexOf(".JPG") > 0) return true;
	if (this.lastIndexOf(".PNG") > 0) return true;
	if (this.lastIndexOf(".png") > 0) return true;
	return false;
};

String.prototype.isVideo = function () {
	if (this.lastIndexOf(".flv") > 0) return true;
	if (this.lastIndexOf(".wmv") > 0) return true;
	if (this.lastIndexOf(".FLV") > 0) return true;
	if (this.lastIndexOf(".WMV") > 0) return true;
	return false;
};

String.prototype.isFlickr = function () {
	if (this.lastIndexOf(".flickr.com") > 0) return true;
	return false;
};

String.prototype.isYoutube = function () {
	if (this.lastIndexOf(".youtube.com") > 0) return true;
	return false;
};

var newWin;
function newWindow(url) {
	win_name = "popup";
	width = 700;
	height = 400;
	winLeft = (screen.width-width)/2; 
	winTop = (screen.height-(height+110))/2; 
	win_size = "resizable,scrollbars,status,top="+winTop+",left="+winLeft+",width="+width+",height="+height;
	if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion >="4")
	if (newWin!=null)
		newWin.close();
	newWin = window.open (url, win_name, win_size);
	if (navigator.appName=="Netscape" && navigator.appVersion >= "3")
		newWin.focus();
}

function checkfield(obj, txt) {
	if ($(obj).getValue().strip().empty()) {
		alert(txt);
		$(obj).value = $(obj).getValue().strip();
		$(obj).focus();
		return false;
	} else {
		$(obj).value = $(obj).getValue().strip();
		return true;
	}
}

function countChecked(obj, element_name) {
	len=obj.elements.length;
	var i=0;
	var j=0;
	for( i=0 ; i<len ; i++) {
		if (obj.elements[i].name==element_name && obj.elements[i].checked)
		j=j+1;
	}
	return j;
}

function countSelected(selObj) {
	var i;
	var count = 0;
	for (i=0; i<selObj.options.length; i++) {
		if (selObj.options[i].selected) {
			count++;
		}
	}
	return count;
}

