var timer=null;
var interval=30000; //30 secs
function reqTime(){
  timer=setInterval("work();",interval);
}
function work(){
	var dateObj = new Date(document.frmManage.hdnCurrent.value);
	document.frmManage.hdnCurrent.value=new Date(dateObj.getYear(), dateObj.getMonth(), dateObj.getDate(), dateObj.getHours(), dateObj.getMinutes(), dateObj.getSeconds()+ interval/1000);
}

function VoidRequest(request_id){
	var msgConfirm = confirm("Are you sure you want to cancel your request?");

	if (msgConfirm) {
		document.location = "main.asp?uri=1083&action=3&id=" + request_id;
	}
}

function VoidRequestAdmin(request_id){
	var msgConfirm = confirm("Are you sure you want to delete this request?");

	if (msgConfirm) {
		document.location = "admin.asp?uri=2334&action=3&id=" + request_id + "&cll=2333|fi=1";
	}
}

function chgLookup(cbo){
	var HREF=document.frmManage.SvRtnAction.value;

	i=HREF.indexOf('&goto=') + 6;
	if (cbo[cbo.selectedIndex].className!='')
	{
		HREFSearch.href = HREF.substring(0,i) +  cbo[cbo.selectedIndex].className + HREF.substr(i);
		if (cbo[cbo.selectedIndex].className==4000)
		{
		MM_showHideLayers('OpportunityLink','','show');
		}
		else{MM_showHideLayers('OpportunityLink','','hide')}

	}
	else HREFSearch.href= 'javascript:void(0)';
}


var log='';
function RequestTypeChg(obj,obj1){
	var scriptHTML="";
	if (typeof(obj.length)!='undefined'){
		for(var i=0;i<obj.length;i++){
			if(typeof(obj1)!='undefined' && obj[i].value==obj1.value) obj[i].checked=true;
			if (obj[i].checked)	scriptHTML= obj[i].className;
		}
	}
	else scriptHTML=obj.className; //onclick event for each RADIO item
	log=GetValueByKey(scriptHTML,'login=');
	document.getElementById('lblRQ').innerHTML = (log)?'Requestor:':'';
	var myInput=document.getElementById('txtCustomer');
	if(log){
		myInput.style.display ='';
	}else{
		myInput.value='';
		myInput.style.display = "none";
	}
	//document.getElementById('txtRQ').innerHTML = (log)?'<input name=txtCustomer size=70/>':'';

	scriptHTML=GetValueByKey(scriptHTML,'script=',true)
	//if(scriptHTML.length>550) document.all.item('divScript').style.cssText="overflow: auto; width:720px; height:100px;";
	//else document.all.item('divScript').style.cssText="overflow: auto; width:720px; height:40px;";
	//document.all.item('divScript').innerHTML= scriptHTML;
	document.getElementById('divScript').innerHTML= scriptHTML;

	//}
	//alert(document.frmManage.Add.href);
}
//!!!TODO: Client Time difference!!! ??Display Seconds?
function enterTime(obj){
	var d=new Date(document.frmManage.hdnCurrent.value);
	var iMinutes = d.getMinutes();
	obj.value=d.getHours() + ':' + (iMinutes>9?'':'0') + iMinutes; //+ ':' + d.getSeconds();
}

function GetValueByKey(sInf,sKey,end){
	var iPos=0;
	var iPosStop=0;
		var sVal=""; //Return value
	iPos=sInf.indexOf(sKey);
	if (iPos==-1){
		sVal="";
	}
	else{
		sVal=sInf.substr(iPos+sKey.length,sInf.length);
		iPosStop= end?-1:sVal.indexOf(';');
			if (iPosStop==-1){
			//End of Info string
				sVal=sVal;
			}
			else{
				//Retrieve information
				sVal=sVal.substr(0,iPosStop);
			}
		}
   return sVal;
}

function FRMValidate(){
	var sStop="";
	if (typeof(document.frmManage.RequestTypeID)!='undefined'){
		var obj=document.frmManage.RequestTypeID;
		if (obj.length>0){
			sStop="stop";
			for(var i=0;i<obj.length;i++){
				if (obj[i].checked){ sStop=""; break; }
			}
		}
		else if(!obj.checked) sStop="stop";
		if (sStop!=''){ alert('Please, select a Request Type'); obj[0].focus();}
	}
	if(typeof(document.frmManage.ApprovedByID)!='undefined' && !document.frmManage.ApprovedByID.checked){
		sStop='stop'; alert('Please, authorize the Work Order created')
	}
	return sStop;
}

