function replaceAll(string,text,by) 
{
	// Replaces text with by in string
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
	    newstr += replaceAll(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}

function setCountryCode(cmbCountry)
{
	var countrycode=getCountryCode(cmbCountry)
	document.getElementById("txtP1CntCd").value=countrycode
	document.getElementById("txtP2CntCd").value=countrycode
	document.getElementById("txtFaxCntCd").value=countrycode
}

function getCountryCode(CountryElement)//gets the telephones country code for that selected country
{
	//CountryName=CountryName.toLowerCase();
	CountryName= document.getElementById(CountryElement).options[document.getElementById(CountryElement).selectedIndex].text.toLowerCase()
	var CountryCode
	if (CountryName == "canada" )
		CountryCode = "1"
	else if (CountryName == "china" )
		CountryCode = "86"
	else if (  CountryName == "france" )
		CountryCode = "33"
	else if (  CountryName == "germany" )
		CountryCode = "49"
	else if (  CountryName == "india" )
		CountryCode = "91"
	else if (  CountryName == "italy" )
		CountryCode = "39"
	else if (  CountryName == "mexico" )
		CountryCode = "52"
	else if (  CountryName == "netherlands" )
		CountryCode = "31"
	else if (  CountryName == "pakistan" )
		CountryCode = "92"
	else if (  CountryName == "spain" )
		CountryCode = "34"
	else if (  CountryName == "switzerland" )
		CountryCode = "41"
	else if (  CountryName == "united kingdom" )
		CountryCode = "44"
	else if (  CountryName == "united states" )
		CountryCode = "1"
	else
		CountryCode = "0"
		return (CountryCode);
}

function ConfirmExit()
{
	if (confirm('All changes would be lost! Want to continue?'))
	{
		window.close()
		return false
	}
	return false
}

function DisableSaveCancel(mode)
{
	//alert(mode)
	if(mode != 'true' )
	{
	document.getElementById("cmdSave").disabled=true;
	document.getElementById("cmdCancel").disabled=true
	document.getElementById("cmdSaveNext").disabled=true
	}
}

function ResetFormAction()
{
	document.forms[0].action=document.forms[0].action.split("?")[0]
	return true
}
function doSubmit(id,mode,selectedrow,listid)
{	
	if ( mode=="D" )
	{
		if ( confirm("Selected Record would be Deleted!!.Want to continue?"))
		{
			document.forms[0].action=document.forms[0].action.split("?")[0] + "?id=" + id + "&mode=" + mode +"&selectedrow="  + selectedrow + "&listid=" + listid
			//document.forms[0].action="<%=formname%>" + "?id=" + id + "&mode=" + mode +"&selectedrow="  + selectedrow
			document.forms[0].submit()
			return true;	
		}
		else
		return false
	}
	else
	{
		document.forms[0].action=document.forms[0].action.split("?")[0] + "?id=" + id + "&mode=" + mode +"&selectedrow="  + selectedrow
		//document.forms[0].action="<%=formname%>" + "?id=" + id + "&mode=" + mode +"&selectedrow="  + selectedrow
		document.forms[0].submit()
		return true;	
	}
	
}
function isValueEntered(ele)
{
	if (ele.value.length==0)
	{
		return false
	}
	else
	{
		return true
	}
}
//code for validating the text field using a common function which would be called on their onblur event..
var err,errEleNm
err=false
errEleNm=""
	function checkForNull(ele)//ele means the passed element for which we r checking...
	{ 
		if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
		{
			return true
		}
		if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
		{
			return true
		}
//		alert("active element name " + document.activeElement.name)
		if (ele.value.length==0)
		{
//			alert(errEleNm)
//			alert(ele.name)
			if (errEleNm =="" || ele.name == errEleNm)
			{
				err=true
				errEleNm= ele.name
				alert('Please Enter the value for ' + ele.name.substr(3))
				ele.focus()
				return false
			}
		}
		else
		{
			errEleNm=""
			err=false
			return true
		}
	}


function isValidEmail(ele,checkIfNOTNULL)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}

	//var emailStr=document.updatebidderemail.email.value;
	/*if (! checkForNull(ele))
	{
		if (checkIfNOTNULL)
			return false // mean if the Null Email is NOT Allowed
		else
			return true// means if the Null Email is Allowed
	}*/
	if (! isValueEntered(ele))
	{
		if (checkIfNOTNULL)
			return false // mean if the Null Email is NOT Allowed
		else
			return true// means if the Null Email is Allowed
	}
	
	var emailStr=ele.value;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	/*if(theForm.email.value==""){
		return true;
	}*/
	if (matchArray==null) {
		err=true
		errEleNm= ele.name
		alert("email address seems incorrect (check @ and .'s)");
		ele.focus();
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null) {
		err=true
		errEleNm= ele.name
		alert("The username in Email ID doesn't seem to be valid.");
		ele.focus();
		return false;
	}
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				err=true
				errEleNm= ele.name
				alert("Destination IP address in Email ID is invalid!");
				ele.focus();
				return false;
			}
		}
	}  

	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		err=true
		errEleNm= ele.name
		alert("The domain name in Email ID doesn't seem to be valid.");
		ele.focus();
		return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
		err=true
		errEleNm= ele.name
		alert("The Email address must end in a three-letter domain, or two letter country.");
		ele.focus();
		return false;
	}
	if (len<2) {
		var errStr="This Email address is missing a hostname!";
		err=true
		errEleNm= ele.name
		alert(errStr);
		ele.focus();
		return false;
	  }
	 err=false
	 errEleNm= ""
	return true;
}

