// -- Adobe GoLive JavaScript Library
// -- Global Functions
CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
CSIsW3CDOM = ((document.getElementById) && !(IsIE()&&CSBVers<6)) ? true : false;
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
function CSIEStyl(s) { return document.all.tags("div")[s].style; }
function CSNSStyl(s) { if (CSIsW3CDOM) return document.getElementById(s).style; else return CSFindElement(s,0);  }
CSIImg=false;
function CSInitImgID() {if (!CSIImg && document.images) { for (var i=0; i<document.images.length; i++) { if (!document.images[i].id) document.images[i].id=document.images[i].name; } CSIImg = true;}}
function CSFindElement(n,ly) { if (CSBVers<4) return document[n];
	if (CSIsW3CDOM) {CSInitImgID();return(document.getElementById(n));}
	var curDoc = ly?ly.document:document; var elem = curDoc[n];
	if (!elem) {for (var i=0;i<curDoc.layers.length;i++) {elem=CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
	return elem;
}
function CSGetImage(n) {if(document.images) {return ((!IsIE()&&CSBVers<5)?CSFindElement(n,0):document.images[n]);} else {return null;}}
CSDInit=false;
function CSIDOM() { if (CSDInit)return; CSDInit=true; if(document.getElementsByTagName) {var n = document.getElementsByTagName('DIV'); for (var i=0;i<n.length;i++) {CSICSS2Prop(n[i].id);}}}
function CSICSS2Prop(id) { var n = document.getElementsByTagName('STYLE');for (var i=0;i<n.length;i++) { var cn = n[i].childNodes; for (var j=0;j<cn.length;j++) { CSSetCSS2Props(CSFetchStyle(cn[j].data, id),id); }}}
function CSFetchStyle(sc, id) {
	var s=sc; while(s.indexOf("#")!=-1) { s=s.substring(s.indexOf("#")+1,sc.length); if (s.substring(0,s.indexOf("{")).toUpperCase().indexOf(id.toUpperCase())!=-1) return(s.substring(s.indexOf("{")+1,s.indexOf("}")));}
	return "";
}
function CSGetStyleAttrValue (si, id) {
	var s=si.toUpperCase();
	var myID=id.toUpperCase()+":";
	var id1=s.indexOf(myID);
	if (id1==-1) return "";
	s=s.substring(id1+myID.length+1,si.length);
	var id2=s.indexOf(";");
	return ((id2==-1)?s:s.substring(0,id2));
}
function CSSetCSS2Props(si, id) {
	var el=document.getElementById(id);
	if (el==null) return;
	var style=document.getElementById(id).style;
	if (style) {
		if (style.left=="") style.left=CSGetStyleAttrValue(si,"left");
		if (style.top=="") style.top=CSGetStyleAttrValue(si,"top");
		if (style.width=="") style.width=CSGetStyleAttrValue(si,"width");
		if (style.height=="") style.height=CSGetStyleAttrValue(si,"height");
		if (style.visibility=="") style.visibility=CSGetStyleAttrValue(si,"visibility");
		if (style.zIndex=="") style.zIndex=CSGetStyleAttrValue(si,"z-index");
	}
}
function CSScriptInit() {
if(typeof(skipPage) != "undefined") { if(skipPage) return; }
idxArray = new Array;
for(var i=0;i<CSInit.length;i++)
	idxArray[i] = i;
CSAction2(CSInit, idxArray);
}
CSInit = new Array;
CSExit = new Array;
CSStopExecution=false;
function CSAction(array) {return CSAction2(CSAct, array);}
function CSAction2(fct, array) { 
	var result;
	for (var i=0;i<array.length;i++) {
		if(CSStopExecution) return false; 
		var aa = fct[array[i]];
		if (aa == null) return false;
		var ta = new Array;
		for(var j=1;j<aa.length;j++) {
			if((aa[j]!=null)&&(typeof(aa[j])=="object")&&(aa[j].length==2)){
				if(aa[j][0]=="VAR"){ta[j]=CSStateArray[aa[j][1]];}
				else{if(aa[j][0]=="ACT"){ta[j]=CSAction(new Array(new String(aa[j][1])));}
				else ta[j]=aa[j];}
			} else ta[j]=aa[j];
		}			
		result=aa[0](ta);
	}
	return result;
}
CSAct = new Object;
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
mustInitImg = true;
function initImgID() {di = document.images; if (mustInitImg && di) { for (var i=0; i<di.length; i++) { if (!di[i].id) di[i].id=di[i].name; } mustInitImg = false;}}
function findElement(n,ly) {
	d = document;
	if (browserVers < 4)		return d[n];
	if ((browserVers >= 6) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
function changeImages() {
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (d.layers) {img = findElement(changeImages.arguments[i],0);}
			else {img = d.images[changeImages.arguments[i]];}
			if (img) {img.src = changeImages.arguments[i+1];}
		}
	}
}
function CSClickReturn () {
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName;
	if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
		return true; // dont follow link
	else return false; // dont follow link
}
// -- Action Functions
function CSCloseWindow() { 
if (self.parent.frames.length != 0) {
	self.parent.close()	
	} else {
	window.close()
	}
}
function CSRandomImg(action) { 
	var img = CSGetImage(action[1]);
	if (img) 
		{
		var v1 =  Math.floor(Math.random() * 10);
		var whichone = v1-(Math.floor(v1/3)*3);
		img.src = action[whichone+2];
		}
}
function CSOpenWindow(action) {
	var wf = "";	
	wf = wf + "width=" + action[3];
	wf = wf + ",height=" + action[4];
	wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
	wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
	wf = wf + ",menubar=" + (action[7] ? "yes" : "no");
	wf = wf + ",toolbar=" + (action[8] ? "yes" : "no");
	wf = wf + ",directories=" + (action[9] ? "yes" : "no");
	wf = wf + ",location=" + (action[10] ? "yes" : "no");
	wf = wf + ",status=" + (action[11] ? "yes" : "no");		
	window.open(action[1],action[2],wf);
}
/*--Displays the privacy statement pop-up window--*/
function showPriv() {
  PopWin=window.open("../coupons/window.htm","Privacy","width=475,height=125,resizable=no");
}

/*--Validates user input from Pumpkin Festival Coupon--*/

function CheckInput(){
	if (document.Coupon.FName.value ==""){
		alert("Please enter your First Name.");
		document.Coupon.FName.focus();
		return false;
	}
	if (document.Coupon.LName.value ==""){
		alert("Please enter your Last Name.");
		document.Coupon.LName.focus();
		return false;
	}
	if (document.Coupon.Address.value ==""){
		alert("Please enter your Address.");
		document.Coupon.Address.focus();
		return false;
	}
	if (document.Coupon.City.value ==""){
		alert("Please enter your City.");
		document.Coupon.City.focus();
		return false;
	}
	if (document.Coupon.State.value ==""){
		alert("Please enter your State.");
		document.Coupon.State.focus();
		return false;
	}
	if (document.Coupon.Zip.value ==""){
		alert("Please enter your Zip Code.");
		document.Coupon.Zip.focus();
		return false;
	}
	if (document.Coupon.email.value ==""){
		alert("Please enter your e-mail Address.");
		document.Coupon.email.focus();
		return false;
	}
	if (document.Coupon.email2.value ==""){
		alert("Please enter your e-mail Address.");
		document.Coupon.email2.focus();
		return false;
	}
		
	var email1, email2;
	email1 = document.Coupon.email.value;
	email2 = document.Coupon.email2.value;
	if (email1 != email2){
		alert("The e-mail fields do not match!");
		document.Coupon.email.focus();
		return false;
	}
}


// is_date()
// Tests a given string value to determine if it contains a valid date expression.
// The following formats are recognized
// MM    : one or two digit month
// MMM   : month abbreviation (jan, feb, etc)
// DD    : one or two digit day
// YY    : two digit year
// YYYY  : four digit year
// Month : Full month name, case insensitive
//
// MM/DD/YY
// MM/DD/YYYY
// MMM/DD/YY
// MMM/DD/YYYY
// Month/DD/YY
// Month/DD/YYYY
// YYYY-MM-DD
// YYYY-MMM-DD
// YYYY-Month-DD
// MMM DD, YY
// MMM DD, YYYY
// Month DD, YY
// Month DD, YYYY
//
// Delimiters between date parts may take the form of
// a forward slash (/), a comma (,), a dash (-), a period(.), or a blank space

function is_date(strValue)
{
	var intPosition;
	var intMonth;
	var intDay;
	var intYear;
	var strMonth;
	var strDay;
	var strYear;
	var strValidTokens;
	var intFirstTokenIndex;
	var intSecondTokenIndex;
	var strFirstToken;
	var strSecondToken;
	var strChar;
	var strParts = new Array(2);
	var i;

	if(!strValue || strValue == "")
	{
		return false;
	}

	strValidTokens = "/-., ";

	intFirstTokenIndex = -1;
	intSecondTokenIndex = -1;

	for(i=0; i<strValue.length; i++)
	{
		strChar = strValue.charAt(i);
		if(strValidTokens.indexOf(strChar) > -1)
		{
			intFirstTokenIndex = i;
			strFirstToken = strChar;
			break;
		}
	}

	if(intFirstTokenIndex == -1 || intFirstTokenIndex > strValue.length - 2)
	{
		return false;
	}

	for(i=intFirstTokenIndex + 1; i<strValue.length; i++)
	{
		strChar = strValue.charAt(i);
		if(strValidTokens.indexOf(strChar) > -1)
		{
			intSecondTokenIndex = i;
			strSecondToken = strChar;
			break;
		}
	}

	if(intSecondTokenIndex == -1 || intSecondTokenIndex == strValue.length - 1)
	{
		return false;
	}

	strParts[0] = strValue.slice(0, intFirstTokenIndex);
	strParts[1] = strValue.slice(intFirstTokenIndex + 1, intSecondTokenIndex);
	strParts[2] = strValue.slice(intSecondTokenIndex + 1, strValue.length);

	for(i=0; i<3; i++)
	{
		while(strParts[i].charAt(0) == " ")
		{
			strParts[i] = strParts[i].slice(1,
			strParts[i].length);
		}

		while(strParts[i].charAt(strParts[i].length - 1) == " ")
		{
			strParts[i] = strParts[i].slice(0,
			strParts[i].length - 1);
		}

		if(strParts[i] == "")
		{
			return false;
		}
	}


	if(strParts[0].length == 4)
	{
		intYear = parseInt(strParts[0])
		if(isNaN(intYear))
		{
			strMonth = strParts[0];
			strDay = strParts[1];
			strYear = strParts[2];
		}
		else
		{
			strYear = strParts[0];
			strMonth = strParts[1];
			strDay = strParts[2];
		}
	}
	else
	{
		strMonth = strParts[0];
		strDay = strParts[1];
		strYear = strParts[2];
	}

	if(strDay.length > 2)
	{
		return false;
	}

	if(strDay.length == 2 && strDay.charAt(0) == "0")
	{
		strDay = strDay.charAt(1);
	}

	intDay = parseInt(strDay);
	if(isNaN(intDay))
	{
		return false;
	}

	if(strYear.length != 2 && strYear.length != 4)
	{
		return false;
	}

	if(strYear.length == 2 && strYear.charAt(0) == "0")
	{
		strYear = strYear.charAt(1);
	}

	intYear = parseInt(strYear);
	if(isNaN(intYear))
	{
		return false;
	}

	if(strMonth.length < 3)
	{
		if(strMonth.length == 2 && strMonth.charAt(0) == "0")
		{
			strMonth = strMonth.charAt(1);
		}
		intMonth = parseInt(strMonth);
		if(isNaN(intMonth))
		{
			return false;
		}
	}
	else
	{
		var strMonths;
		var strMonthAbbrevs;

		strMonth = strMonth.toLowerCase();
		strMonths = new
		Array("january","february","march","april","may","june","july","august","september","october","november","december");
		strMonthAbbrevs = new
		Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");

		intMonth = -1;
		for(i=0; i<12; i++)
		{
			if(strMonth == strMonths[i] || strMonth == strMonthAbbrevs[i])
			{
				intMonth = (i + 1);
				break;
			}
		}

		if(intMonth == -1)
		{
			return false;
		}
	}

	if(intYear < 0 || intDay < 1 || intDay > 31 || intMonth < 1 ||intMonth > 12)
	{	
		return false;
	}

	switch(intMonth)
	{
		case 2:
		if(intYear % 4 == 0 && intDay > 29)
		{
			return false;
		}

		if(intYear % 4 != 0 && intDay > 28)
		{
			return false;
		}
			break;
		case 4:
		case 6:
		case 9:
		case 11:
		if(intDay > 30)
		{
			return false;
		}
			break;
	}

	return true;
}


function preloadImages() {
	if (document.images) {
		over_Visit = newImage(/*URL*/'../Graphics/images/NavigationImages/VisitOver.gif');
		over_Events4 = newImage(/*URL*/'../Graphics/images/NavigationImages/EventsOver.gif');
		over_Visit3 = newImage(/*URL*/'../Graphics/images/NavigationImages/PoultryOver.gif');
		over_Events3 = newImage(/*URL*/'../Graphics/images/NavigationImages/SaveFarmOver.gif');
		over_Events5 = newImage(/*URL*/'../Graphics/images/NavigationImages/AboutOver.gif');
		over_Events6 = newImage(/*URL*/'../Graphics/images/NavigationImages/StoreOver.gif');
		over_Events7 = newImage(/*URL*/'../Graphics/images/NavigationImages/NewsletterOver.gif');
		over_Events8 = newImage(/*URL*/'../Graphics/images/NavigationImages/SearchOver.gif');
		preloadFlag = true;
	}
}

//*-displays YF Map in pop up
function MapPrint() {
	var url = "Map.html";
	var options = "width=750, height=550, menubar=no, status=no, location=no, toolbar=yes, scrollbars=yes, resizable=yes";
	window.open(url,"Printer",options);
}

//*-Displays picture in a pop up
var stdOptions2 = "resizable=no,directories=no,toolbar=no,scrollbars=no";
function showPic(name, width, height){
	var screenW = screen.availWidth;
	var screenH = screen.availHeight;
	var newWidth = (screenW - width)/2;
	var newHeight = (screenH - height)/2;
	var pic = name;
	var url = "../ShowPics.asp?name=" + pic;
	var options = stdOptions2 + ",left=" + newWidth + ",top=" + newHeight + ",width=" + width + ",height=" + height;
	window.open(url,"pictures",options);
}

function showPage(){
	url = "../Fire.asp";
	window.open(url,"Fire",stdOptions2);
}

function focus(){
	document.login.user.focus();
}
function cancel(){
	history.back();
}

function check(form) 
{
	var strValue = form;   	
    	if (strValue != '')
     {
     	if (!(isCurrency(strValue)))
          {
          	alert('Please enter a valid currency for Cost.');
          	return false;
          }
	}
}
function isCurrency(strValue)
{
	objRegExp = /\)|\(|[,]|[$]/g;
	var strValue_Temp = strValue.replace(objRegExp,'');

	if (isNumeric(strValue_Temp))


		{
			//BEGINS with NUMBER AND NUMBER = 1,000,000 | 1.99 . . . 
			objRegExp = /^([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$|^([0-9]?\.)([0-9][0-9])$/;
			if (objRegExp.test(strValue))


				{
					return objRegExp.test(strValue);
				}
				//BEGINS with $ AND NUMBER = 1,000,000 | 1.99 . . . 
				objRegExp = /^(\${1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$|^(\${1}[0-9]?\.)([0-9][0-9])$/;
				if (objRegExp.test(strValue))


				{
					return objRegExp.test(strValue);
				}		
				//BEGINS with $- AND NUMBER = 1,000,000 | 1.99 . . . 
				objRegExp = /^(\${1}[-]{1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$|^(\${1}[-]{1}[0-9]?\.)([0-9][0-9])$/;
				if (objRegExp.test(strValue))


					{
						return objRegExp.test(strValue);
					}		
					//BEGINS with -$ AND NUMBER = 1,000,000 | 1.99 . . . 
					objRegExp = /^([-]{1}\${1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$|^([-]{1}\${1}[0-9]?\.)([0-9][0-9])$/;
					if (objRegExp.test(strValue))


						{
							return objRegExp.test(strValue);
						}	
						//BEGINS with - AND NUMBER = 1,000,000 | 1.99 . . . 
						objRegExp = /^([-]{1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$|^([-]{1}[0-9]?\.)([0-9][0-9])$/;
						if (objRegExp.test(strValue))


							{
								return objRegExp.test(strValue);
							}		
							//BEGINS with ( ENDS WITH ) AND NUMBER = 1,000,000 | 1.99 . . . 
							objRegExp = /^(\({1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)((\.[0-9][0-9]\){1})$|(\){1})$)|^(\({1}\.{1})([0-9][0-9]\){1})$/;
							if (objRegExp.test(strValue))


								{
									return objRegExp.test(strValue);
								}		
								//BEGINS with ($ ENDS WITH ) AND NUMBER = 1,000,000 | 1.99 . . . 
								objRegExp = /^(\({1}\${1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)((\.[0-9][0-9]\){1})$|(\){1})$)|^(\(\${1}{1}\.{1})([0-9][0-9]\){1})$/;
								if (objRegExp.test(strValue))


								{
									return objRegExp.test(strValue);
								}	
								//BEGINS with $( ENDS WITH ) AND NUMBER = 1,000,000 | 1.99 . . . 
								objRegExp = /^(\${1}\({1})([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)((\.[0-9][0-9]\){1})$|(\){1})$)|^(\${1}\({1}\.{1})([0-9][0-9]\){1})$/;
								if (objRegExp.test(strValue))


									{
										return objRegExp.test(strValue);
									}					
									return false
								}
								else


									{
										return false;
									}
							   }

							   function isNumeric(strValue)


								  {
									var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 

									//check for numeric characters 
									return objRegExp.test(strValue);
							   }


function navDrop(dropBox, bOx){

<!-- the box offsetTop is used if the nav bar is part of a  larger table (as they usually are) -->
<!-- the box offsetTop determines how far the current cell is from the top of the large table -->
<!-- the box offsetHeight is added to the offsetTop otherwise the dropdown menu would begin at the top of the cell -->
<!-- the window.main.offsetTop is the distance determines how far the large table is from the margine of the window and is added to the other values -->
<!-- window.body.offsetTop determines how large the top margine is and is added to the rest of the numbers -->
var Top = bOx.offsetTop + bOx.offsetHeight + window.main.offsetTop + window.body.offsetTop
<!-- like the offsets above the offsetLeft values are basicly the same except horizontal but you dont need the width of the cell so that is left out -->
var Left = bOx.offsetLeft + window.main.offsetLeft + window.body.offsetLeft
<!-- these next lines set the top and left values of the drop down menu to the variables above and sets the boxs visibility to visible -->
dropBox.style.left = Left
dropBox.style.top = Top
dropBox.style.visibility = 'visible'
}

function navRemove(dropBox){
<!-- this hides the dropdown menu when the mouse moves off the link or the dropdown menu -->
dropBox.style.visibility = 'hidden'
}

function stayUp(dropBox){
<!-- this keeps the dropdown menu visible when the mouse moves off the link and onto the dropdown menu area -->
dropBox.style.visibility = 'visible'
}



/* 
    This is the source code for the validation function. 
    Add the following code just after the </HEAD> in the files where the 
    generalised validation functionality is required. 
    <SCRIPT language="JavaScript1.2" src="gen_validation.js"></SCRIPT> 
*/ 

    /* 
    *   File : gen_validation.js 
    *     
    *   Author : Prasanth M J 
    *   
    *   CreativeProgrammers.com - 
	*	Turn your Programming Expertise into Achievements!
    *   Visit http://www.creativeprogrammers.com 
    *     
    *   Email : prasanth@creativeprogrammers.com
    */ 
//---------------------------------EMail Check ------------------------------------ 

/*  checks the validity of an email address entered 
*   returns true or false 
*   
*/ 

function validateEmail(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

/* function validateData 
*  Checks each field in a form 
*  Called from validateForm function 
*/ 
function validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 

    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
        case "email": 
          { 
               if(!validateEmail(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
            if(!objValue.value.match(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name+": Invalid characters found "; 
              }//if                                                               
              alert(strError); 
              return false;                   
            }//if 
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect
         case "iscurrency":
         {
         	if (!(isCurrency(objValue.value)))
	    	{
	    		if(!strError || strError.length ==0) 
               { 
              	 strError = objValue.name + " : Required Field"; 
              	}//if 
              	alert(strError); 
              	return false;
           }//if
           break;
         	}//case iscurrency
         case "isdate":
         {
         	if (!(is_date(objValue.value)))
         	{
         		if(!strError || strError.length ==0) 
			{ 
			 strError = objValue.name + " : Required Field"; 
			}//if 
			alert(strError); 
			return false;
         	}//if
         	break;
         }//case isdate
         	
    }//switch 
    return true; 
} 

/* 
* function validateForm 
* the function that can be used to validate any form 
* returns false if the validation fails; true if success 
* arguments : 
*   objFrm     : the form object 
*   arrObjDesc : an array of objects describing the validations to conduct on each 
*        input item. 
*          The array should consist of one object per input item in the order the input 
*          elements are present in the form. Each object consist of zero or more validation 
*          objects. Each of these validation object is a pair consisting of the validation 
*          descriptor string and an optional Error message. 
*/ 

function validateForm(objFrm,arrObjDesc) 
{ 
 for(var itrobj=0; itrobj < arrObjDesc.length; itrobj++) 
 { 
   if(objFrm.elements.length <= itrobj) 
   { 
        alert("BUG: Obj descriptor for a non existent form element"); 
        return false; 
   }//if 
   for(var itrdesc=0; itrdesc < arrObjDesc[itrobj].length ;itrdesc++) 
   { 
      if(validateData(arrObjDesc[itrobj][itrdesc][0], 
                 objFrm[itrobj],arrObjDesc[itrobj][itrdesc][1]) == false) 
       { 
	     objFrm[itrobj].focus();
         return false; 
       }//if 
   }//for 
 }//for 
} 

function test(){
	alert ("It Works");
	return false;
}

//++++++++++++++++++++++++++
//Called from Youngschew.asp
//++++++++++++++++++++++++++
var objWindow;
var textbox;

function reset_textbox_on_child(x)
{
	textbox = x;
	setTimeout("objWindow.set_date_textbox(document.forms[textbox].os1, window)", 1000);
}
function ReadForm(obj1) { // process un-named selects
  var i,amt,des,obj,pos,val,qua,num="";
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description
  qua = 0;
  for (i=0; i<obj1.length; i++) {     // run entire form
    obj = obj1.elements[i];           // a form element
    if (obj.type == "select-one" &&   // just get selects
	   obj.name == "") {             // must be un-named
	 pos = obj.selectedIndex;        // which option selected
	 qua = qua + pos;
	 val = obj.options[pos].value;   // selected value
	 pos  = val.indexOf ("@");       // price set?
	 if (pos >= 0) amt = val.substring (pos + 1)*1.0;
	 pos  = val.indexOf ("+");       // price increment?
	 if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
	 pos  = val.indexOf ("%");       // percent change?
	 if (pos >= 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
	 pos  = val.indexOf ("#");       // item number?
	 if (pos > 0) {                  //  yes
	   num = val.substring (pos + 1);// get number, and rest of line
	   val = val.substring (0, pos); // lop off some stuff
	   pos = num.indexOf (" ");      // end it with space
	   if (pos > 0) num = num.substring (0, pos);
	 }
	 if (des.length == 0) des = val;
	 else des = des + ", " + val;    // accumulate value
    }
  }
  if (obj1.item_number && num.length > 0) obj1.item_number.value = num;
  obj1.amount.value = amt;
  obj1.tot.value = qua;
  if (obj1.tot.value > 9){
	alert ("You can only select 9 items.");
	return false;
  }
}

function SendForm(obj1) { // process un-named selects
var i,amt,des,obj,pos,val,qua,num="";
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description
  qua = 0;
  for (i=0; i<obj1.length; i++) {     // run entire form
    obj = obj1.elements[i];           // a form element
    if (obj.type == "select-one" &&   // just get selects
	   obj.name == "") {             // must be un-named
	 pos = obj.selectedIndex;        // which option selected
	 qua = qua + pos;
	 val = obj.options[pos].value;   // selected value
	 pos  = val.indexOf ("@");       // price set?
	 if (pos >= 0) amt = val.substring (pos + 1)*1.0;
	 pos  = val.indexOf ("+");       // price increment?
	 if (pos >= 0) amt = amt + val.substring (pos + 1)*1.0;
	 pos  = val.indexOf ("%");       // percent change?
	 if (pos >= 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
	 pos  = val.indexOf ("#");       // item number?
	 if (pos > 0) {                  //  yes
	   num = val.substring (pos + 1);// get number, and rest of line
	   val = val.substring (0, pos); // lop off some stuff
	   pos = num.indexOf (" ");      // end it with space
	   if (pos > 0) num = num.substring (0, pos);
	 }
	 if (des.length == 0){
		des = val;
	 }else{
		des = des + ", " + val;    // accumulate value
	 }
    }
  }
  if (obj1.item_number && num.length > 0) obj1.item_number.value = num;
  obj1.os0.value = des;
  obj1.amount.value = amt;
  obj1.tot.value = qua;
  if (obj1.tot.value > 9){
	alert ("You can only select 9 items.");
	return false;
  }
  if (obj1.tot.value < 9){
	alert ("You must select 9 items.");
	return false;
  }
  return true;
}

function SubClear (obj1) {  // submit, then clear a FORM
  if (SendForm(obj1,true)) {
    obj1.target = 'paypal';
    obj1.submit();
    obj1.reset();
  }
  return false;
}


// EOF