
//defining constants
var color1
var errorMessage;
var formName="";
var selectedLinkTab

cstLinkTabColor1='#FEDA9C'
cstLinkTabColor2='#FEA108'
cstLinkTabColor3='#FEA108'
cstSelectedLinkTabColor='#FEA108'

cstTableBorderBottom='1px solid #C2C2C2'
cstTableTrOverColor='#f6e8e7'
cstTableTrDefaultColor='#000066'

fVal=new Array();
pfv=new Array();


function getFieldName(x){
	if(x.alt!=null) 
		if (x.alt!='')return x.alt
		else return breakCase(x.name)
	else return breakCase(x.name)
}


//0 blank validation
//1 text validation
//2 number validation
//3 text and blank validation
//4 number and blank validation
//5 email validation
//6 email and blank validation
//7 misc validation
//8 Login Name validation
//9 password validation
function formValidation(srcForm){
	var i;
	errorFields=""; 
	msg=""; 
	var flg;
	flg=true
	for (i=0;i<srcForm.elements.length; i++ ){
	status=srcForm.elements[i].name
	//srcForm.elements[i].style.border='1px solid #00387f'
	//Blank Validation
		if(srcForm.elements[i].id=="0") {
//			alert()
			if(!blankVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" cannot be left blank";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Text Validation
		if(srcForm.elements[i].id=="1") {
			if(!charVal(srcForm.elements[i].value)){
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can have only text values";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//number Validation
		if(srcForm.elements[i].id=="2") {
			if(!numVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can have only numeric values";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Blank and Text Validation
		if(srcForm.elements[i].id=="3") {
			if(!blankVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" cannot be left blank";
				errorFields+=i+", ";
				flg=false;
			}

			if(!charVal(srcForm.elements[i].value)){
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can have only text values";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Blank and Number Validation
		if(srcForm.elements[i].id=="4") {
			if(!blankVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can have only text values";
				errorFields+=i+", ";
				flg=false;
			}

			if(!numVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can have only numeric values";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Email Validation
		if(srcForm.elements[i].id=="5") {
			if(!emailVal(srcForm.elements[i].value)){
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" is not Valid Email Address";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Blank and Email Validation
		if(srcForm.elements[i].id=="6") {
			if(!blankVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can not be blank";
				errorFields+=i+", ";
				flg=false;
			}

			if(!emailVal(srcForm.elements[i].value)){
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" is not Valid Email Address";
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Misc Validation
		if(srcForm.elements[i].id=="7") {
			if(!eval(srcForm.elements[i].title)){
				errorFields+=i+", ";
				flg=false;
			}
		}

	//Login name Validation
		if(srcForm.elements[i].id=="8") {
			if(!blankVal(srcForm.elements[i].value)) {
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" can not be blank";
				errorFields+=i+", ";
				flg=false;
			}

			if(!loginVal(srcForm.elements[i].value)){
				msg+="\n  - "+getFieldName(srcForm.elements[i])+" is not valid";
				errorFields+=i+", ";
				flg=false;
			}
		}


	}

	if(!flg){
		alert("Following error(s) have occured\n-----------------------------------------                           "+msg);
		sl1=(removeTail(errorFields)).split(", ");

		for(i=0;i<sl1.length;i++){
			srcForm.elements[sl1[i]].style.border='1px solid #ff0000';
		}

//		srcForm.elements[sl1[0]].focus();
	}
			
	return flg;

}


function emailVal(theVal){
	if (theVal != "" ){
		if(theVal.indexOf('@')>1 && theVal.indexOf('.')>1 && theVal.indexOf('.')<theVal.length-2 && theVal.indexOf('@.')<0) return true;
		else return false;
	}
	else{
		return true
	}
}


function overEffect(obj){
		if(event.type=='mouseover' || event.type=='onfocus'){
			obj.style.backgroundColor=cstLinkTabColor2;
			obj.style.cursor='hand';
			style='filter:alpha(opacity=100)'
		}
		else{
			if(event.type=='mouseout'){
					obj.style.backgroundColor='';
					obj.style.cursor='default'
					style='filter:alpha(opacity=60)'
			}

			if(event.type=='mousedown'){
					obj.style.backgroundColor=cstLinkTabColor3;
					obj.style.cursor='default'
			}

			if(event.type=='mouseup'){
					obj.style.backgroundColor=cstLinkTabColor1;
					obj.style.cursor='default';
			}
		}
}

function getMWheel(){
	if(event.wheelDelta >=120 ){
		linkTabDisplay('leftLink')		
	}
	else{
		linkTabDisplay('rightLink')
	}
}

function populateInnerLinks(linkWidth, linkNames, linkHREF, overRideLinkColumnWidth){
	var tw;
	var i;
	//selectedLinkTab;
	selectedLinkTab=0;

	linkNames=linkNames.split(",");
	linkHREF=linkHREF.split(",");

	linkColumnWidth=700
	if(screen.width==800) linkColumnWidth=420; //add if condition for screen width here
	if(overRideLinkColumnWidth=='undefined') alert(overRideLinkColumnWidth); //this will override the value set for link width here in the function

	linksTabToShow=parseInt(linkColumnWidth/linkWidth);
	
	thisLinkHREF=(location.href).split("/");
	thisLinkHREF=thisLinkHREF[thisLinkHREF.length-1];
	thisLinkHREF=thisLinkHREF.split("&");
	thisLinkHREF=thisLinkHREF[0];
	
	
	tw="<table cellspacing='1' cellpadding='4' height='25' class='lt1' border='0' onmousewheel=getMWheel();>";
	tw+="<tr align=center>";

	tw+="<td id=scrollLinks style='display:none;cursor:hand' disabled bgcolor='"+cstLinkTabColor1+"' width='10' onmousewheel=\"linkTabDisplay('leftLink');\"  onclick=\"linkTabDisplay('leftLink');\"  onmouseover='overEffect(this)' onmousedown='overEffect(this)' onmouseout='overEffect(this)' onmouseup='overEffect(this)'><a class=lt1 style='font-family:wingdings;' >ç</a></td>";
	
	hideBlock="";
	for(i=0;i<linkNames.length;i++){
		if(i+1>linksTabToShow) hideBlock=" style='display:none' ";
		
		linkHREFsl1 = linkHREF[i].split("&");
		linkHREFsl1 = linkHREFsl1[0];
		
		if(trim(thisLinkHREF)==trim(linkHREFsl1)){
			tw+="<td bgcolor='"+cstSelectedLinkTabColor+"' id=linkTab width='"+linkWidth+"' "+hideBlock+" onclick=\"location.href='"+linkHREF[i]+"'\" onmouseover='overEffect(this)' onmousedown='overEffect(this)' onmouseout='overEffect(this)' onmouseup='overEffect(this)' ><a href='"+linkHREF[i]+"' class=lt1 style=color:#ffffff>"+linkNames[i]+"</a></td>";
			selectedLinkTab=i+1;
		}
		else{
			tw+="<td bgcolor='"+cstLinkTabColor1+"' id=linkTab width='"+linkWidth+"' "+hideBlock+" onclick=\"location.href='"+linkHREF[i]+"'\" onmouseover='overEffect(this)' onmousedown='overEffect(this)' onmouseout='overEffect(this)' onmouseup='overEffect(this)' style='filter:alpha(opacity=90)'><a href='"+linkHREF[i]+"' class=lt1 style=color:#000000>"+linkNames[i]+"</a></td>";
		}
	}
	
	hideBlock=" style='display:none' ";

	if(linkNames.length>linksTabToShow)
		hideBlock=""
	
	tw+="<td style='cursor:hand' id=scrollLinks "+hideBlock+" bgcolor='"+cstLinkTabColor1+"' width='10' onmousewheel=\"linkTabDisplay('rightLink');\"  onclick=\"linkTabDisplay('rightLink');\"  onmouseover='overEffect(this)' onmousedown='overEffect(this)' onmouseout='overEffect(this)' onmouseup='overEffect(this)'><a class=lt1 style='font-family:wingdings;' >è</a></td>";
	tw+="</tr></table>";
	 
	document.all.linkColumn.innerHTML=tw
	if (linkNames.length>linksTabToShow){
		scrollLinks[0].style.display='block'
		scrollLinks[0].onclick=function(){linkTabDisplay('leftLink');}
	}
	
	if(selectedLinkTab>linksTabToShow){
		for(j=0;j<selectedLinkTab-linksTabToShow;j++)
			linkTabDisplay('rightLink')
	}
	
}


//This function is required by populateInnerLinks function which make implicit calls
function linkTabDisplay(whichLink){

	//if there is no scroll links at all then don't run this function
	if (scrollLinks[0].style.display=='none'){
		return
	}


	var i;
	if(scrollLinks[1].disabled==false){
		if(whichLink=='rightLink'){
			for(i=0;i<linkTab.length;i++)
					if(linkTab[i].style.display!='none') break;

			linkTab[i].style.display='none';

			for(i=i+1;i<linkTab.length;i++)
				if(linkTab[i].style.display=='none') break;

			linkTab[i].style.display='block';

			scrollLinks[0].disabled=false;

			if(i+1==linkTab.length) scrollLinks[1].disabled=true;
		}
	}

	if(scrollLinks[0].disabled==false){
		if(whichLink=='leftLink'){

			for(i=0;i<linkTab.length;i++)
					if(linkTab[i].style.display!='none')
						break;
			i=i-1;
			
			linkTab[i].style.display='block';
			if(i==0) scrollLinks[0].disabled=true;

			for(i=i+1;i<linkTab.length;i++)
				if(linkTab[i].style.display=='none')
					break;
			
			linkTab[i-1].style.display='none';
			scrollLinks[1].disabled=false;
		}
	}
}


/*
function createLinkTab(linkWidth, linkNames, linkHREF, columnName){
	
	var tw;
	linkNames=linkNames.split(",");
	linkHREF=linkHREF.split(",");


	tw="<table cellspacing='1' cellpadding='4' height='20' class='lt2' border='0'>"
	tw+="<tr align=center>"
	//tw+="<td bgcolor='#1E3A65'>&nbsp; sdfg</td>"

	
	for(i=0;i<linkNames.length;i++)
		tw+="<td bgcolor='#1E3A65' width='"+linkWidth+"' onclick=\"location.href='"+linkHREF[i]+"'\" onmouseover='overEffect(this)' onmousedown='overEffect(this)' onmouseout='overEffect(this)' onmouseup='overEffect(this)'>"+linkNames[i]+"</td>"

	tw+="</tr></table>"
	eval("document.all."+columnName+".innerHTML=tw")
}

*/

function csv(formName, comboName, theValue){
	var theObj="document."+formName+"."+comboName
	for(var i=0;i<eval(theObj+".length");i++){
		if (eval(theObj).options[i].value==theValue){
			eval(theObj).selectedIndex=i;
			break;
		}
	}
}

function applyTableFormat(tableName, formatId){
	tableProperties=new Array("border=0 cellPadding=4 className=t1", "cellSpacing=1 cellPadding=4 bgColor=#e6e6e6 className=t1", "")
	headingProperties=new Array("", "bgColor=#f8f8e3 class=h1", "")
	cellsProperties=new Array("", "bgColor=#ffffff class=t1", "")
	mouseOverColor=new Array("#f6f6f6", "")

	tableProperties=(tableProperties[formatId]).split(" ");
	headingProperties=(headingProperties[formatId]).split(" ");
	cellsProperties=(cellsProperties[formatId]).split(" ");
	
	for(var i=0;i<tableProperties.length;i++){
		fs1=tableProperties[i].split("=")
		eval('document.all.'+tableName+'.setAttribute("'+fs1[0]+'", "'+fs1[1]+'")')
	}

	for(var i=0;i<headingProperties.length;i++){
		fs1=headingProperties[i].split("=")
		eval('document.all.'+tableName+'.rows[0].setAttribute("'+fs1[0]+'", "'+fs1[1]+'");')
	}

	for(var i=0;i<cellsProperties.length;i++){
		fs1=cellsProperties[i].split("=")
		for(j=1;j<eval('document.all.'+tableName+'.rows.length');j++){
			eval('document.all.'+tableName+'.rows[j].setAttribute("'+fs1[0]+'", "'+fs1[1]+'");')
		}
	}
}

function executeASPCommand(code, variables, values){
	variables=variables.split(',');
	values=values.split(',');
	var queryString;

	queryString="?uwCode="+code+"&";

	for(var i=0;i<variables.length;i++)
			queryString=queryString+trim(variables[i])+"="+trim(values[i])+"&";

	queryString=queryString.substr(0, queryString.length-1);

	
	utilityWindow.location.href="utilityWindow.asp"+queryString;
}

function trim(theValue){
	//alert(theValue.length)
	if(theValue!=""){
		if(theValue.indexOf(" ")==0){
			//recurse this function in case the first character of string is a space
			theValue=theValue.substr(1, theValue.length)
			trim(theValue)
		}
		
		if (theValue.lastIndexOf(" ")==(theValue.length-1)){
			//recurse this function in case the first character of string is a space
			theValue=theValue.substr(0,theValue.length-1);
			trim(theValue);
		}
	}	
	return theValue;
}

function openWindow(fileName,windowSize){
	if(screen.width>=1024){
		if(windowSize==1) newx2=window.open(fileName, "newx2","status=1, height=300, width=400, left=250, top=180, scrollbars, toolbars=yes ")
		if(windowSize==2) newx2=window.open(fileName, "newx2","height=620, width=656, left=150, top=50, status, scrollbars ")
		if(windowSize==3) newx2=window.open(fileName, "newx2","height=216, width=398, left=10, top=10,  status")
		if(windowSize==4) newx2=window.open(fileName, "newx2","status=1 height=600 width=900 left=50 top=50 scrollbars center=yes")
	}
	else{
		if(windowSize==1) newx2=window.open(fileName, "newx2","height=480 width=470 left=150 top=10 status scrollbars  center=yes")
		if(windowSize==2) newx2=window.open(fileName, "newx2","height=370 width=650 left=70 top=120 status scrollbars")
		if(windowSize==3) newx2=window.open(fileName, "newx2","height=280 width=450 left=10 top=10  status")
		if(windowSize==4) newx2=window.open(fileName, "newx2","height=480 width=770 left=10 top=40 status scrollbars  center=yes")
	}

}

function openWindow1(fileName,windowSize,winName){
	if(screen.width==1024){
		if(windowSize==1) newx2=window.open(fileName, winName,"status=1, height=620, width=720, left=100, top=50, scrollbars ")
		if(windowSize==2) newx2=window.open(fileName, winName,"height=370 width=650 left=150 top=230 status scrollbars ")
		if(windowSize==3) newx2=window.open(fileName, winName,"height=350 width=480 left=10 top=10  status")
		if(windowSize==4) newx2=window.open(fileName, winName,"status=1 height=480 width=470 left=250 top=150 scrollbars center=yes")
	}
	else{
		if(windowSize==1) newx2=window.open(fileName, winName,"height=480 width=470 left=150 top=10 status scrollbars  center=yes")
		if(windowSize==2) newx2=window.open(fileName, winName,"height=370 width=650 left=70 top=120 status scrollbars")
		if(windowSize==3) newx2=window.open(fileName, winName,"height=310 width=450 left=10 top=10  status")
		if(windowSize==4) newx2=window.open(fileName, winName,"height=480 width=770 left=10 top=40 status scrollbars  center=yes")
	}
}


function ccWindow(ccCode1, ccStatus1, ccMessage1, nextOptions1){
/*	if(screen.width==1024){
		window.open(fileName, "ccBox","height=240 width=420 left=313 top=276 scrollbars")
	}
	else{
		window.open(fileName, "ccBox","height=240 width=420 left=201 top=192 scrollbars")
	}
*/

		window.opener.ccCode2.innerText=ccCode1;
		window.opener.ccStatus2.innerText=ccStatus1;
		window.opener.ccMessage2.innerText=ccMessage1;
		window.opener.nextOptions2.innerHTML=nextOptions1;
	
}


function makeAllChecked(objName){
	if(eval("document.all."+objName+"[0].checked==true")){
		for(var i=1;i<eval("document.all."+objName+".length");i++)
				eval("document.all."+objName+"[i].checked=true")
	}
	else{
		for(var i=1;i<eval("document.all."+objName+".length");i++)
				eval("document.all."+objName+"[i].checked=false")
	}
}

function rsv(formName, radioName, theValue){
	var theObj="document."+formName+"."+radioName
	for(var i=0;i<eval(theObj+".length");i++){
		if (eval(theObj)[i].value==theValue){
			eval(theObj)[i].checked=true;
			break;
		}
	}
}

function calledThroughFileName(){
	priCalledThroughFileName=((window.opener.location.href).substr((window.opener.location.href).lastIndexOf('/')+1)).substr(0, (window.opener.location.href).indexOf('?'))
	return(priCalledThroughFileName.substr(0, priCalledThroughFileName.indexOf('?')))
}

function s(theVal){
	window.status=theVal;
}

function setTableColor(tblObj){
	for(priI=0;priI<tblObj.rows.length;priI++){	
		for(priJ=0;priJ<tblObj.rows(priI).cells.length;priJ++){
			if(priI!=tblObj.rows.length)tblObj.rows(priI).cells(priJ).style.borderBottom=cstTableBorderBottom
		}

		tblObj.rows(priI).onmouseover=function(){this.style.cursor='hand';this.style.backgroundColor=cstTableTrOverColor; this.style.color=cstTableTrDefaultColor;};
		tblObj.rows(priI).onmouseout=function(){this.style.cursor='';this.style.backgroundColor='';	this.style.color='';};;
	}
}

function testSuite(srcForm){
		var i
		tsAddress="iMatics India, 315, DS Industrial Complex,\nNear Mukund Company,\nKurla, Mumbai-400070"
		tsTelNo="9892677476"
		tsDescription="There is some descriptoin"
		for(i=0;i<pfv.length;i++){
			sl1=pfv[i].split(":");
//			alert(eval("srcForm."+trim(sl1[0])+".type"))
//			alert(eval("srcForm."+trim(sl1[0])+".options")=='undefined')
			if(eval("srcForm."+trim(sl1[0])+".options")>0 ){
				elType=eval("srcForm."+trim(sl1[0])+"[0].type")
			}
			else{
				elType=eval("srcForm."+trim(sl1[0])+".type")
			
			}
//			alert(elType)
			if (elType=="select-one" || elType=="radio" ){
//				alert()
			}
			eval("srcForm."+trim(sl1[0])+".value=trim(sl1[1])");
		}

}

function testSuite(srcForm){
		var i
		tsAddress="iMatics India Pvt. Ltd, 315, DS Industrial Complex,\nNear Mukund Company,\nKurla, Mumbai-400070"
		tsTelNo="9892677476"
		tsDescription="There is some descriptoin"
		for(i=0;i<pfv.length;i++){
			sl1=pfv[i].split(":");
//			alert(eval("srcForm."+trim(sl1[0])+".type"))
//			alert(eval("srcForm."+trim(sl1[0])+".options")=='undefined')
			if(eval("srcForm."+trim(sl1[0])+".options")>0 ){
				elType=eval("srcForm."+trim(sl1[0])+"[0].type")
			}
			else{
				elType=eval("srcForm."+trim(sl1[0])+".type")
			
			}
//			alert(elType)
			if (elType=="select-one" || elType=="radio" ){
//				alert()
			}
			eval("srcForm."+trim(sl1[0])+".value=trim(sl1[1])");
		}

}



a=""
function listProperties(obj){
//		document.write ("<table>")
		 for (var i in obj){
			a = a + i + "\n"
		 }
		 alert(a)
//			document.write (a)
	//	document.write  (a + "</table>")
}

/*--------------------For ShowHideDailog-------------------
Requirements :
1) call function callDiv() 
2) colomn id should be "toHide1" which you to hide 
3) Dailog layer Id should be "toShowDailog"
4) Form name should be defaultForm1
5) On Submit button call function saveThis()

*/
function callDiv(){
	document.write ("<div id=div2 style='top:0;left:0;display:none;position:absolute;width:100%;height=510;background-image:url(images/al.gif)'></div>")
}
function showDailog(whichDailog){
	document.body.scroll='no'
	div2.style.display='block'
	defaultForm.disabled=true
	whichDailog.style.display='block'
	for(i=0;i<toHide1.length;i++){
		toHide1[i].style.display='none'
	}
	document.body.onkeypress=function(){if(event.keyCode==27){hideDailogWs(whichDailog)}}

}

flag2=false
function hideDailog(whichDailog){
	document.body.scroll='yes'
	div2.style.display='none'
	defaultForm.disabled=false
	whichDailog.style.display='none'
	for(i=0;i<toHide1.length;i++){
		toHide1[i].style.display='block'
	}
	document.body.onkeypress=""
}

function hideDailogWs(whichDailog){
//	alert(flag2)
	if (flag2==false){
		document.defaultForm.status.selectedIndex=0
		showStatusUnit(document.defaultForm.status.options[0].isShowUnit)
	}
	hideDailog(whichDailog)
}

	function saveThis(whichDailog){
//		document.defaultForm1.submit()
		hideDailog(whichDailog);
		flag2=true;
	}
//--------------------End showHideDailog----------------------------------

	var scrollCounter = 0;
	var scrollText = "";
	var scrollDelay = 100;

	var i = 0;
	function scrollThis(theText){
		while (i++ < 80)
			theText=" " + theText;

		Scroller(theText)
	}

	function Scroller(scrollT) { 
		var scrollText=scrollT
		window.status = scrollText.substring(scrollCounter++,scrollText.length);
		if (scrollCounter == scrollText.length) scrollCounter = 0;
		setTimeout('Scroller(\''+scrollT+'\')', scrollDelay);

	} 
		

	function openPrintWindow(header){
		newx2=window.open('reportFrame.asp?header='+header, "newx1","height=480 width=800 left=50 top=150 scrollbars status center=yes")
	}


function breakCase(fieldName){
	var i;
	var processedFieldName=(fieldName.charAt(0)).toUpperCase();

	for(i=1;i<fieldName.length;i++){
		if(fieldName.charAt(i)==(fieldName.charAt(i)).toUpperCase()){
			processedFieldName=processedFieldName+" "+fieldName.charAt(i);
		}
		else{
			processedFieldName=processedFieldName+fieldName.charAt(i);
		}
	}

	return(processedFieldName);
}


function blankVal(theValue){

		if(theValue=="")
			return(false);
		else
			return(true);
}

function charVal(theVal){
	var i;
	theVal=theVal.toLowerCase()

	for(i=0;i<theVal.length;i++){
		if((theVal.charAt(i)<'a' || theVal.charAt(i)>'z' ) && (theVal.charAt(i)!=' ' && theVal.charAt(i)!='.') ){
			return false;
		}
	}
	return true;
}


function loginVal(theVal){
	var i;
	theVal=theVal.toLowerCase()

	for(i=0;i<theVal.length;i++){
		if((theVal.charAt(i)<'a' || theVal.charAt(i)>'z' ) && (theVal.charAt(i)!='_' && isNaN(theVal.charAt(i))==true) ){
			return false;
		}
	}
	return true;
}

function numVal(theVal){
	if(isNaN(theVal)) return false;
	return true
}


function removeTail(theValue){
	return(theValue.substring(0, theValue.length-2))	
}

function resetFormClasses(){
	for(i=0;i<fVal.length;i++){
		sl1=fVal[i].split(', ');
		document.defaultForm.elements[sl1[0]].className=''
	}
}

function setEventOnForm(){
	document.defaultForm.onsubmit=function (){return(formVal())};
	document.defaultForm.onreset=function (){resetFormClasses()}
}

// By Munib
// To Check proper DateRange
// function in diMethodSet getDateRange() and getDateRangeV2()

function properDate(x){
	if(x==true){
		return true
	}
	else {
		alert("Invalid Date Range")
		return false
	}
}
/******************************************************
For ccBox - Command Confirmation Box
*******************************************************/

var ccBoxI=0
ccOnFlg=false;
function showCCBox(){
	lx = document.body.offsetWidth - 300
	ly = document.body.offsetHeight - 190
	ccBox.style.left=lx;
	ccBox.style.top=ly;

	if(!ccOnFlg){
		if(ccBoxI < 200){ 
			ccBoxI +=  15;
			ccBox.style.filter='alpha(opacity='+ccBoxI+')'

			setTimeout('showCCBox()', 200);
		}
		else{
			ccBoxI=200;
			closeCCBox();
		}
	}
}

function closeCCBox(){
	lx = document.body.offsetWidth - 300
	ly = document.body.offsetHeight - 190
	ccBox.style.left=lx;
	ccBox.style.top=ly;

	if(!ccOnFlg){
		if(ccBoxI > 0){
			ccBoxI -= 15
			ccBox.style.filter='alpha(opacity='+ccBoxI+')'
			setTimeout('closeCCBox()', 200);
		}
		else{
			ccBox.style.display='none'
		}
	}
}

function viewCCBox(){

	if (ccOnFlg==true) 	ccOnFlg=false;
	else ccOnFlg=true

	if(!ccOnFlg){
		img1.title="Always Visible"
		ccBoxI=200;
		closeCCBox()
	}
	else{
		img1.title="Hide this Box"
		ccBox.style.filter='alpha(opacity=100)'
	}	
}

function selectOptions(selectElement, selctedValues){
	var i;
	selctedValues=selctedValues.split(",")
//	alert(selectElement.options.length)
	for (i=0; i<selectElement.options.length;i++ ){
		for (j=0;j<selctedValues.length; j++){
//			alert(selectElement.options(i).value+' = '+trim(selctedValues[j]))
			if(selectElement.options(i).value==trim(selctedValues[j])){
				selectElement.options(i).selected=true;
				break;
			}
		}
	}
}


function checkStepImages(){
	if(document.stepImage.readyState!='complete' ){
		document.stepImage.src='images/step0<%=curStep%>.gif'
	}
}

function checkImages(){
	if(window.pageXOffset==0){
		if (isNaN(document.imgs.length)){
			if(document.imgs.readyState!='complete'){
				if (document.imgs.name=='product'){
					document.imgs.src="/productimages/noImage.gif"
				}
				else{
					document.imgs.src="images/"+document.imgs.alt
				}
			}
		}
		else{
			for(i=0;i<document.imgs.length;i++){
				if(document.imgs[i].width==0){
					if (document.imgs[i].name=='product'){
						document.imgs[i].src="/productimages/noImage.gif"
					}
					else{
						document.imgs[i].src="images/"+document.imgs[i].alt
					}
				}
			}
		}
	}
	else{
		if (isNaN(document.all.imgs.length)){
			if(document.all.imgs.readyState!='complete'){
				if (document.all.imgs.name=='product'){
					document.all.imgs.src="/productimages/noImage.gif"
				}
				else{
					document.all.imgs.src="images/"+document.all.imgs.imageName
//					document.all.imgs.style.visibility='visible'
				}
			}
		}
		else{
			for(i=0;i<document.all.imgs.length;i++){
				if(document.all.imgs[i].readyState!='complete'){
					if (document.all.imgs[i].name=='product'){
						document.all.imgs[i].src="/productimages/noImage.gif"
					}
					else{
						document.all.imgs(i).src="images/"+document.all.imgs[i].imageName
	//					document.all.imgs(i).style.visibility='visible'
					}
				}
			}
		}
	}
}



function checkImageType(x){
	imgType=x.value.split(".")
	if (imgType[imgType.length-1].toLowerCase()=='jpg' || imgType[imgType.length-1].toLowerCase()=='jpeg' || (imgType[imgType.length-1].toLowerCase()=='' && x.name!='thumbNail') ) {
		return true
	}
	else{
		msg+="\n  - "+breakCase(x.name)+" is non jpg type or blank";
		return false
	}
}



function addTheRow(theTBody){
  	var noOfCells
	theRow=theTBody.insertRow();
	
	noOfCells=theTBody.rows(0).cells.length;
	theRow.id="tr"+(theTBody.rows.length-1)
	for(i=0;i<noOfCells;i++){
		theTBody.rows(theTBody.rows.length-1).insertCell();
		theTBody.rows(theTBody.rows.length-1).cells(i).innerHTML=theTBody.rows(0).cells(i).innerHTML;
	}
	
	theTBody.rows(theTBody.rows.length-1).insertCell();
	theTBody.rows(theTBody.rows.length-1).cells(i).innerHTML="<a href='#' onclick='delRow(document.all."+theTBody.id+","+(theTBody.rows.length-1)+")'>Delete</a>"
 }
 
function delRow(theTBody,whichRow){

	for(i=0;i<theTBody.rows.length;i++)
			if(theTBody.rows(i).id=="tr"+whichRow)
					theTBody.deleteRow(i);

}

function getImgType(x){
	x=x.split('.')
	
	return x[x.length-1].toLowerCase();
}


function checkMisc(i){
	var theValue;
	var theName;
	var flg1
	flg1=true
	theValue=document.defaultForm.image1.value
	theName=document.defaultForm.image1.name
	
	if(i==0){
		if (theValue!=''){
			if (getImgType(theValue)=='jpg' || getImgType(theValue)=='gif' ){
			
			}
			else{
				msg+="\n  - "+breakCase(theName)+" can be GIF or JPG only";
				flg1=false
			}
		}
		else{
			msg+="\n  - "+breakCase(theName)+" can not be blank";
			flg1=false
		
		}
	}
	else{
		if (theValue!=''){
			if (getImgType(theValue)=='mpg' || getImgType(theValue)=='avi' ){
			
			}
			else{
				msg+="\n  - Video can be mpg or avi only";
				flg1=false
			}
		}
		else{
			msg+="\n  - Video can not be blank";
			flg1=false
		
		}
	}

	return flg1;
}


function fillForm2Debug(automateDebugValue){
	//Math.random() can be replaced with date hours and minute
	debugValue=parseInt(Math.random()*99);
	if(!automateDebugValue) debugValue=prompt("Enter Debug Value", parseInt(Math.random()*99));
	
	theArr01=document.body.getElementsByTagName("input");
	
	for(i=0;i<theArr01.length;i++){
		if(theArr01[i].type=='text'){
			theArr01[i].value=theArr01[i].name+debugValue;
		}
	}

	theArr01=document.body.getElementsByTagName("textarea");
	
	for(i=0;i<theArr01.length;i++){
			theArr01[i].value=theArr01[i].name+debugValue;
	}

}

/*
Developed date: 08-Feb-2006 while working on prism
Developed by: Ashraf Ahmed
*/

function filterArray(theArray, condition){
	var tempArray = new Array();
	var j=0;	

	for(var i=0;i<theArray.length;i++){
		if(theArray[i]==condition){
			tempArray[j++] = theArray[i];
		}
	}
	
	return(tempArray);
}



function hideProperty(no){
	for(tempI=0;tempI<navLinks.length;tempI++){
		if (tempI!=no){
			navLinks(tempI).style.display='none';
		}
	}
	if(no>=0)	{
		callProperty(no)
	}
}

function callProperty(x){
	navLinks[x].style.display='block'
	l=navLinks[x].rows.length
	for (j=0;j<l;j++){
		navLinks[x].rows[j].style.display='none'
	}
	showCCBox(navLinks[x], l-1)
}


ccBoxI=0

function showCCBox(x, l){
	y=x
	k=l
	if(ccBoxI < 100 || l>=0){ 
		if (l>=0)	x.rows[l].style.display='block'
		ccBoxI +=  Math.floor(100/(x.rows.length));
		x.style.filter='alpha(opacity='+ccBoxI+')'
		setTimeout('showCCBox(y, k-1)', 50);
	}
	else{
		ccBoxI=0
		
	}
}

ccBoxII=100
function hideCCBox(x, l){
	y=x
	k=l
	if(ccBoxII >= 0 && l>=0){ 
		x.rows[k].style.display='none'
		ccBoxII -=  100/x.rows.length;
//		window.status= ccBoxII
		x.style.filter='alpha(opacity='+ccBoxII+')'
		setTimeout('hideCCBox(y, k-1)', 40);
	}
	else{
		ccBoxII=100;		
		x.style.display='none'
	}
}


function showMenu(x){
	menuTable.style.display='block'
	for(i=0;i<theMenu.length;i++){
		direction(i).style.visibility='hidden'
		theMenu(i).style.display='none'
	}
	direction(x).style.visibility='visible'
	theMenu(x).style.display='block'
	
}

function hideAllMenu(){
	for(i=0;i<theMenu.length;i++){
		direction(i).style.visibility='hidden'
		theMenu(i).style.display='none'
	}
}