function checkValidDate(ele,notReq)
{	
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}
	//alert("active element name " + document.activeElement.name ) //+ "length of name " + document.activeElement.name.length )
	
	if(!(notReq))
		notReq=false
	if(notReq && ele.value.length==0)
	{
		errEleNm=""
		err=false
		return true
	}
	
	if (!isValidDate(ele))
	{
		if (errEleNm =="" || ele.name == errEleNm)
		{
			err=true
			errEleNm= ele.name
			alert("Please Enter a Valid Date")
			ele.focus()
			//alert('Please Enter the value for ' + ele.name.substr(3))
			//ele.focus()
			return false
		}
	}
	else
	{
		errEleNm=""
		err=false
		return true
	}
}
function isValidDate(dateStr1) {
	// dateStr must be of format month day year with either slashes
	// or dashes separating the parts. Some minor changes would have
	// to be made to use day month year or another format.
	// This function returns True if the date is valid.
	var dateStr=dateStr1.value;
	var slash1 = dateStr.indexOf("/");
	if (slash1 == -1) { slash1 = dateStr.indexOf("-"); }
	// if no slashes or dashes, invalid date
	if (slash1 == -1) { return false; }
	var dateMonth = dateStr.substring(0, slash1)
	var dateMonthAndYear = dateStr.substring(slash1+1, dateStr.length);
	var slash2 = dateMonthAndYear.indexOf("/");
	if (slash2 == -1) { slash2 = dateMonthAndYear.indexOf("-"); }
	// if not a second slash or dash, invalid date
	if (slash2 == -1) { return false; }
	var dateDay = dateMonthAndYear.substring(0, slash2);
	var dateYear = dateMonthAndYear.substring(slash2+1, dateMonthAndYear.length);
	if ( (dateMonth == "") || (dateDay == "") || (dateYear == "") ) { return false; }
	// if any non-digits in the month, invalid date
	for (var x=0; x < dateMonth.length; x++) {
		var digit = dateMonth.substring(x, x+1);
		if ((digit < "0") || (digit > "9")) { return false; }
	}
	// convert the text month to a number
	var numMonth = 0;
	for (var x=0; x < dateMonth.length; x++) {
		digit = dateMonth.substring(x, x+1);
		numMonth *= 10;
		numMonth += parseInt(digit);
	}
	if ((numMonth <= 0) || (numMonth > 12)) { return false; }
	// if any non-digits in the day, invalid date
	for (var x=0; x < dateDay.length; x++) {
		digit = dateDay.substring(x, x+1);
		if ((digit < "0") || (digit > "9")) { return false; }
	}
	// convert the text day to a number
	var numDay = 0;
	for (var x=0; x < dateDay.length; x++) {
		digit = dateDay.substring(x, x+1);
		numDay *= 10;
		numDay += parseInt(digit);
	}
	if ((numDay <= 0) || (numDay > 31)) { return false; }
	// February can't be greater than 29 (leap year calculation comes later)
	if ((numMonth == 2) && (numDay > 29)) { return false; }
	// check for months with only 30 days
	if ((numMonth == 4) || (numMonth == 6) || (numMonth == 9) || (numMonth == 11)) { 
		if (numDay > 30) { return false; } 
	}
	// if any non-digits in the year, invalid date
	for (var x=0; x < dateYear.length; x++) {
		digit = dateYear.substring(x, x+1);
		if ((digit < "0") || (digit > "9")) { return false; }
	}
	// convert the text year to a number
	var numYear = 0;
	for (var x=0; x < dateYear.length; x++) {
		digit = dateYear.substring(x, x+1);
		numYear *= 10;
		numYear += parseInt(digit);
	}
	// Year must be a 2-digit year or a 4-digit year
	if ( (dateYear.length != 2) && (dateYear.length != 4) ) { return false; }
	// if 2-digit year, use 50 as a pivot date
	if ( (numYear < 50) && (dateYear.length == 2) ) { numYear += 2000; }
	if ( (numYear < 100) && (dateYear.length == 2) ) { numYear += 1900; }
	if ((numYear <= 0) || (numYear > 9999)) { return false; }
	// check for leap year if the month and day is Feb 29
	if ((numMonth == 2) && (numDay == 29)) {
		var div4 = numYear % 4;
		var div100 = numYear % 100;
		var div400 = numYear % 400;
		// if not divisible by 4, then not a leap year so Feb 29 is invalid
		if (div4 != 0) { return false; }
		// at this point, year is divisible by 4. So if year is divisible by
		// 100 and not 400, then it's not a leap year so Feb 29 is invalid
		if ((div100 == 0) && (div400 != 0)) { return false; }
	}
	// date is valid
	return true;
}

