
//WP.js, contains rollover functions, woody flash logo docwrite function,
// and small page-specific functions. 02-10

// SWF objects, flash

var logo = new SWFObject('\/images\/wp-ani-02-10.swf', 'wp-ani-embed', '97', '165', '6', '#000000'); 
logo.addParam("wmode", "transparent");
var slideshow = new SWFObject('\/images\/slideshow.swf', 'slideshow-embed', '760', '330', '6', '#000000'); 
slideshow.addParam("wmode", "transparent");

var maxx = new SWFObject('http:\/\/www.internationaltrucks.com\/\/InternationalTrucks/PageContent/Community/MaxxForceTV/widget/localMaxxTVWidget/intTruckerLocal.swf', '300', '250', '6', '#ffffff'); 
maxx.addParam("wmode", "transparent");
maxx.addParam("allowNetworking", "all");
maxx.addParam("allowScriptAccess", "always");

var about_wp = new Image();		var about_wp_over = new Image();
var locations_wp = new Image();	var locations_wp_over = new Image();
var buy_wp = new Image();		var buy_wp_over = new Image();
var sales_wp = new Image();		var sales_wp_over = new Image();
var parts_wp = new Image();		var parts_wp_over = new Image();
var service_wp = new Image();	var service_wp_over = new Image();
var rental_wp = new Image();	var rental_wp_over = new Image();
var contact_wp = new Image();	var contact_wp_over = new Image();
var home_wp = new Image();		var home_wp_over = new Image();

var imgObj = new Array(about_wp,about_wp_over,locations_wp,locations_wp_over,buy_wp,buy_wp_over,
          sales_wp,sales_wp_over,parts_wp,parts_wp_over,service_wp,service_wp_over,rental_wp,rental_wp_over,
          contact_wp,contact_wp_over,home_wp,home_wp_over);
var images = new Array('about-wp.gif','about-wp-over.gif','locations-wp-02-10.gif','locations-wp-over-02-10.gif','buy-wp.gif',
          'buy-wp-over.gif','sales-wp.gif','sales-wp-over.gif','parts-wp.gif','parts-wp-over.gif',
          'service-wp.gif','service-wp-over.gif','rental-wp.gif','rental-wp-over.gif',
          'contact-wp.gif','contact-wp-over.gif','home-wp.gif','home-wp-over.gif');
		  
var imgName;
for (i=0;i<images.length;i++) {
      imgName = '\/images\/' + images[i];
      imgObj[i].src=imgName;
}

function attachRollovers () {
  if (document.getElementById) {
    if (document.getElementById('about_link')) { 
      document.getElementById('about_link').onmouseover = function() { document.getElementById('about_wp').src = '\/images\/about-wp-over.gif'; }; 
      document.getElementById('about_link').onmouseout  = function() { document.getElementById('about_wp').src = '\/images\/about-wp.gif'; }; 
    }
    if (document.getElementById('locations_link')) {
	  document.getElementById('locations_link').onmouseover = function() { document.getElementById('locations_wp').src = '\/images\/locations-wp-over-02-10.gif'; }; 
      document.getElementById('locations_link').onmouseout  = function() { document.getElementById('locations_wp').src = '\/images\/locations-wp-02-10.gif'; }; 
    }
    if (document.getElementById('buy_link')) {
	  document.getElementById('buy_link').onmouseover = function() { document.getElementById('buy_wp').src = '\/images\/buy-wp-over.gif'; }; 
      document.getElementById('buy_link').onmouseout  = function() { document.getElementById('buy_wp').src = '\/images\/buy-wp.gif'; }; 
    }
    if (document.getElementById('sales_link')) {
	  document.getElementById('sales_link').onmouseover = function() { document.getElementById('sales_wp').src = '\/images\/sales-wp-over.gif'; }; 
      document.getElementById('sales_link').onmouseout  = function() { document.getElementById('sales_wp').src = '\/images\/sales-wp.gif'; }; 
    }
    if (document.getElementById('parts_link')) {
	  document.getElementById('parts_link').onmouseover = function() { document.getElementById('parts_wp').src = '\/images\/parts-wp-over.gif'; }; 
      document.getElementById('parts_link').onmouseout  = function() { document.getElementById('parts_wp').src = '\/images\/parts-wp.gif'; }; 
    }
    if (document.getElementById('service_link')) {
	  document.getElementById('service_link').onmouseover = function() { document.getElementById('service_wp').src = '\/images\/service-wp-over.gif'; }; 
      document.getElementById('service_link').onmouseout  = function() { document.getElementById('service_wp').src = '\/images\/service-wp.gif'; }; 
    }
    if (document.getElementById('rental_link')) {
	  document.getElementById('rental_link').onmouseover = function() { document.getElementById('rental_wp').src = '\/images\/rental-wp-over.gif'; }; 
      document.getElementById('rental_link').onmouseout  = function() { document.getElementById('rental_wp').src = '\/images\/rental-wp.gif'; }; 
    }
    if (document.getElementById('contact_link')) {
	  document.getElementById('contact_link').onmouseover = function() { document.getElementById('contact_wp').src = '\/images\/contact-wp-over.gif'; }; 
      document.getElementById('contact_link').onmouseout  = function() { document.getElementById('contact_wp').src = '\/images\/contact-wp.gif'; }; 
    }
    if (document.getElementById('home_link')) {
	  document.getElementById('home_link').onmouseover = function() { document.getElementById('home_wp').src = '\/images\/home-wp-over.gif'; }; 
      document.getElementById('home_link').onmouseout  = function() { document.getElementById('home_wp').src = '\/images\/home-wp.gif'; }; 
    }
  }
}

// Specific functions for main and parts pages in conditionals

