

function _cs_ClickOnEnter(btnName, e) {
	if (!e) e = window.event;
	if (!e) return;
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
		var btn = document.getElementById(btnName);
		if (btn) {
			e.returnValue = false;
			e.cancel = true;
			if (btn.click) {
				btn.click();
			}
			else {
				var executeAction = true;
				if (btn.onclick) executeAction = btn.onclick({type: 'click'});
				if (executeAction) open(btn.href, btn.target ? btn.target : '_self');
			}
		}
	}
}

function comboBox_KeyPress(comboBox, eventArgs, string ,sButtonID) {
    if (eventArgs.get_domEvent().keyCode && eventArgs.get_domEvent().keyCode == 13) {
        var button = document.getElementById(sButtonID);
        if (button) button.click();
    }
}

function getBrowser() {
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("chrome") != -1) return 'Chrome';
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
		if (agt.substr(0, agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0, agt.indexOf('\/'));
		}
		else return 'Netscape';
	} else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0, agt.indexOf(' '));
	else return navigator.userAgent;
}

function ShowPopUpWindow(pWidth, pHeight, pURL, pTitle, pID, pAutoSize) {
	
	// javascript:ShowPopUpWindow(<Initial Height>,<Initial Width>,'<URL>','<Windows Title>','<Window Name>'); return false;";

	var myWidth = 0, myHeight = 0;
	if (typeof (window.innerWidth) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	var oWnd = 	window.radopen(pURL,pID); //Opens the window
	oWnd.add_close(OnPopUpClose);
	oWnd.set_modal(true);
	oWnd.set_width(pWidth);
	oWnd.set_height(pHeight);
	oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
	oWnd.set_title(pTitle);
	oWnd.set_visibleStatusbar(false);
	oWnd.MoveTo((myWidth / 2) - (pWidth / 2), (myHeight / 2) - (pHeight / 2));

/*	if (pAutoSize && (pAutoSize == true || pAutoSize == 'true')) {
		oWnd.autoSize(true);
	}
*/	
}

function OnPopUpClose(oWnd) {
	oWnd.setUrl("about:blank"); 
	oWnd.remove_close(OnPopUpClose); 
}      






function GetRadWindow() {
	var oWindow = null;
	if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including classic dialog
	else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
	return oWindow;
}

function closeParentWindow() {

	if (getBrowser() == "Internet Explorer") {
		window.parent.window.opener = null;
		window.parent.window.close();
	} else if (getBrowser() == "Firefox") {
		top.window.opener = top;
		top.window.open('', '_parent', '');
		top.window.close();
	}
} 
	
function GetURLParameter( name )
{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
		return "";
	  else
		return results[1];
}

function loadJavaApp(name) {


/*
			document.write('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" id="' + name + '" WIDTH ="1" HEIGHT ="1"  codebase="https://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#Version=1,6,0,mn"	mayscript="mayscript">');
			document.write('<PARAM NAME = CODE VALUE = "com.web.print.applet.WebPrintApplet.class" >');
			document.write('<PARAM NAME = CODEBASE VALUE = "." >');
			document.write('<PARAM NAME = ARCHIVE VALUE = "/_kc_java/applet.jar" >');
			document.write('<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4">');
			document.write('<PARAM NAME="scriptable" VALUE="true">');
			document.write('<param name="mayscript" value="mayscript">');
			document.write('<param name="success_message" value="Spool Completed Successfully">');
			document.write('<param name="reprint_error" value="This coupon has already been printed">');
			document.write('<COMMENT>');
			document.write('<EMBED type="application/x-java-applet;version=1.3" id="' + name + '" CODE = "com.web.print.applet.WebPrintApplet.class" CODEBASE = "." ARCHIVE = "/_kc_java/applet.jar" WIDTH ="1" HEIGHT ="1" success_message = "Spool Completed Successfully" reprint_error="This coupon has already been printed" scriptable="true" pluginspage="https://java.sun.com/update/1.6.0/jre-6-windows-i586.xpi#Version=1,6,0,mn" mayscript="mayscript">');
					document.write('<NOEMBED>');
						document.write('<h2>java not found in your browser.</h2>');
					document.write('</NOEMBED>');
				document.write('</EMBED>');
			document.write('</COMMENT>');
			document.write('</OBJECT>');

*/



	if (getBrowser() == 'Internet Explorer') {
		document.write('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" id="' + name + '" width="1" height="1">',
                   '<PARAM name="code" value="com.web.print.applet.WebPrintApplet.class">',
                   '<PARAM name="archive" value="/_kc_java/applet.jar">',
                   '<PARAM name="mayscript" value="true">',
                   '</object>');
	}
	else {
		document.write('<embed code="com.web.print.applet.WebPrintApplet.class" archive="/_kc_java/applet.jar" mayscript="true" id="' + name + '" width="1" height="1" type="application/x-java-applet">');
	}
	

}