function checkValidZip(ele,ziplength,isRequired)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}

	if (ele.value.length == 0 )
	{
		if (isRequired)
		{
			alert("Please Enter Value for the Zip code")
			ele.focus()
			return false
		}
	}
	else if(isNaN(ele.value))
	{
		alert("Please Enter Numeric Values for the Zip code")
		ele.focus()
		return false
	}
	else if(ele.value.length < ziplength)
	{
		alert("Please Enter " + ziplength  + "  Digits for Zip Code")
		ele.focus()
		return false
	}
}

function isPositive(ele,msgfldname)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}
	if ( ele.value < 0 )
	{
		if (errEleNm =="" || ele.name == errEleNm)
		{
			err=true
			errEleNm= ele.name
			alert("Please enter positive value for " + msgfldname )
			ele.focus()
			return false
		}
		else
		{
			errEleNm=""
			err=false
			return true
		}
		
		ele.focus()
		return false
	}
	return true
}

function isNumeric(ele,isRequired,msgfldname)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}
	if (document.activeElement.name != ele.name)
	{
		if (ele.value.length == 0 )
		{
			if (isRequired)
			{
				if (errEleNm =="" || ele.name == errEleNm)
				{
					err=true
					errEleNm= ele.name
					alert("Please Enter Value for the " + msgfldname)
					ele.focus()
					return false
				}
			}
			else
			{
				ele.value="0"
				errEleNm=""
				err=false
				return true
			}
		}
		else if(isNaN(ele.value))
		{
			if (errEleNm =="" || ele.name == errEleNm)
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Numeric Values for the " + msgfldname)
				ele.focus()
				return false
			}
		}
		else
		{
			errEleNm=""
			err=false
			return true
		}
	}
	//return true
}

function isDecimal(ele)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}
	if (isNaN(ele.value))
	{
		alert("Please enter a Decimal value")
		ele.focus()
		return false
	}
}


