//Javascript Functions

// Netscape Hover Effects
// Copyright 1998 InsideDHTML.com, LLC. All rights reserved.
// www.insideDHTML.com
// This script can be reused as long as this copyright notice
// is not removed.

var ns4 = (document.layers)

function showHover(ev) {
  this._layer.visibility = "hidden"  
  this._layer._hover.visibility = "show"  
  // Position the layer
  if (ev.type=="mouseover") {
    this._layer._hover.top = this.y
    this._layer._hover.left = this.x
  }
}


function CreateHover(layerID, hoverText) {
  hoverLayer = new Layer(300)
  hoverLayer.document.write(hoverText)
  hoverLayer.document.close()
  hoverLayer.document.links[0]._layer = hoverLayer
  hoverLayer.document.links[0].onmouseout = showHover
  var oLayer = document.layers[layerID]
  hoverLayer._hover = oLayer
  oLayer._hover = hoverLayer
  oLayer.document.links[0]._layer = oLayer
  oLayer.document.links[0].onmouseover = showHover  
}

function DoLoad() {
// Create the hover effect for Netscape Navigator
	if (ns4) {
		// pass in the ID of the element and the HTML representing the hover effect.
		CreateHover("myAccount","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">MY ACCOUNT</a></strong>")
		document["myAccount"].visibility = "show"
		CreateHover("earnPoints","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">EARN POINTS</a></strong>")
		document["earnPoints"].visibility = "show"
		CreateHover("redeemPoints","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">REDEEM POINTS</a></strong>")
		document["redeemPoints"].visibility = "show"
		CreateHover("customerSupport","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">CUSTOMER SUPPORT</a></strong>")
		document["customerSupport"].visibility = "show"
		CreateHover("contactUs","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">Contact Us</a></strong>")
		document["contactUs"].visibility = "show"
		CreateHover("siteMap","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">Site Map</a></strong>")
		document["siteMap"].visibility = "show"
		CreateHover("privacyPolicy","<strong><a href=\"#\" class=\"navLevel1BodyNetscapehover\">Privacy Policy</a></strong>")
		document["privacyPolicy"].visibility = "show"
	}
}
 
window.onload = DoLoad;

//Slide Show
	// Set slideShowSpeed (milliseconds)
	var slideShowSpeed = 7000

	// Duration of crossfade (seconds)
	var crossFadeDuration = 4

	// Specify the image files
	//var Pic = new Array() // don't touch this
	// to add more images, just continue
	// the pattern, adding to the array below

	//Pic[0] = '/images/header_houseOfRaeford.jpg'; Pic[1] = '/images/header_schwans.jpg'; Pic[2] = '/images/header_tyson.jpg'; Pic[3] = '/images/header_hatfield.jpg'; Pic[4] = '/images/header_lambWeston.jpg'; Pic[5] = '/images/header_farmland.jpg';

	// =======================================
	// do not edit anything below this line
	// =======================================

	var t
	var j = 0
	//var p = Pic.length

	//var preLoad = new Array()
//	for (i = 0; i < p; i++){
//	   preLoad[i] = new Image()
//	   preLoad[i].src = Pic[i]
//	}

	function runSlideShow(){
	/*   if (document.all){
		  document.images.SlideShow.style.filter='blendTrans(duration=3)'
		  document.images.SlideShow.style.filter='blendTrans(duration=crossFadeDuration)'
		  document.images.SlideShow.filters.blendTrans.Apply()      
	   }
	   document.images.SlideShow.src = preLoad[j].src
	   if (document.all){
		  document.images.SlideShow.filters.blendTrans.Play()
	   }
	   j = j + 1
	   if (j > (p-1)) j=0
	   t = setTimeout('runSlideShow()', slideShowSpeed)*/
	}



<!-- 
//
function popImage(imgWidth, imgHeight, imgSrc){
        //fix for margins\\
        if(navigator.appName == 'Netscape'){imgWidth += 10;imgHeight += 10;}else{imgWidth += 20;imgHeight += 50;}       
        bob = window.open(imgSrc,"bob",'resizable=no,toolbar=no,scrollbars=yes,directories=no,menubar=no,status=no,width=' + imgWidth + ',height=' + imgHeight + "'");
        bob.focus();
        //IE code
        if(navigator.appName != 'Netscape'){bob.resizeTo(imgWidth,imgHeight)}
}
// -->

<!-- 
// Popup Calendar
function popUpCalendar(startIndex) {
	if (navigator.appName.indexOf("Explorer") == -1) {
		// netscape
		timer = window.open("/calendarframe.asp",'calendar','location=no,scrollbars=no,resizable=no,toolbar=no,status=no,width=262,height=200');
	} else {
		// IE
		timer = window.open("/calendarframe.asp",'calendar','location=no,scrollbars=no,resizable=no,toolbar=no,status=no,width=262,height=200');
	}
	timer.startIndex=startIndex;
	timer.parentwindow = self.window;
	timer.focus();
}

function selectAll(formObj, isReset) {
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if(isReset) fldObj.checked = false;
         else fldObj.checked = true; 
       }
   }
}


function updateSelectedProducts (formObj,iFrameName,iFrameURL) {
	var tempString="";
	var isFirst=true;
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if (fldObj.checked) {
				if (isFirst) isFirst = false;
				else tempString += "=&";
				tempString += fldObj.value;
			}
       }
   }
	tempString += "=";
	frames[iFrameName].location.href=iFrameURL+'?'+tempString;
}


//For Product_ProductGroup purpose
function updateSelectedProductsTest (formObj,iFrameURL) {
	var tempString="";
	var isFirst=true;
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if (fldObj.checked) {
				if (isFirst) isFirst = false;
				else tempString += "=&";
				tempString += fldObj.value;
			}
       }
   }
	tempString += "=";
	location.href=iFrameURL+'?'+tempString;
}

