function isString(){
	if (typeof(arguments[0]) == 'string'){return true;}
	if(typeof(arguments[0]) == 'object'){
		var criterion = arguments[0].constructor.toString().match(/string/i); 
		return (criterion != null);
	}
	return false;
}

function get_parent(obj,findTag){
	count=0;
	foundObj=false;
	limit=10;
	parentObj=false;
	do{
		if(!parentObj){parentObj=obj;}
		parentObj=parentObj.parentNode;
		tmpName=parentObj.tagName;
		count++;
		if(tmpName.toLowerCase()=='html'){break;}
	}while(tmpName.toLowerCase()!=findTag.toLowerCase() && count<=limit)// && count<=100
	if(tmpName.toLowerCase()==findTag.toLowerCase()){foundObj=parentObj;}
	return foundObj;
}
function basic_check(stringIn){
	if(typeof(stringIn)=='string'){
		tmp=stringIn.trim();
		if(tmp.length>0){
			return true;
		}else{
			return false;}
	}else{
		return false;}
}
function check_strip_last(stringIn,checkFor){
	output="";
	if(!(stringIn.indexOf(checkFor)==-1)){//found
		startPoint=stringIn.length-checkFor.length;
		tmp=stringIn.substr(startPoint,checkFor.length);
		if(tmp==checkFor){
			output=stringIn.substr(0,(stringIn.length-checkFor.length));}
		else{
			output=stringIn;}		
		return output;
	}else{
		return stringIn;}
}
function check_strip_first(stringIn,checkFor){
	output="";
	if(!(stringIn.indexOf(checkFor)==-1)){//found
		startPoint=stringIn.length-checkFor.length;
		tmp=stringIn.substr(0,checkFor.length);
		if(tmp==checkFor){
			output=stringIn.substr(checkFor.length,stringIn.length);}
		else{
			output=stringIn;}	
		return output;
	}else{
		return stringIn;}	
}
function popup(target,width,height) {
	default_width=600;
	default_height=400;
	if(!width){width=default_width;}
	else{
		width=parseInt(width);}
	if(!height){height=default_height;}
	else{
		height=parseInt(height);}
	if(width<1){width=default_width;}
	if(height<1){height=default_height;}
	link_loc=target.href;
	ext=get_file_extension(link_loc);
	ext=ext.toLowerCase();
	if(ext=='.jpg' || ext=='.jpeg' || ext=='.jpe' || ext=='.gif' || ext=='.png'){
		popwin = window.open("", new Date().getTime(), "width="+width+",height="+height+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
		popwin.document.open();
		popwin.document.write('<html><body style="margin:0px;padding:0px;">'); 
		popwin.document.write('<img src="'+link_loc+'"></body></html>'); 
		popwin.document.close();
		popwin.focus();
	}else{
		popwin = window.open(link_loc, new Date().getTime(), "width="+width+",height="+height+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");}
	popwin.focus();
    return false;
}
function get_file_extension(stringIn){ 
	var filename = stringIn; 
	if( filename.length == 0 ) return "";
	var dot = filename.lastIndexOf("."); 
	if( dot == -1 ) return ""; 
	var extension = filename.substr(dot,filename.length); 
	return extension; 
} 
function switchFormErr(tableOBJ,tableClass,divOBJ,divClass){
	if(typeof(tableOBJ)=='object' && basic_check(tableOBJ.tagName)){
		tableOBJ.className=tableClass;
	}else if(typeof(tableOBJ)=='string'){
		if(basic_check(document.getElementById(tableOBJ).tagName)){
			document.getElementById(tableOBJ).className=tableClass;}
	}
	if(typeof(divOBJ)=='object' && basic_check(divOBJ.tagName)){
		divOBJ.className=divClass;
	}else if(typeof(divOBJ)=='string'){
		if(basic_check(document.getElementById(divOBJ).tagName)){
			document.getElementById(divOBJ).className=divClass;}
	}
}
function getStyle(el,styleProp){
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
function getStyle_bd(el,styleProp){
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
Array.match = function(array){
	if(array.constructor==Array){
		var find_obj=new Object;
		var dup_found=false;
		for(var m_key in array){
			if(!find_obj[array[m_key]]){
				find_obj[array[m_key]]=1;
			}else{
				find_obj[array[m_key]]++;
				dup_found=true;
				break;
			}
		}
		return dup_found;
	}else{
		return false;
	}
};