window.onload = function() { 
	attachRollovers(); 
	if (document.getElementById('wp-ani')) { logo.write('wp-ani'); }
	if (document.getElementById('partsImage')) { setTimeout("rotatePic('partsImage','parts-store.jpg','parts-1960.jpg')",5000); }
	if (document.getElementById('serviceImage')) { setTimeout("rotatePic('serviceImage','heavy-duty-wreckers-05-09.jpg','bens_service_truck.jpg')",5000); }
	if (document.getElementById('anniversary-img')) { setTimeout("rotatePic('anniversary-img','50th-anniversary-small.jpg','50th-anniversary-staff.jpg')",5000); }
	if (document.getElementById('flash_slideshow')) { slideshow.write('flash_slideshow'); }
	//if (document.getElementById('maxxforce')) { maxx.write('maxxforce'); }
	if (document.getElementById('pendleton_map')) { load(); }
}; 

window.onunload = function() { if (document.getElementById('pendleton_map')) { GUnload(); } };

// Parts page pic rotate

function rotatePic(id,img1,img2) { 
	var src = document.getElementById(id).src;
	var reg = new RegExp(img1);
	var newImg = (reg.test(src))?img2:img1;
	document.getElementById(id).src = '\/images\/'+newImg;
	var cmd = 'rotatePic("'+id+'","'+img1+'","'+img2+'")';
	setTimeout(cmd,5000);
}

// Contact page, obvious

function checkContact(form) {

        var requireds = new Array("Name", "Email", "Source");
        var obj,msg = "";

        for (i=0; i<requireds.length; i++) {
            obj = document.getElementById(requireds[i]);
            if (obj.value == "") {
                if (requireds[i] == 'Source') {
                    msg = "Please let us how you found out about the Temple of Isis.";
                }
                else { msg = "Please provide your " + requireds[i] + " before submitting this form.";  }
                break;
            }
        }
        if ((msg == '') && (form.Email.value != "")) {
            var found = false;
            var emailString = form.Email.value;
            for (j=0; j < emailString.length; j++) {
                if (emailString.charAt(j) == "@") { found = true; }
            }
            if (found == false) {
                msg = 'Is that your true email address?\n' +
                      'Please enter your correct email address.\n' +
                      'We will not place you on any mailing lists!\n';
            }
        }

        if (msg == '') { form.submit(); }
        else {  alert(msg);  }

        return false;
}

// Short rental form, the long one is large and has it's own

function chkShortForm(form) {

   var requireds = new Array('Name', 'Address', 'City', 'Zip', 'Email', 'State', 'Telephone');
   var quanChk   = new Array('Cab_and_Chassis_Only','End_Dump_with_Hoist','Flat_Bed_Only','Self_Unloading_Bed');
   var dtFlds    = new Array('StartMonth','StartDay','StartYear','EndMonth','EndDay','EndYear');
   var obj,msg='';
		
   if (document.getElementById) {
		for (i=0;i<requireds.length;i++) {
		      var obj = document.getElementById(requireds[i]);
		      if (
		         ((obj.type=='select-one') && (obj.selectedIndex==0)) ||
		         ((obj.type=='text') && (obj.value == '')) 
				 ) {
			     msg = 'The ' + requireds[i] + ' field is required to submit this application.';
		         break;
		      }
		 }
         if (msg == '') {
             for (i=0; i<quanChk.length; i++) {
               if (document.getElementById(quanChk[i]).checked==true) {
                  var quanFld =  quanChk[i] + '_Quantity';
                  if ((document.getElementById(quanFld).value == '') || 
				      (document.getElementById(quanFld).value == 0) || 
					  (isNaN(document.getElementById(quanFld).value))) {
                      msg = 'Please enter a quantity for the\n' +
                            'type of beds you need. Use only numbers.';
                      break;
                  }
               }
             }
         }
         if (msg == '') {
             for (i=0; i<dtFlds.length; i++) {
               var ind = document.getElementById(dtFlds[i]).selectedIndex;
               var DDval = document.getElementById(dtFlds[i]).options[ind].value;
               if (DDval == '') {
                    msg = 'Please select the month, day, and\n' +
                          'year for both an approximate start\n' +
                          'and end date for the lease.';
                    break;
               }
             }
         }
         if ((msg == '') && (form.Email.value != '')) {
               var found = false;
               var emailString = form.Email.value;
               for (j=0; j < emailString.length; j++) {
                   if (emailString.charAt(j) == "@") { found = true; }
               }
               if (found == false) { msg = 'Please check the email address field, it appears to be an incorrect email format.\n'; }
         }
		 if (msg != '') { alert(msg); }
		 else { form.submit(); }
	  }
	  return false;

}

function newWindow(img,w,h) {
	var day = new Date();
	var id = day.getTime();
	ww=w+75;
	wh=h+125;
	if ((screen.height) && (wh > screen.height-150)) { wh = screen.height-150; }
	var params='width='+ww+',height='+wh+',scrollbars,resizable';
	var txt='<html><head><title>'+img+'</title><style type="text/css">'+
	'body { text-align:center; } </style></head><body>'+
	'<img src="'+img+'"width="'+w+'" height="'+h+'" border="0" alt="'+img+'">'+
	'<form action=""><hr><input type="button" onClick="window.close()" value="Close Window"></form>'+
	' <map name="header-map" id="header-map">'+
  	'<area shape="rect" href="about-woodpecker-truck.html" coords="108,102 542,122" alt="Read about out 50th year of service to the Northwest and beyond">'+
  	'<area shape="default" href="index.html" alt="Woodpecker Truck Main Page">'+
 	'</map></body></html>';
	var win=open('',id,params);
	win.document.write(txt);
	win.document.close();
	return false;
}
	

