/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
var win;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
var req ;
var req_JScriptName="";
//
function CallWebPageAndExecuteJs(url, JScriptName){
	loadXMLDoc(url, JScriptName);
	//JScriptName should define a function that handles text
	//abc(textStr)
}
//
function loadXMLDoc(url, JScriptName) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		var  processReqChangeWrapper_ = new  processReqChangeWrapper();
		req_JScriptName = JScriptName;
		req.onreadystatechange =  processReqChangeWrapper_.myFuncProcessReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}	
//
function processReqChangeWrapper(){
	this.JScriptName_ ;
	this.myFuncProcessReqChange=processReqChange ;
		function processReqChange() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					// ...processing statements go here...
					//alert(req.responseXML());
					//alert(req.responseText);
					var resText  = req.responseText;
					var evalStr = req_JScriptName + '(resText)';
					eval( evalStr);
				} else {
					alert("There was a problem retrieving the XML data:\n" +
						req.statusText);
				}
			}
		}
}
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function NewPopUpWindowModal(mypage, myname, w, h, scroll) 
{
	var winl = 50;
	var wint = 20;
	var width = (screen.width - 100);
	var height = (screen.height - 100);
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',status=yes,toolbar=no,menubar=no,location=no,scrollbars='+scroll+',resizable=yes'
	win = window.showModalDialog(mypage, "DEDWIN" + myname, winprops)
	 //win.window.focus();
}
function LblEdit(fieldCode) 
{
	 var mypage = "../../Pages/Admin/GeneralRulesControlsUpdate.aspx?tab=25&HeaderLabelID=3025&SelectedIndex=1&SelectValueField=" + fieldCode + "&SelectedValueFieldName=SelectValueField&SelectedObjectIndex=CM_FLD##TOP";
	 //NewPopUpWindowModal(mypage, "EditLabel", 800, 600, "yes") ;
	NewPopUpWindow(mypage, "DEDWINEditLabel", 600, 600, "yes");
}
function HelpEdit(ScreenCode) 
{
	 var mypage = "../../Pages/Admin/GeneralRulesControlsUpdate.aspx?tab=25&HeaderLabelID=3025&SelectedIndex=2&SelectValueField=" + ScreenCode + "&SelectedValueFieldName=SelectValueField&SelectedObjectIndex=CM_SCRN_HELP";
	 //NewPopUpWindowModal(mypage, "EditLabel", 800, 600, "yes") ;
	NewPopUpWindow(mypage, "DEDWINEditLabel", 600, 600, "yes");
}
//-----------------------------------
function NewPopUpWindow(mypage, myname, w, h, scroll) 
{
	var winl = 50;
	var wint = 20;
	var width = (screen.width - 100);
	var height = (screen.height - 100);
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',status=no,toolbar=yes,menubar=no,location=no,scrollbars='+scroll+',resizable=yes'
	win = window.open(mypage, "DEDWIN" + myname, winprops)
	//win = window.showModalDialog(mypage, myname, winprops)
	//if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	 win.window.focus();
}
//-----------------------------------
function NewPopUpWindow_NO(mypage, myname, w, h, scroll) 
{
	var winl = 50;
	var wint = 20;
	var width = (screen.width - 100);
	var height = (screen.height - 100);
	winprops ="";
	win = window.open(mypage, "DEDWIN" + myname, winprops)
	//win = window.showModalDialog(mypage, myname, winprops)
	//if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	 win.window.focus();
}
/******************************************************/
function ChangeLanguage(){
	NewPopUpWindow("../../Anonymous/User/ChangeLang.aspx", "DEDWINChangeLanguage", 100, 150, "no");
}
/******************************************************/
function ShowEmp(urlStr){
	NewWindow2(urlStr, "DEDWINShowEmp", 500, 600, "yes");
}
/******************************************************/
function ShowRule(urlStr){
	NewWindow2(urlStr, "DEDWINShowrule", 500, 600, "yes");
}
/******************************************************/
function MuncpConflict(qry){
	var url = "../../Pages/Tradelicense/DispMunicpConflict.aspx?" + qry;
	//alert (url);
	NewWindow2(url, "DEDWINMuncpConflict", 650, 350, "yes");
}
/******************************************************/
function ShowProcRemove(){
	var url = "../../Pages/Tradelicense/RemoveTLProc.aspx";
	NewWindow2(url, "DEDWINRemoveProc", 500, 600, "yes");
}
/******************************************************/
function ShowInspRep(IPNO){
	//var CrystalReportPage =""; //is set in the basepage, read from the web.config
	NewWindow2( CrystalReportPage + '&repId=16&IPNO=' + IPNO , 'DEDReportWindow', 750, 500, 'yes', 10, 10);
}
/******************************************************/
function ShowPOPopUp(QryStrParam){
	//var CrystalReportPage =""; //is set in the basepage, read from the web.config
	NewWindow2( CrystalReportPage + QryStrParam);
}
/******************************************************/
function HiddenWindow(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.showModalDialog(mypage, myname, winprops);
}
/******************************************************/
function NewWindow2(mypage, myname, w, h, scroll,Left,Top) 
{
	winprops = 'height='+h+',width='+w+',top='+Top+',left='+Left+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, "DEDWIN" + myname, winprops);
	win.focus();
}
function NewWindow3(mypage, myname, w, h, scroll,Left,Top) 
{
	//does not reuse an open window
	winprops = 'height='+h+',width='+w+',top='+Top+',left='+Left+',scrollbars='+scroll+',resizable'
	var win3 = window.open(mypage, "DEDWIN" + myname, winprops);
	win3.focus();
}

