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){//,debug
	if(!findTag || !basic_check(findTag)){findTag='*';}
//if(!debug){debug=false;}
	var count=0;
	var foundObj=false;
	var limit=10;
	var parentObj=false;
	do{
		if(!parentObj){parentObj=obj;}
		parentObj=parentObj.parentNode;
		tmpName=parentObj.tagName;
		if(tmpName && findTag=='*'){findTag=tmpName;}
//if(debug==true){alert('findTag: ' + findTag +' |||| '+tmpName);}
		count++;
		if(tmpName.toLowerCase()=='html'){break;}
	}while(tmpName.toLowerCase()!=findTag.toLowerCase() && count<=limit)// && count<=100
	if(tmpName.toLowerCase()==findTag.toLowerCase()){foundObj=parentObj;}
	//if(count==limit){alert('xxx');}
	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 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 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 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;
}

function onOffCheck(theLayer, effectLayer, force){
	if(force=="block"){
		if(document.getElementById(effectLayer)){document.getElementById(effectLayer).innerHTML="&#9472;";}
		document.getElementById(theLayer).style.display="block";
	}else if(document.getElementById(theLayer).style.display=="block" || force=="none"){
		if(document.getElementById(effectLayer)){document.getElementById(effectLayer).innerHTML="+";}
		document.getElementById(theLayer).style.display="none";
	}else{
		if(document.getElementById(effectLayer)){document.getElementById(effectLayer).innerHTML="&#9472;";}
		document.getElementById(theLayer).style.display="block";
	}
}
function applyCheckboxReveal(boolItem,effectString,defaultClass,falseClass){
	if(boolItem){
		document.getElementById(effectString).className=defaultClass+' '+falseClass;
	}else{
		document.getElementById(effectString).className=defaultClass;
	}
}
function applyRadioRevealYesNo(obj,effectString,defaultClass,revealClass){
	var formOBJ=get_parent(obj,'form');
	var formName=formOBJ.name;
	val=getRadioValue(document.forms[formName].elements[obj.name]);
	if(val=="YES"){
		document.getElementById(effectString).className=defaultClass;
	}else if(val=="NO"){
		document.getElementById(effectString).className=defaultClass+' '+revealClass;
	}else{
		document.getElementById(effectString).className=defaultClass;
	}
}
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;
	}
};
function in_array(needle, haystack, argStrict) {//http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_in_array/
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true
    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
 
    var key = '', strict = !!argStrict;
 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
 
    return false;
}