function checkDollarAmount(ele)
{
	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{
		return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{
		return true
	}
	if (isNaN(ele.value))
	{
		alert("Please enter a Valid Numeric Amount")
		ele.focus()
		return false
	}
}

function OpenWindow(theURL,winName,features) { //v2.0
	var wd,ht,i,tmp;
	var len
	len=features.length
	if(len!=0)
	{
		features=features.toLowerCase()
		for(i=0;i<(len)/4;i++)features=features.replace(" ","")	
		tmp=features.indexOf("width=")+6;
		wd=parseInt(features.substr(tmp));
		tmp=features.indexOf("height=")+7;
		ht=parseInt(features.substr(tmp));
		//if(features.indexOf("top=")==-1)
		features=features+",top=" +((window.screen.height/2)-(ht/2))+",left="+((window.screen.width/2)-(wd/2))
		w=window.open(theURL,winName,features);
		w.focus();
	}else
	{
		w=window.open(theURL,winName,features);
		w.resizeTo(window.screen.width,window.screen.height); 
		w.moveTo(0,0);                		
		w.focus();
	}
	
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
	var wd,ht,i,tmp;
	var len
	len=features.length
	if(len!=0)
	{
		features=features.toLowerCase()
		for(i=0;i<(len)/4;i++)features=features.replace(" ","")	
		tmp=features.indexOf("width=")+6;
		wd=parseInt(features.substr(tmp));
		tmp=features.indexOf("height=")+7;
		ht=parseInt(features.substr(tmp));
		//if(features.indexOf("top=")==-1)
		features=features+",top=" +((window.screen.height/2)-(ht/2))+",left="+((window.screen.width/2)-(wd/2))
		w=window.open(theURL,winName,features);
		w.focus();
	}else
	{
		w=window.open(theURL,winName,features);
		w.resizeTo(window.screen.width,window.screen.height); 
		w.moveTo(0,0);                		
		w.focus();
	}
	
}

//on ,key down
function checkkeydown(field)
{
	var noofdeci;
	//	alert("key down" + event.keyCode)
	if ( event.keyCode != 8 )
	{
		if( field.value.indexOf(".")!= -1 && field.value.substr(field.value.indexOf(".")+1).length>2)
		{
			alert ("Only two Decimal Places allowed Press Back Space to delete the Extra Decimal Place " );
			event.keyCode=0
			event.returnValue=false
		}
	}
}

function checkinteger(field)
{
	if  (!((event.keyCode  >=48 &&  event.keyCode <=57) || event.keyCode==13 ) )
	{
		//alert("Only Numeric Values Allowed");
		event.keyCode=null;
	}
}

//on key press
function checkkey(field)
{
	var noofdeci;
	if  (!((event.keyCode  >=48 &&  event.keyCode <=57) || event.keyCode==46 || event.keyCode==13 ) )
	{
		alert("Only Numeric or Decimal Values Allowed");
		event.keyCode=null;
	}
	else if( field.value.indexOf(".")!= -1 && event.keyCode==46 )
	{
		event.keyCode=null;
	}
	else if(event.keyCode  >=48 &&  event.keyCode <=57)
	{
			
	//	alert(field.value)
	//	if( field.value.indexOf(".")!= -1 && field.value.substr(field.value.indexOf(".")).length>2)
	//	{
	//		event.keyCode=null;			alert ("Only two Decimal Places allowed" );
	//	}
	}
}


function diffTime(starttime,endtime)
{	if(starttime=="" ||endtime=="" )
	{
		return 0;
	}
	var startdate,enddate
	startdate="11/29/2003 " + starttime
	enddate="11/29/2003 " + endtime
	
	var d1=new Date(startdate)
	var d2=new Date(enddate)
	
	return (d1-d2);
}


function diffDateMDY(startdate,enddate)
{
	if(startdate=="" ||enddate=="" )
	{
		return 0;
	}
	var d1=new Date(startdate)
	var d2=new Date(enddate)
	return (d1-d2);
}

//below function is not yet used
function stringToDate(sd1)
{	
	var no;
	var tmp;
	var m,d,y;
	sd1=sd1.replace('-','/');	sd1=sd1.replace('-','/');
	sd1=sd1.replace(',','/');	sd1=sd1.replace(',','/');
	sd1=sd1.replace(';','/');	sd1=sd1.replace(';','/');
	no=0;
	tmp=no;
	no=sd1.indexOf("/",no);
	m=sd1.substring(tmp,no);
	no++;
	tmp=no;
	no=sd1.indexOf("/",no);
	d=sd1.substring(tmp,no);
	no++;
	tmp=no;
	no=no+4;
	y=sd1.substring(tmp,no);
	var d=new Date(y,m,d);
	return d;
}

//for getting date difference using javascript
function DaysDiff(D1, D2) { // Date Objects, with similar times
  return Math.round((D1-D2)/864e5) }

function DiffDays(S1, S2) { // ISO date strings
  var X = ReadISO8601date(S1) ; if (X<0) return 'Date 1 bad'
  var Y = ReadISO8601date(S2) ; if (Y<0) return 'Date 2 bad'
  var Dx = Date.UTC(X[0], X[1]-1, X[2])
  var Dy = Date.UTC(Y[0], Y[1]-1, Y[2])
  return (Dx-Dy)/864e5 }

//function DateDiff(ele1,ele2) { with (document.forms['Frm1']) 
function DateDiff(ele1,ele2)
{
//	alert(ele1.value)
//	alert(ele2.value)
	var Diff1,Diff2
	Diff1 = DaysDiff(new Date(ele1.value.replace(/-/g,'/')),new Date(ele2.value.replace(/-/g, '/')))
    Diff2 = DiffDays(ele1.value.trim(), ele2.value.trim())
//    alert(Diff1)
//    alert(Diff2)
    return Diff2
    //ele1.focus() }
}

function checkTime(ele,isRequired,msgfldname)
{	if( document.activeElement.tagName=="A" )// this condi is needed as if user wants to leave the page without entry
	{	return true
	}
	if( document.activeElement.name=="cmdClose" || document.activeElement.name=="cmdCancel" )
	{	return true
	}
	if (document.activeElement.name != ele.name)
	{	if (ele.value.length == 0 )
		{	if (isRequired)
			{
				if (errEleNm =="" || ele.name == errEleNm)
				{
					err=true
					errEleNm= ele.name
					alert("Please Enter Time for the " + msgfldname)
					ele.focus()
					return false
				}
			}
			else
			{
				ele.value=""
				errEleNm=""
				err=false
				return true
			}
		}
		else 
		{
			st=ele.value;
			
			st=st.replace("/",":");	st=st.replace("/",":");	st=st.replace("/",":");
			st=st.replace("\\",":");st=st.replace("\\",":");st=st.replace("\\",":");
			st=st.replace(" ","");	st=st.replace(" ","");	st=st.replace(" ","");
			st=st.replace(" ","");	st=st.replace(" ","");	st=st.replace(" ","");
			st=st.replace(".",":");	st=st.replace(".",":");	st=st.replace(".",":");

		
			f=st.indexOf(":");	s=st.indexOf(":",f+1)
			
			if(f==-1)
			{
				ssf=st.indexOf("A");
				if(ssf==-1)
					ssf=st.indexOf("a");
				if(ssf==-1)
				{
					ssf=st.indexOf("P");
					if(ssf==-1)
						ssf=st.indexOf("p");
				}
				if(ssf==-1)
				{
					hh=st.substr(f+1);
					mm="00"
					ss="00"
				}else
				{
					hh=st.substr(f+1,ssf-(f+1));
					mm="00";
					ss="00"+st.substr(ssf);
				}

			}else
			{
				if(s==-1)
				{
					hh=st.substr(0,f);

					ssf=st.indexOf("A");
					if(ssf==-1)
						ssf=st.indexOf("a");
					if(ssf==-1)
					{
						ssf=st.indexOf("P");
						if(ssf==-1)
							ssf=st.indexOf("p");
					}
					if(ssf==-1)
					{
						mm=st.substr(f+1);
						ss="00"
					}else
					{
						mm=st.substr(f+1,ssf-(f+1));
						ss="00"+st.substr(ssf);
						
					}
				}else
				{
					
					hh=st.substr(0,f)
					mm=st.substr(f+1,s-(f+1))
					ss=st.substr(s+1)
				}
			}

			ssf=ss.indexOf("A");
			if(ssf==-1)
				ssf=ss.indexOf("a");

			sss=ss.indexOf("P");
			if(sss==-1)
				sss=ss.indexOf("p");

			if(ssf==-1 && sss==-1)
			{
				ss=ss.substr(0,2);
				ampm="AM";
			}else
			{
				
				if(ssf!=-1)
				{	ampm="AM";
					ss=ss.substr(0,ssf);
				}
				else
				{	ampm="PM";
					ss=ss.substr(0,sss);
				}
				
			}
			if(ss=="")ss=0;
			if(mm=="")mm=0;
			if(hh=="")hh=0;

			hh=Number(hh);
			if(isNaN(hh))
			{	err=true
				errEleNm= ele.name
				alert("Please Enter Valid Time(hour) for the " + msgfldname)
				ele.focus()
				return false
			}

			mm=Number(mm);
			if(isNaN(mm))
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Valid Time(minute) for the " + msgfldname)
				ele.focus()
				return false
			}

			ss=Number(ss);
			if(isNaN(ss))
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Valid Time(Second) for the " + msgfldname)
				ele.focus()
				return false
			}
			
			if(hh>=0 && hh<=24)
			{	
				if(hh>12 && hh<=24)
				{	hh=hh-12;
					ampm="PM";
				}
			}else
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Valid Hour for the " + msgfldname)
				ele.focus()
				return false
			}
			if(hh==0)hh=12;
			if(0>mm || mm>=59)
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Valid Minute for the " + msgfldname)
				ele.focus()
				return false
			}

			if(0>ss || ss>=59)
			{
				err=true
				errEleNm= ele.name
				alert("Please Enter Valid Second for the " + msgfldname)
				ele.focus()
				return false
			}
			hh=hh+"";
			if(hh.length==1)hh="0"+hh;
			mm=mm+"";
			if(mm.length==1)mm="0"+mm;
			ss=ss+"";
			if(ss.length==1)ss="0"+ss;
			
			ele.value=(hh+":"+mm+":"+ss+" "+ampm);

			errEleNm="";
			err=false;
			return true;
		}// end of if for len
	}// end of if of active element
	return true;
}

