//Common function 

ns4 = (document.layers)? true:false;
ns6 = (document.getElementById)? true:false;
ie4 = (document.all)? true:false;
if (ie4 == true){
	ns6=false;
}

var formswitch = "null";


var submitted = false;

function submitonce() {
    if (submitted) {
        return false;
    } else {
        submitted = true;
        return true;
    }
}


// control form	buttons	EXtended
function formdirectEX(task, formName, hiddenName, formAction) {
	theField = eval("document." + formName + "." + hiddenName);
	if(task == "cancel"){
		theField.value = formAction;
		document.forms[formName].submit();
	}
	if(task == "reset"){
		theField.value = formAction;
		formswitch="reset";
		/*resetToEmptyString(document.forms[formName]);*/
		document.forms[formName].reset();
	}
	if(task == "send"){
		theField.value = formAction;
		document.forms[formName].submit();
	}
}



//create URI
function createFlashVerLink(uriVar){
    	var newUri = uriVar;
        newUri = uriVar + flashVersion;
		newUri = newUri + "&shockwaveVersion=";
		newUri = newUri + shockwaveVersion;
    	window.location.href = newUri;
   	}


// Utility function to perform global find and replace on a string
function replaceAll(oldStr,findStr,repStr) {
	var newStr = "";
	var srchNdx = 0;
	while (oldStr.indexOf(findStr,srchNdx) != -1) {
		newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
		newStr += repStr;
		srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
	}
	newStr += oldStr.substring(srchNdx,oldStr.length);
	return newStr;
}

// Undo the result of the filter function used by <bean:write>
function reverseFilter(s) {
	s = replaceAll(s, "&lt;", "<");
	s = replaceAll(s, "&gt;", ">");
	s = replaceAll(s, "&amp;", "&");
	s = replaceAll(s, "&quot;", "\"");
	return s;
}


    function popWindowTC(url, height, width) {
            var optionListing = "HEIGHT="+height+",WIDTH="+width+",innerHeight="+height+",innerWidth="+width+",left=50,top=15,channelmode=0,dependent=no,directories=no,fullscreen=0,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,screenX=10,screenY=20,menubar=yes"
            remote = window.open(url,"PopupTC",optionListing);
            if (remote != null) {
                    remote.focus();
            }
    }

    function popWindowPP(url, height, width) {
            var optionListing = "HEIGHT="+height+",WIDTH="+width+",innerHeight="+height+",innerWidth="+width+",left=50,top=15,channelmode=0,dependent=no,directories=no,fullscreen=0,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,screenX=10,screenY=20,menubar=yes"
            remote = window.open(url,"PopupPP",optionListing);
            if (remote != null) {
                    remote.focus();
            }
    }
    