function QuoteValidation(rid)
{
	var sUrl;
	var aInputs = document.all.item("chkItemStatus");

	var aCbos = new Array();
	if (document.all.item("chkItemStatus")) aCbos=document.all.item("chkItemStatus");

	for(var i = 0; i<aCbos.length; i++){
	if (typeof(aCbos[i].name) !="undefined")	// if there is array from some comboboxes
		{
 		if (aInputs[i].value==1)
	 		{
	 		alert('Item Status for all Items must be set to either Priced or Not Available before a quote can be generated');
			return;
	 		}
	 	}
	else
		{
		 if (aCbos[i].selected && aCbos[i].value==1)
		 {
		alert('Item Status for all Items must be set to either Priced or Not Available before a quote can be generated');
		return;
		 }

		}
	}

	_onSave(document.frmManage,'2334&action=4&id=' + rid + '&qid=-1');
}

//////// Request Submit button - use on Public Page and Admin Entry
function ReqSubmit(id, bAddDoc, bSts, curUrl)
{

if (valRequiredExtended('frmManage')==''){

	document.frmManage.hdnActive.value=1;
	var urlcll="";
	var urlSave="";
	var urlRtn="";
	var goto='&state=goto&goto=';
	var DocPage='1082|action=16|id=' + id;

	if (curUrl==2334){
		urlSave='admin.asp?uri='+ curUrl + '&action=4&id=' +id;
		//urlcll='|cll=2334|action=1|id=' + id + '|st=10';
		urlcll='|cll=2334|action=2|id=' + id;
		urlRtn='2334|action=1|id=' + id + '|st=10';
	}
	else{
		urlSave='main.asp?uri='+ curUrl + '&action=4&id=' +id;
		urlcll='|cll=1083|id=' + id + '|st=10';
		urlRtn='1083|id=' + id + '|st=10';
	}

	// RequestType allow add Document
	if (bAddDoc=='True' && curUrl!=2334){
		if(mdOpen('<center>Would you like to attach a document or file?</center>','300','140',' Yes ',' No ','','','','Request Attachments',''))
		{
			// If page is not secure
			if (bSts!='True'){
				document.frmManage.action=urlSave + goto +  DocPage + urlcll;
				document.frmManage.submit();
				}
			else{
				frmManage.action=frmManage.action + goto + DocPage + urlcll;
				frmManage.submit();}
		}
		// Document is not attached
		else{
			if (bSts!='True'){
				document.frmManage.action=urlSave + goto +  urlRtn + urlcll;
				document.frmManage.submit();
			}
			else{
				frmManage.action=frmManage.action + goto + urlRtn + urlcll;
				frmManage.submit();
			}
		}
		}
	else{			 // RequestType don't allow add Document
			if (bSts!='True'){
				document.frmManage.action=urlSave + goto +  urlRtn + urlcll;
				document.frmManage.submit();
			}
			else{
				frmManage.action=frmManage.action + goto + urlRtn;
				frmManage.submit();
			}
	}
}}

function ReqMBSubmit(id, bAddDoc, bSts, curUrl)
{

//if (valRequired()==''){
if (valRequiredExtended('frmRQMBManage')==''){

	document.frmRQMBManage.hdnActive.value=1;
	var urlcll="";
	var urlSave="";
	var urlRtn="";
	var goto='&state=goto&goto=';
	var DocPage='1082|action=16|id=' + id;

	if (curUrl==2334){
		urlSave='admin.asp?uri='+ curUrl + '&action=4&id=' +id;
		urlcll='|cll=2334|action=1|id=' + id + '|st=10';
		urlRtn='2334|action=1|id=' + id + '|st=10';
	}
	else{
		urlSave='main.asp?uri='+ curUrl + '&action=4&id=' +id;
		urlcll='|cll=1083|id=' + id + '|st=10';
		urlRtn='1083|id=' + id + '|st=10';
	}

	// RequestType allow add Document
	if (bAddDoc=='True' && curUrl!=2334){
		if(mdOpen('<center>Would you like to attach a document or file?</center>','300','140',' Yes ',' No ','','','','Request Attachments',''))
		{
			// If page is not secure
			if (bSts!='True'){
				document.frmRQMBManage.action=urlSave + goto +  DocPage + urlcll;
				document.frmRQMBManage.submit();
				}
			else{
				frmRQMBManage.action=frmRQMBManage.action + goto + DocPage + urlcll;
				frmRQMBManage.submit();}
		}
		// Document is not attached
		else{
			if (bSts!='True'){
				document.frmRQMBManage.action=urlSave + goto +  urlRtn;
				document.frmRQMBManage.submit();
			}
			else{
				frmRQMBManage.action=frmRQMBManage.action + goto + urlRtn;
				frmRQMBManage.submit();
			}
		}
		}
	else{			 // RequestType don't allow add Document
			if (bSts!='True'){
				document.frmRQMBManage.action=urlSave + goto +  urlRtn + urlcll;
				document.frmRQMBManage.submit();
			}
			else{
				frmRQMBManage.action=frmRQMBManage.action + goto + urlRtn;
				frmRQMBManage.submit();
			}
	}
}}