function addNotAddHttp(ele)
{	
	var dst,st,pos;
	st=ele.value;
	dst=st.toUpperCase();
	pos=dst.indexOf("WWW");
	if(pos==-1)
	{	pos=dst.indexOf("HTTP");
		if(!(pos==-1))
			dst=dst.substr(pos+4);
		pos=dst.indexOf(":");
		if(pos==-1)
		{	pos=dst.indexOf("\\\\");
			if(pos==-1)
			{	pos=dst.indexOf("//");
				if(!(pos==-1))
					dst=dst.substr(pos+2);
			}else
				dst=dst.substr(pos+2);
		}else
		{	pos=dst.indexOf("\\\\");
			if(pos==-1)
			{	pos=dst.indexOf("//");
				if(pos==-1)
					dst=dst.substr(1);
				else
					dst=dst.substr(pos+2);
			}else
			{
				dst=dst.substr(pos+2);
			}
		}
	}else
	{	dst=dst.substr(pos+3);
		pos=dst.indexOf(".");
		if(pos==0)
			dst=dst.substr(pos+1);
		if(pos>0)
			dst="WWW"+dst;
	}
	pos=(st.toUpperCase()).indexOf(dst)
	if(!(pos==-1))
	{	st=st.substr(pos);
	}
	st="http://www."+st;
	ele.value=st;
	//return false;
}


