// JavaScript Document Ver 1.0 - Created on May 20 2005 for SIS Format check by Padma
function fncCheckOtherSISFormat(sisval,filetype)
{
	var localsisval = trim(sisval);
	if(filetype != "")
	{
		session.setAttribute('sisnumber',document.sisform.sis.value);
		var s = filetype + ".html?itemNo=" + itemNo + "&sisnumber=" + document.sisform.sis.value;
		window.location.href = s;
		var rightframeerrname = "SIS-Serch.html";
		return true;	
	}	
}
function getMenuListIndex(itemNo){
	var menuItemNo = itemNo;
	for(var i=0;i<menuList.length;i++){
		if(menuItemNo==menuList[i].itemNo){
		return i;
		}
	}
}
//function to check the SIS format before proceeding with search in DB/XML from Main Menu / Sub Menu pages
function fncCheckSISFormat(sisval,filetype)
{
	var localsisval = sisval;
	var flag = true;
	if(trim(localsisval).length < 18)
		flag = false;
	/*
	else
	{
		var condition = "abmtyABMTY";
		if(condition.indexOf(localsisval.charAt(0)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}	
		
		//Upper case char check
		condition = "localsisval.substring(1,3)  == 'AW' || localsisval.substring(1,3)  == 'DK' || ";
		condition += "localsisval.substring(1,3)  == 'DA' || localsisval.substring(1,3)  == 'DL' || ";
		condition += "localsisval.substring(1,3)  == 'LF' || localsisval.substring(1,3)  == 'LJ' || ";
		condition += "localsisval.substring(1,3)  == 'WS'";
		//Lower case char check
		condition += " || localsisval.substring(1,3)  == 'aw' || localsisval.substring(1,3)  == 'dk' || ";
		condition += "localsisval.substring(1,3)  == 'da' || localsisval.substring(1,3)  == 'dl' || ";
		condition += "localsisval.substring(1,3)  == 'lf' || localsisval.substring(1,3)  == 'lj' || ";
		condition += "localsisval.substring(1,3)  == 'ws'";
		flag = eval(condition)?true:false;
		if(flag == false)
		{
			//alert("Please enter a valid SIS Number");
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
		
		condition = "abcdnpABCDNP";
		if(condition.indexOf(localsisval.charAt(3)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}	
		
		condition = "glrGLR";
		if(condition.indexOf(localsisval.charAt(4)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
			
		condition = "abcdefgABCDEFG";
		if(condition.indexOf(localsisval.charAt(5)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}	
		
		condition = "abcdnfzABCDNFZ";
		if(condition.indexOf(localsisval.charAt(6)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}	
		
		//Upper case char check
		condition = "localsisval.substring(7,10) == 'B15' || localsisval.substring(7,10) == 'C24' || ";
		condition += "localsisval.substring(7,10) == 'E51' || localsisval.substring(7,10) == 'K12' || ";
		condition += "localsisval.substring(7,10) == 'T30' || localsisval.substring(7,10) == 'Y34' || ";
		condition += "localsisval.substring(7,10) == 'Z11'";
		//Lower case char check
		condition += " || localsisval.substring(7,10) == 'b15' || localsisval.substring(7,10) == 'c24' || ";
		condition += "localsisval.substring(7,10) == 'e51' || localsisval.substring(7,10) == 'k12' || ";
		condition += "localsisval.substring(7,10) == 't30' || localsisval.substring(7,10) == 'y34' || ";
		condition += "localsisval.substring(7,10) == 'z11'";
		flag = eval(condition)?true:false;
		if(flag == false)
		{
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
		
		
		condition = "einpstEINPST";
		if(condition.indexOf(localsisval.charAt(10)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
			
		condition = "dgmnuvzDGMNUVZ";
		if(condition.indexOf(localsisval.charAt(11)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
			
		condition = "hjHJ";
		if(condition.indexOf(localsisval.charAt(12)) == -1){
			alert(getMessage("MMSMS_InvalidSIS"));
			document.sisform.sis.focus();
			return false;
		}
	
	}
	*/
	if(flag == false)
	{
		alert(getMessage("MMSMS_InvalidSIS"));
		document.sisform.sis.focus();
		//parent.frameMainRight.location.href = "../pages/error/SIS-Serch.html";
		return "InvalidSis";
	}
	else
	{
		var rightframeerrname = "error/SIS-Serch.html";
		var menuSearch = new Array();
		var dm = application.getAttribute("DATAMANAGER");
		menuSearch = getMenuData(session.getAttribute("itemNo"))		
		//var nq = new NamedQuery("GET_MANUAL_SIS");		
		var nq = new NamedQuery("GET_SIE_WITH_MENUITEM_SISNO");
		nq.params["sisno"] = sisval;
		nq.params["menuitemarray"] = menuSearch;
		var menuarray=new Array();
		var dbData = menuarray;
		var rs = dm.executeNamedQuery(nq);
		if(rs.rowCount==0)
		{
			if(filetype != "")
			{
			fncDispResultsInRightFrame(dbData, rightframeerrname);
			return false;
			}else
			{
				return false;
			}
		}else if(filetype != "")
		{
			itemNo = session.getAttribute("itemNo");
			var rightframeerrname = entranceList[getMenuListIndex(itemNo)];
			session.setAttribute('sisnumber',document.sisform.sis.value);
			if(dbData.length == 0)
				parent.frameMainRight.location.href = rightframeerrname;
			var s = filetype + ".html?itemNo=" + itemNo + "&sisnumber=" + document.sisform.sis.value;
			window.location.href = s;
			//var rightframeerrname = "SIS-Serch.html";
			return true;	
		}	
		return true;
	}	
/*"	Check if 1st character in the sisno is 'A'/'B'/'E'/'G'/'M'/'T'/'Y'
"	Check if the 2nd and 3rd characters are a combination of "AW"/"DK"/"DA"/"DL"/"LF"/"LJ"/"WS"
"	Check if the 4TH character is 'A'/'B'/'C'/'D'/'N'/'P'
"	Check if the 5th character is 'G'/'L'/'R'
"	Check if the 6th character is 'A'/'B'/'C'/'D'/'E'/'F'/'G'
"	Check if the 7th character is 'A'/'B'/'C'/'D'/'F'/'N'/'Z'
"	Check if the 8th, 9th and 10th characters are a combination of "B15"/"C24"/"E51"/"K12"/"T30"/"Y34"/"Z11"
"	Check if the 11th character is 'E'/'I'/'N'/'P'/'S'/'T'
"	Check if the 12th character is 'D'/'G'/'M'/'N'/'U'/'V'/'Z'
"	Check if the 13th character is 'H'/'J'
"	Check for alphanumeric characters for the characters between 14th and 18th positions
aawagaab15edh12355
*/
}
//Function to reset the SIS number in the screen as well clear the SIS search in the contents tree
function fnresetSIS(thisimg, filetype)
{
  if(thisimg.name=='btnSIS_Clear') {
	document.sisform.sis.disabled=false;
	document.sisform.sis.value="";
	session.setAttribute('sisnumber','');
	thisimg.src="../images/SIS_Search.jpg";
	thisimg.name="btnSIS_Search";
/*Added on 2005/12/13 for VIN-SIS issue*/
	session.setAttribute('vin','');
	//parent.frameHeader.fncGetVIN("");
/**/
  }
	//Added when returning back to the initial screen display on clearing the SIS search criteria.
	//if(parseInt(itemNo)<10 && itemNo.toString().substring(0,1) == "0")
	//	itemNo = itemNo.substring(1,itemNo.length);
	//itemNo = parseInt(itemNo);
	parent.frameMainRight.location = entranceList[getMenuListIndex(itemNo)];
	parent.frameMainLeft.location = filetype + ".html?itemNo=" + itemNo + "&sisnumber=" + document.sisform.sis.value;
  //window.location.href = filetype + ".html?itemNo=" + itemNo + "&sisnumber=" + document.sisform.sis.value;
	
}

