var jhcs_blankPage = "/public/site/blank/";

function getAspForm() {
	theForm = document.forms['frmjhcs'];
	if (!theForm) { theForm = document.aspnetForm; }
	return theForm;
}

function jhcs_PostBack2(eventTarget, eventArgument, skipValidation, target) {

	if (!theForm) { getAspForm(); }
	if ( !skipValidation ) {
		if( typeof(jhcs_ValidatorOnSubmit) == "function" ) if ( false == jhcs_ValidatorOnSubmit( eventTarget, eventArgument ) ) return; 
	}
	
	theForm.csf_eventTarget.value = eventTarget;
    theForm.csf_eventArgument.value = eventArgument;	

	var originalTarget = theForm.target;
	if ( target ) {
		theForm.target = target;
		var newWindow = jhcs_openSubmitWindow( target );
		window.status = 'target=' + theForm.target ;
	}

	theForm.submit();
	
    theForm.target = originalTarget;
	
}

function jhcs_PostBack(eventTarget, eventArgument, target) {
	jhcs_PostBack2( eventTarget, eventArgument, false, target );
}

function jhcs_Postback4Print ( eventTarget, eventArgument, target ) {
	if (!theForm) { getAspForm(); }
	var v;
	v = document.getElementById( 'jhcs_p_v' );
	if ( v ) { v.value = "printer"; }
	
	theForm.csf_isPrinter.value = "printer";
	jhcs_PostBack(eventTarget, eventArgument, target);
	theForm.csf_isPrinter.value = "";
	if ( v ) { v.value = ""; }
}

function jhcs_openSubmitWindow ( t ) {
	var options = "";
	
	function addOption(option) {  if(options != "") { options += ","; } options += option; }
	addOption("toolbar=0");
	addOption("location=0");
	addOption("status=1");
	addOption("scrollbars=1");
	addOption("menubar=1");
	addOption("resizable=1");
	
	var newWindow = window.open( jhcs_blankPage, t, options );
	return newWindow;
}

function jhcs_Popup(url, naked, width, height,elastic) {
	var options = "";
	
	function addOption(option) { if(options != "")  { options += ","; } options += option; }
	
	if(width) { addOption("width=" + width); }
	if(height) { addOption("height=" + height); }
	
	if(naked) {
		addOption("toolbar=0");
		addOption("location=0");
		addOption("status=0");
		addOption("menubar=0");
		if (elastic) { 
			addOption("resizable=1");
			addOption("scrollbars=1");
		} else {
			addOption("resizable=0");
			addOption("scrollbars=0");
		}
	} else {
		addOption("toolbar=1");
		addOption("location=1");
		addOption("status=1");
		addOption("scrollbars=1");
		addOption("menubar=1");
		addOption("resizable=1");
	}
	
	var newWindow = window.open(url,"",options)
}