function StopSubmitOnEnter()
{
	/*if (event.keyCode==13 )
	{
		if (document.activeElement.tagName=="TEXTAREA")
		{
			return true
		}
		return false
	}*/
	return true
}

function AreDetailsComplete(compfields,compmsgs)
{
	var comfldsArr,msgArr
	var ele
	msgArr=compmsgs.split(",")
//		alert("compmsgs="+compmsgs);
	comfldsArr=compfields.split(",")
		//alert("compfields="+compfields);
		//alert("before for");
	for(var i=0;i<comfldsArr.length;i++)
	{//alert(comfldsArr[i]);
		ele=document.getElementById(comfldsArr[i])
		if(ele==null)
		{
			ele=document.getElementById(comfldsArr[i].toLowerCase())
		}
			//alert("ele="+ele);
		if(comfldsArr[i].substr(0,3).toLowerCase() == "cmb" || comfldsArr[i].substr(0,3).toLowerCase() == "ddl")
		{
			//alert("if");
			if(ele.selectedIndex == 0)
			{
				alert("Please select " + msgArr[i] + " from the list" +".")
				ele.focus()
				return false
			}
		}
		else if(comfldsArr[i].substr(0,3).toLowerCase() != "cmb" && comfldsArr[i].substr(0,3).toLowerCase() != "ddl" && comfldsArr[i].substr(0,3).toLowerCase() != "txt" )
		{
			//in case there is no indication b4 the field whether its a text box or listbox then whole message would have beed passed so display that directly
			//would only work for the textboxes
			//alert("else if");
			if(ele.value == "" )
			{
				alert( msgArr[i] +".")
				ele.focus()
				return false
			}
		}
		else if(ele.value == "")
		{
			//alert("else");
			//alert("mesg="+msgArr[i]);
			alert("Please enter value for " + msgArr[i] +".")
			//alert("Please enter value for " + document.forms[0].elements[i].getAttribute("errmsg"))
			ele.focus()
			return false
		}
	}
	//alert("over");
	return true
}