function GoTo(id, Page, bSts){
	if (bSts!='True'){
		_onSave(document.frmManage,'2334&action=4&id=' + id + '&state=goto&goto=' + Page);
	}
	else{
		frmManage.action=frmManage.action+ '&state=goto&goto=' + Page;
		frmManage.submit();
	}
}


function cancelReq(cancelHREF){
	if(confirm('You are about to cancel the request')) document.location=cancelHREF;
}
function gotoPage(val){
	if (window.event.keyCode==13)	{
		var  url = '2334&action=1&st=2&id=' + val+ '&src=yes&state=goto&goto=';
		_onSave(document.frmManage,url);
	}
}

function LoadWOTypePage(ReqID, sGoToUrl, Secure) {

	var url="admin.asp?uri=7000&page=wotype";

	WOType=window.showModalDialog(url, 'cal', 'dialogWidth:395 px;dialogHeight:200 px;resizable:yes;scroll:no;status:no;center:yes;unadorned:yes;help:no;');

	if (WOType!='' && typeof(WOType)!="undefined" && WOType!=0) {
		if (ReqID>0)
		{
		GoTo(ReqID,sGoToUrl + '&wot=' + WOType, Secure);
		}
	else
		{
		document.location='admin.asp?uri=2332&action=1&wot='+ WOType;
		}
	}
	else
	{
	alert('Please, select WorkOrder type');
	return;
	}
}
function LoadServTypePage() {

	var url="admin.asp?uri=7000&page=srvtype";

	WOType=window.showModalDialog(url, 'cal', 'dialogWidth:395 px;dialogHeight:200 px;resizable:yes;scroll:no;status:no;center:yes;unadorned:yes;help:no;');

	if (WOType!='' && typeof(WOType)!="undefined" && WOType!=0) {
		document.location='admin.asp?uri=2350&action=1&wot='+ WOType;

	}
	else
	{
	alert('Please, select Service Contract type');
	return;
	}
}
function TypeSelect(){

     window.returnValue=document.frm.lstWOList.value;window.close();

}

function ShowHideLayer(oLayer,aidi,arrow){
	if(aidi!='') var imgObj=document.getElementById(aidi);
	if(oLayer!='') var layerObj=document.getElementById(oLayer);
	if(arrow==1) var arrowObj=document.getElementById(oLayer+'CeilingImg');
	if(layerObj.style.display=='none'){
		layerObj.style.display='';
		if(arrowObj) arrowObj.src="images/icons/arup.png";
		if(imgObj) imgObj.src="images/icons/remove.gif";
	}else{
		layerObj.style.display='none';
		if(arrowObj) arrowObj.src="images/icons/ardown.png";
		if(imgObj) imgObj.src="images/icons/add.gif";
	}
}

function HotKeyT(){
	var hr=document.location.href;
	var arr=new Array();
	arr=hr.split('&');
	var reqID;
	for(var i=0;i<arr.length;i++){
		if(arr[i].indexOf('id')==0 && arr[i].indexOf('=')==2) reqID=arr[i].substring(3);
	}
	if(reqID*1>0) window.open('admin.asp?uri=2240&id=' + reqID);
}


var c_middleInitial=31;
var c_lastName=33;
var c_SSN=35;
var c_Email=3;
var c_cardNumber=47;
var c_cardExpMonth=48;
var c_cardExpYear=49;
var c_website=9;
var c_zipValidated=39;
var c_zip=40;
var c_countryAll=42;
var c_countrySelected=43;
var c_cityValidated=38;
var c_state=41;

