// JavaScript Document
function ranQuote() {
var quote = new Array(3);
quote[0] = 'A Great Place to Live and Work.';
quote[1] = 'Strong Midwest Work Values.';
quote[2] = 'Trucking Operations and Rail Access with Quick and Easy Access to Major Cities.';
quote[3] = 'Cost Effective Business Incentives and Business Tax Savings.';
quote[4] = 'Available Cost Effective, Responsible, Well Educated labor Pool.';
quote[5] = 'Centrally Located.';
quote[6] = 'Distribution Systems Easy to Access.';
quote[7] = 'Affordable Land and Building Opportunities.';
quote[8] = 'Highly Competitive Wage Rates.';
quote[9] = 'Stable Economic Environment.';
quote[10] = 'Do-it Ourselves Attitude.';
quote[11] = 'Business Presence has True Value.';
quote[12] = 'Other Business Locations and Suppliers Nearby.';
quote[13] = 'Family Oriented Focus with Strong Quality of Life Attractions.';
quote[14] = 'Local Government that is Supportive of Legitimate Business Interests.';

var ran = 60/quote.length


  currentdate = new Date();
  core = currentdate.getSeconds();
  core = Math.floor(core/ran);
    return(quote[core]);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;

//annual report JS
//----------------------------------
function createChapter(year){
//----------------------------------
//	alert('inside newChapter');
//	var reportArray = document.getElementById('report');
//	for (var i=0; i < reportArray.length; i++){
//		alert(reportArray[i].name);	
//	}
	var cgiString = 'report.php?chapter=true&repYear='+year;
	//alert(cgiString);
	document.location.href=cgiString;
}
//----------------------------------
function submitReportForm(){
//----------------------------------
	alert('inside submitReportForm');
	document.submit();	
}

//----------------------------------
function ckNumber(ev) {
//----------------------------------
   // Initialize local variables
   var tmpstr = ev.value
   var l = tmpstr.length
	
	if (ev == null)
   {
   		return;
   }
   if (isNaN(tmpstr) == true)
   {
      	alert("Error: Input must be numeric");
      	ev.select()
      	ev.focus()
      	return;
	}
}
//-----------------------------------------
function changephoto(input, img)
//-----------------------------------------
{
  	if ( navigator.appName == "Microsoft Internet Explorer" )
   		img.src = input.value;
}
//---------------------------------
function ckDate(ev,nam) {
//---------------------------------
  
      isAllValid = false
 
   
   vdt = ev.value
//   if (vdt.length == 0)
//      return
//   if (vdt == "mm/dd/yyyy")
//      return
      
  // parse date
   if (vdt.length > 0)
   {
   dts = vdt.split("/",4)
   j = dts.length
   
   if (j != 3)
   {
      curTarget = ev
      inEvent = true
      alert("Error: Date must be in the format MM/DD/YYYY")
      //ev.select()
      ev.focus()
      isAllValid = false
      return
   }
   else
   {
      mon = dts[0] - 0
      if (isNaN(mon) == true)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Month")
         //ev.select()
         ev.focus()
         isAllValid = false
         return
      }
      if (mon < 1 || mon > 12)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Month")
         //ev.select()
         ev.focus()
         isAllValid = false
         return
      }
     
      day = dts[1] - 0
      if (isNaN(day) == true)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Day")
         //ev.select()
         ev.focus()
         isAllValid = false
         return
      }
      yr = dts[2] - 0
      if (isNaN(yr) == true || yr < 1000)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Year - Use Date format MM/DD/YYYY");
         //ev.select()
         ev.focus()
         isAllValid = false
         return
      }
      switch(mon)
      {
         case 1:
         case 3:
         case 5:
         case 7:
         case 8:
         case 10:
         case 12:
            if (day < 1 || day > 31)
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               //ev.select()
               ev.focus()
               isAllValid = false
               return
            }
            break
         case 4:
         case 6:
         case 9:
         case 11:
            if (day < 1 || day > 30)
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               //ev.select()
               ev.focus()
               isAllValid = false
               return
            }
            break
         default:
            lpyr = 0
            if (yr < 100)
               yr += 1900
            if (yr % 4 == 0)
            {
               if (yr % 100 != 0)
                  lpyr = 1
               else if (yr % 400 == 0)
                  lpyr = 1
            }
            if (day < 1 || day > (28 + lpyr))
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               //ev.select()
               ev.focus()
               isAllValid = false
               return
            }
      }
   }
   }
}
//----------------------------------
function echeck(str) {
//----------------------------------
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}
//----------------------------------
function ckEmail(ev){
//----------------------------------	
	var emailID=ev;
	
	if ((emailID.value==null)||(emailID.value=="")){
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 //----------------------------------
function wait(ev){
//----------------------------------
	//disable the button
   ev.value= "please Wait...";
   //ev.disabled = true;
}
//----------------------------------
function confirmDelete(msg){
//----------------------------------
	//asks before deltes
	return confirm(msg);
}
//----------------------------------
function checkValidURL(field,excval){
//----------------------------------
var httpregex=/^([a-zA-Z]+:\/\/)/
var urlregex=/^\w+.[.\w]*\w$/;
var value=field.value;
var match=value.match(httpregex); // has a protocol indicator
     if (match){
          match=field.value.substr(match[1].length,value.length)
          match=match.match(urlregex);
     }else{
          var match=value.match(urlregex);
     }
     if(!match){
          alert('The URL entered is not valid. make sure it starts with: http://');
          if (excval) eval(excval);
          return false;
     }
	 else 
	 	return true;
}
//-----------------------------------
function linkConfirm(urlLink,msg){
//-----------------------------------
	if (confirm(msg)) {
		 location.href = urlLink;
	  }
	  return false;
	
}