/******************************************************/
function storeValues(DetailTxtbox, IDTxtbox, spanID, javascriptStr){
	try{
		var srcTxtBox = document.forms[0].elements[DetailTxtbox];
		var idBox = document.forms[0].elements[IDTxtbox];
		var txtBoxVal = srcTxtBox.value;
		if  (txtBoxVal.indexOf(",") > -1 ) {
			idBox.value = txtBoxVal.substr(0, txtBoxVal.indexOf(","));
			srcTxtBox.value = txtBoxVal.substr(txtBoxVal.indexOf(",") +1);
			try{
				document.getElementById(spanID).innerHTML = srcTxtBox.value;	
			}catch(e){
			}
		}
		if (javascriptStr.length > 0 ){
			eval(javascriptStr);
		}
	}catch(e){
	}
	try{
		//storeValuesCustom(DetailTxtbox, IDTxtbox, spanID, javascriptStr)
	}catch(e){
	}
}
/******************************************************/
function CleanCSV(txtBoxRef){
	var txt = txtBoxRef.value;
	var leadingComma = "^,";
	var endingComma = ",$";

	var reg = new RegExp( leadingComma);
	if (reg.test(txt)){
		if (txt.length > 1 ) {
			txt = txt.substr(1, txt.length-1);
		}
		else{
			txt = "";
		}
	}
	reg = new RegExp( endingComma);
	if (reg.test(txt)){
		if (txt.length > 1 ) {
			txt = txt.substr(0, txt.length-1);
		}
		else{
			txt = "";
		}
	}
	 txtBoxRef.value = txt;
}
/******************************************************/
// function Added  by Mubarak
//Winpopup -- Argument ( URL, WindowName, Features)
function WinPopUp () {
var winPopup; var strHREF; var bNewWindow; var arg1 = WinPopUp.arguments; var strValues;
if (arg1.length >=1 ) strURL = arg1[0];
else strURL = "";
if (arg1.length >=2 ) strWinName = arg1[1];
else strWinName = "_blank";
if (arg1.length >= 3 ) strValues=arg1[2];
else strValues="width=450,height=300,scrollbars=yes,dependent=yes";
winPopup = window.open(strURL, "DEDWIN" + strWinName, strValues);  
return winPopup;
}
//
//Function to validate the character.
function validvalue(objName,validchars,casesensitive)
{
var txt = objName; var txtvalue = txt.value; var arg1 = validvalue.arguments
 validchars = validchars + unescape("%0D%0A")
if (casesensitive!=1)
  {txtvalue=txtvalue.toUpperCase(); validchars=validchars.toUpperCase(); }

if  ((txtvalue.substr(0,1)==".")||(txtvalue.substr(0,1)=="/"))    
	{
		return(false);
	}
charposn=0;
	while ((charposn<txtvalue.length)&&(validchars.indexOf(txtvalue.charAt(charposn))!=- 1))
	{  charposn++;	}
	if (charposn==txtvalue.length)
	{ return(true); } 
	else 
	{ if(arg1.length < 4)
	  return(false);
	}
}
/******************************************************/
function copyEngTN(txtBox){
	try{
		var srcTB = window.opener.getEngTN();
		var destTB = document.getElementById("SearchList1_TRAD_NM_E");
		var destVal = destTB.value + "";
		if(destVal.length < 2 ){
			if(srcTB.length > 1){
				destTB.value = "/" + srcTB + "/";
			}
		}
	}catch(e){
	}	
}
function copyArTN(txtBox){
	try{
		var srcTB = window.opener.getArTN();
		var destTB = document.getElementById("SearchList1_TRAD_FLTR_NM");
		var destVal = destTB.value + "";
		if(destVal.length < 2 ){
			if(srcTB.length > 1){
				destTB.value = "/" + srcTB + "/";
			}
		}
	}catch(e){
	}
}
function PrsnTB(prsnNr){
	var srcTB = window.opener.setPrsn(prsnNr);
	window.self.close();
}
function setPrsn(prsnNr){
	var destTB = document.getElementById("SearchList1_prsn_srl_no");
	destTB.value = prsnNr;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
/******************************************************/