function validateFields(frm){
	var isUS=true;
	var count=0;
	var res='';
	var arr=new Array();
	arr=eval('document.'+ frm +'.elements');
	for(var i=0;i<arr.length;i++){
		var n=arr[i].name.substring(1)
		var obj=document.getElementsByName('ans'+n)[0];
		switch(arr[i].getAttribute('relatedID')*1){
			case c_countryAll:
			case c_countrySelected:
				if(obj){
					if(obj.value!=1) isUS=false;
				}
				break;
			case c_middleInitial:
				if(obj){
					if(obj.value.length>2){
						res=res + 'Please enter a single letter or letter with a period for middle initial. For example : "M." or "M" .';
					}else{
						if(obj.value.length==1){
							var val=obj.value.substr(0,1);
							val=val.charCodeAt(0);
							if(!((val>64 && val< 91) || (val>96 && val< 123))) res=res + 'Please enter a single letter or letter with a period for middle initial. For example : "M." or "M" .';
						}
						if(obj.value.length==2){
							var val=obj.value.substr(0,1);
							val=val.charCodeAt(0);
							if(!((val>64 && val< 91) || (val>96 && val< 123))){
								res=res + 'Please enter a single letter or letter with a period for middle initial. For example : "M." or "M" .';
							}else{
								val=obj.value.substr(1,1);
								val=val.charCodeAt(0);
								if(val!=46) res=res + 'Please enter a single letter or letter with a period for middle initial. For example : "M." or "M" .';
							}
						}
					}
				}
				break;
			case c_lastName:
				if(obj){
					var val=trim(obj.value);
					if(val.indexOf(' ')>-1) res=res + '\n' + 'Please enter your last name without any spaces.';
				}
				break;
			case c_SSN:
				if(obj){
					//if(!(obj.value*1>0)) res=res + '\n' + 'SSN must be digits only.';
					var check=0;
					var val=obj.value;
					if(val.length==0){
						res=res + '\n' + 'SSN must be in this format : 333-44-5555 or 333445555.';
					}else{
						for(var j=0;j < val.length;j++){
							var cChar=val.charCodeAt(j);
							if(!((cChar>47 && cChar< 58) || cChar==45) && check==0){
								res=res + '\n' + 'SSN must be in this format : 333-44-5555 or 333445555.';
								check=1;
							}
						}
					}
				}
				break;
			case c_Email:
				if(obj){
					if(obj.value.indexOf('@')==-1) res=res + '\n' + 'Please enter valid email address.';
				}
				break;
			case c_cardNumber:
				if(obj){
					if(!(obj.value*1>0)){
						res=res + '\n' + 'Credit Card Number must be digits only.';
					}else{
						var first=obj.value.substr(0,1);
						first=first*1;
						if(first!=3 && first!=4 && first!=5 && first!=6){
							res=res + '\n' + 'We accept the following credit cards : American Express, Visa, Master Card and Discover. Please enter valid credit card number.';
						}
					}
				}
				break;
			case c_cardExpMonth:
				var msg=ExpirationDate(frm);
				if(msg!='') res=res + '\n' + msg;
				break;
			case c_website:
					if(obj){
						if(obj.value.length>0 && !isUrl(obj.value)) res=res + '\n' + 'Please enter a valid website URL. For example : http://www.page.com or www.my-page.com';
					}
				break;
			case c_zipValidated:
			case c_zip:
					if(obj && count==0){
						var zip=ZipValidate(obj.value,isUS);
						if(zip!=''){
							res=res + '\n' + zip;
							count=1; //prevents from alerting multiple times if we have more than 1 zip field
						}
					}
				break;
		}
	}
	return res;
}