function AreDetailsComplete1(compfields)
{
	compfields=compfields.toLowerCase()
	for(var i=0;i<document.forms[0].elements.length;i++)
	{
		//alert(document.forms[0].elements[i].name)
		if(compfields.indexOf(document.forms[0].elements[i].name.toLowerCase()) != -1)
		{
			if(document.forms[0].elements[i].name.substr(0,3).toLowerCase() == "cmb")
			{
				if(document.forms[0].elements[i].selectedIndex == 0)
				{
					alert("Please select " + document.forms[0].elements[i].name.substr(3) + " from the list")
					
					document.forms[0].elements[i].focus()
					return false
				}
			}
			if(document.forms[0].elements[i].value == "")
			{
				alert("Please enter value for " + document.forms[0].elements[i].name.substr(3))
				//alert("Please enter value for " + document.forms[0].elements[i].getAttribute("errmsg"))
				document.forms[0].elements[i].focus()
				return false
			}
		}
	}
}

function GetSelectedValuesOfList(sourcelst,destinationtextbox,textORvalue)
{
	//cat=document.getElementById("lstCategoriesSelected")
	cat=sourcelst
	catlen=cat.length
	//txt=document.getElementById('categories')
	txt=destinationtextbox
	txt.value=""
	for (i=0; i<catlen ; i++)
	{
		if (textORvalue=='text')
		{
			txt.value=txt.value+ ";" +  cat.options[i].text
		}
		else if (textORvalue=='value')
		{
			txt.value=txt.value+ ";" +  cat.options[i].value
		}
	}
	txt.value=txt.value+ ";" 
}

function MoveElementBetweenListBoxes(source,destination)
{
	var list1,list2
	list1=source
	list2=destination

	list1len = list1.length;//get the no of elements in the categories list
	for (i=0; i<list1len ; i++)
	{
		if (list1.options[i].selected == true )
		{
			list2len= list2.length;
			list2.options[list2len]= new Option(list1.options[i].text);
			list2.options[list2len].value=list1.options[i].value;
		}
	}
	for ( i = (list1len -1); i>=0; i--)
	{
		if (list1.options[i].selected == true ) 
		{
			list1.options[i] = null;
		}
	}
	return false
}
function IsAnyCompFieldEntered(compfields)
{
	var comfldsArr
	var ele
	comfldsArr=compfields.toLowerCase().split(",")
	for(var i=0;i<comfldsArr.length;i++)
	{
		ele=document.getElementById(comfldsArr[i])
		//alert(ele.name)
		if(comfldsArr[i].substr(0,3).toLowerCase() == "cmb" || comfldsArr[i].substr(0,3).toLowerCase() == "ddl")
		{
			if(ele.selectedIndex != 0)
			{
				return true
			}
		}
		else if(ele.value != "")
		{
			return true
		}
	}
	return false
}
		

function doub(arr)
{
	for(i=0; i< arr[0].length;i++)
	{
		alert(arr[0][i])
	}
	
}

function GetCategories()
{//alert('in function ');
	//cat=categories selected
	cat=document.getElementById("lstCategoriesSelected")
	catlen=cat.length
	txt=document.getElementById('categories')
	//alert(txt.value)
	if (txt.value =='Logistic Services')
		{//alert('function complete');
		}
		else{
		txt.value=""
		for (i=0; i<catlen ; i++)
		{
			txt.value=txt.value+ ";" +  cat.options[i].value
		}
		txt.value=txt.value+ ";" 
		if ( txt.value==";" )
		{
			txt.value="" 
		}
	}
	//alert('function complete')
}


/*function fill_state(statelist,countrylist,){
	with(document.form1)
	{
		for(var i=state.length;i>=0;i--){state.options[i] = null;}//remove all the elements from the state list
		var index = 0;
		<%for(int i=0;i<=v_state.size()-1;i+=3){%>if(country[country.selectedIndex].value == "<%=v_state.get(i+1)%>")
		{
			state.options[index] = new Option('<%=v_state.get(i+2)%>','<%=v_state.get(i)%>');
			if("<%=admin.state%>" == state.options[index].value){state.options[index].selected=true;}
			index++;}<%}%>
	}
}*/