//Product_ProductGroup Purpose end




function updateSelectedCustomer(formObj,iFrameName,iFrameURL,formObj2) {
	var tempString="";
	var isFirst=true;
	var counter;
	counter=0;
	
	
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if (fldObj.checked) {
				if (isFirst) isFirst = false;
				else tempString += "=&";counter=counter+1;
				tempString += fldObj.value;
			}
       }
   }
  	tempString += "=";
	//////alert(formObj.name);
	
	for (var ii=0;ii < formObj2.length;ii++) {
      fldObj = formObj2.elements[ii];
	  
      if (fldObj.type == 'checkbox') { 
        counter=counter+1;
		
       }
   
   }
	
	if(counter<501)
	{
	frames[iFrameName].location.href=iFrameURL+'?'+tempString;
	}
	else
	{
	       alert("The maximum number of participants on a Program can be 500");	
		}

}



function updateSelectedCustomerAgain (formObj,iFrameName,iFrameURL) {
	var tempString="";
	var isFirst=true;
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if (fldObj.checked) {
				if (isFirst) isFirst = false;
				else tempString += "=&";
				tempString += fldObj.value;
			}
       }
   }
	tempString += "=";
	frames[iFrameName].location.href=iFrameURL+'?'+tempString;
}











function updateSelectedParticipants (formObj,pageURL) {
	var tempString="";
	var isFirst=true;
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { 
         if (fldObj.checked) {
				tempString += fldObj.name + '=' + fldObj.value + '&';
			}
       }
   }
	return pageURL + '?' + tempString;
}


function checkDate(strDate,returnTo)
{
j=0;
for (i=0;i<returnTo.length;i++)
{
	if (returnTo.charAt(i)=="&")
	j=j+1;
}
for (i=0;i<j;i++)
{
returnTo=returnTo.replace("&","**");
}
returnTo=returnTo.replace("?","*");

location.href="/select_date.asp?path=" + returnTo+ "&date="+strDate;

//alert("select_date.asp?path=" + returnTo+ "&date="+strDate);
//?path=" + returnTo+ "&date="+strDate);
}




function Trim(strText) { 

    if (strText==null) 
	{ strText = '';
	}
	  
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
     while (strText.substring(0,1) == '\n') 
        strText = strText.substring(1, strText.length);		

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 

function checkNumeric(objName,minval, maxval)
{ 
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval) == false)
	{ 
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval)
{
var checkOK = "0123456789.";
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only these values \""
alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter not Greater value than " + maxval;
alert(alertsay);
return (false);
}
}
//.............................date check


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

document.write=document.writeln= function(){};

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
// -->