function trim(stringToTrim){
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ExpirationDate(frm){
	var d=new Date();
	var dMonth=d.getMonth()+1;
	var dYear=d.getFullYear();
	var arr=new Array();
	arr=eval('document.'+ frm +'.elements');
	var cr_month;
	var cr_year;
	for(var i=0;i<arr.length;i++){
		var n=arr[i].name.substring(1)
		var obj=document.getElementsByName('ans'+n)[0];
		switch(arr[i].getAttribute('relatedID')*1){
			case c_cardExpMonth:
				if(obj){
					cr_month=obj.value*1;
				}
				break;
			case c_cardExpYear:
				if(obj){
					cr_year=obj.value*1;
				}
				break;
		}
	}
	if(cr_month>0 && cr_year>0){
		if(cr_year==dYear && cr_month<dMonth) return 'Please enter a valid expiration date for your credit card.';
		else return '';
	}
}

function isUrl(s) {
	//var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ ;
	var regexp=new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
	var res=regexp.test(s)
	return res;
}

function ZipValidate(val,isUS){
	var bool=false;
	if(isUS){
		if(val.length==0) bool=true;
		if((val.length==5 || val.length==9) && val*1>0) bool=true;
		if(val.length==10){
			if(val.indexOf('-')==5 && val.replace('-','')*1>0) bool=true;
		}
	}else bool=true;
	return bool?'':'Please enter valid zip/postal code. Example : 99999, 999998888, 99999-8888.'
}


/*function AjaxTransport() {
	if (window.XMLHttpRequest) return new XMLHttpRequest();
	else return new ActiveXObject("Microsoft.XMLHTTP");
}

function CityZipValidate(http, zurl, async, cback)
{
  http.onreadystatechange = function() {
  	if (http.readyState == 4) {
  		if (http.status != 200) {
  			alert(http.statusText);
  		}
  		else if (cback) {
  			cback.call(http);
  		}
  	}
  };
  http.open("GET", zurl, async);
  http.send(null);
}*/

var xmlhttp;
var AJAXresult='';

function CityZipValidate(zurl)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttp.onreadystatechange=CityZipValidateStateChange;
  //alert(zurl);
  xmlhttp.open("GET",zurl,true);
  xmlhttp.send(null);
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp.onreadystatechange=CityZipValidateStateChange;
  xmlhttp.open("GET",zurl,true);
  xmlhttp.send();
  }
}


function CityZipValidateStateChange()
{
if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
    // process whatever has been sent back here
    AJAXresult=xmlhttp.responseText;
    if(AJAXresult!='ok'){
    	alert(AJAXresult);
    	return;
    }
    if(siteFeature==1){
    	submitSrv(applFormAction);
    }else ReqSubmit(reqID,reqAddDoc,reqSts,reqCurUrl);
    }
  else
    {
    alert("There was a problem in the returned data");
    }
  }
}

var reqID;
var reqAddDoc;
var reqSts;
var reqCurUrl;
var siteFeature;
var applFormAction;

function BuildURL(pid, bAddDoc, bSts, curUrl,feature,frmAction)//the params here are used to set global vars that we will use in ReqSubmit()
{

	reqID=pid;    //used for request
	reqAddDoc=bAddDoc;    //used for request
	reqSts=bSts;    //used for request
	reqCurUrl=curUrl;    //used for request

	siteFeature=feature;    //used for application
	applFormAction=frmAction;    //used for application

	var docFrm;
	if(feature==1){ //1-for application
		docFrm='frmSurveyAnswer';
	}else docFrm='frmManage'; //for requests.Eventually there will be a value for surveys too.

	var validS=validateFields(docFrm);
	if(validS!=''){
		alert(validS);
		return;
	}

	AJAXresult='';
	var validate=0;//0-do not validate,1-validate city,2-validate zip,3-validate both
	var myCity='';
	var myZip='';
	var arrCity=isCityValidated(docFrm);
	if(arrCity[0]) myCity=arrCity[1];
	var arrZip=isZipValidated(docFrm);
	if(arrZip[0]) myZip=arrZip[1];
	if(!arrCity[0] && !arrZip[0]) validate=0;
	if(arrCity[0] && !arrZip[0]) validate=1;
	if(!arrCity[0] && arrZip[0]) validate=2;
	if(arrCity[0] && arrZip[0]) validate=3;

	switch(validate){
		case 0:
			AJAXresult='ok';
			if(feature==1){
				submitSrv(frmAction);
			}else ReqSubmit(reqID,reqAddDoc,reqSts,reqCurUrl);
			break;
		case 1:
			var a=AddressAJAX('false',docFrm);
			var sState=a.state;
			var sCountry=a.country;
			var sZip=a.zip;
			var sCity=myCity;
			var zurl='test.asp?uri=1083&validate=1&state=' + sState + '&country=' + sCountry + '&zip=' + sZip + '&city=' + sCity + '&rand=' + Math.floor(Math.random()*100001);
			/*var http = AjaxTransport();
			CityZipValidate(http, zurl, true,
				function(http) {
					//alert(http.responseText);
					res=http.responseText;
				}
			);*/
			CityZipValidate(zurl);
			break;
		case 2:
			var a=AddressAJAX('true',docFrm);
			var sCountry=a.country;
			var sZip=myZip;
			var zurl='test.asp?uri=1083&validate=2&country=' + sCountry + '&zip=' + sZip + '&rand=' + Math.floor(Math.random()*100001);
			/*var http = AjaxTransport();
			CityZipValidate(http, zurl, true,
				function(http) {
					//alert(http.responseText);
					res=http.responseText;
				}
			);*/
			CityZipValidate(zurl);
			break;
		case 3:
			var a=AddressAJAX('false',docFrm);
			var sState=a.state;
			var sCountry=a.country;
			var sZip=myZip;
			var sCity=myCity;
			var zurl='test.asp?uri=1083&validate=3&state=' + sState + '&country=' + sCountry + '&zip=' + sZip + '&city=' + sCity + '&rand=' + Math.floor(Math.random()*100001);
			/*var http = AjaxTransport();
			CityZipValidate(http, zurl, true,
				function() {
					//alert(http.responseText);
				}
			);*/
			CityZipValidate(zurl);
			break;
	}
}


function AddressAJAX(bZip,frm){ //find the values for Country, State and Zip
	var state='';
	var zip='';
	var country=0;
	var countZip=0;
	var countCountry=0;
	var arr=new Array();
	arr=eval('document.'+frm+'.elements');
	for(var i=0;i<arr.length;i++){
		var n=arr[i].name.substring(1)
		var obj=document.getElementsByName('ans'+n)[0];
		switch(arr[i].getAttribute('relatedID')*1){
			case c_zipValidated:
				if(obj && countZip==0){
					zip=obj.value;
					countZip=1;
				}
				break;
			case c_countrySelected:
				if(obj && countCountry==0){
					country=obj.value;
					countCountry=1;
				}
				break;
			case c_state:
				if(obj){
					state=obj.value;
				}
				break;
		}
	}
	if(zip=='' && !bZip){ //if there is no field for zip validated
		for(var i=0;i<arr.length;i++){
			var n=arr[i].name.substring(1)
			var obj=document.getElementsByName('ans'+n)[0];
			switch(arr[i].getAttribute('relatedID')*1){
				case c_zip:
					if(obj && countZip==0){
						zip=obj.value;
					}
					break;
			}
		}
	}
	if(country==0){	//if there is no field for country selected
		for(var i=0;i<arr.length;i++){
			var n=arr[i].name.substring(1)
			var obj=document.getElementsByName('ans'+n)[0];
			switch(arr[i].getAttribute('relatedID')*1){
				case c_countryAll:
					if(obj && countCountry==0){
						country=obj.value;
					}
					break;
			}
		}
	}
	return {state:state,zip:zip,country:country};
}



function isCityValidated(frm){ //checks if there is field for CITY validated.Returns if there is and its value
	var res=''
	var bool=false;
	var arr=new Array();
	arr=eval('document.'+ frm +'.elements');
	for(var i=0;i<arr.length;i++){
		var n=arr[i].name.substring(1)
		var obj=document.getElementsByName('ans'+n)[0];
		switch(arr[i].getAttribute('relatedID')*1){
			case c_cityValidated:
				if(obj){
					res=obj.value;
					bool=true;
				}
				break;
		}
	}
	return [bool,res];
}

function isZipValidated(frm){ //checks if there is field for ZIP validated.Returns if there is and its value
	var res=''
	var bool=false;
	var arr=new Array();
	arr=eval('document.'+ frm +'.elements');
	for(var i=0;i<arr.length;i++){
		var n=arr[i].name.substring(1)
		var obj=document.getElementsByName('ans'+n)[0];
		switch(arr[i].getAttribute('relatedID')*1){
			case c_zipValidated:
				if(obj){
					res=obj.value;
					bool=true;
				}
				break;
		}
	}
	return [bool,res];
}

function submitAdminRequestEntry(frm){
	var checks=frm.RequestTypeID;
	var bChecked=false;
	for (var i=0; i<checks.length; i++){
		if(checks[i].checked) bChecked=true;
	}
	if(bChecked){
		if (!log){
			frm.submit();
		}else{
			_onSave(frm,'2334&action=1&st=2&state=goto&amp;goto=');
		}
	}else alert('Please select the request type.');
}
