if (typeof(ROIID) + '' != 'undefined') {
	TrackEvent('LandingPage', 0);
}

// Globals
var message="Welcome to GeneratorDepotUsa.com!";
var place=1;
var limit=100;

// Controls the scrolling welcome message in the status bar.
function scrollIn() {
  window.status=message.substring(0, place);
  if (place >= limit) {
     place=1;
     window.setTimeout("scrollOut()",05);}
	 //window.setTimeout("scrollOut()",25);}
  else {
     place++;
     window.setTimeout("scrollIn()",08); } 
	 //window.setTimeout("scrollIn()",28); } 
}
function scrollOut() {
   window.status=message.substring(place, message.length);
   if (place >= message.length) {
      place=1;
      window.setTimeout("scrollIn()", 80);}
   else {
      place++;
      window.setTimeout("scrollOut()", 80);}
}

// Start the scrolling
scrollIn();

function openAnyWindow(url, name, w, h) {
  popupWin = window.open(url, name, 'status=no,toolbar=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h)
}

// For Wattage Wizard page
function check_misc(field_number) {
        var statement1 = 'document.forms[0].hs_rw'+field_number+'.value';

        var value1 = eval(statement1);

        if (isNaN(value1) || (value1 == '')) {
                alert('Miscellaneous Values must be Numbers');
                return 1;
                }

        return 0;
        }

//**** Wattage Wizard Calculator ****//
// Take the sum of the maximum surge, plus running wattage for all remaining elements.
// Based on this calculation, the consumer would need a generator with a surge (starting)
// wattage of at least this sum.
function generatorDepotCalc() {
        var total = 0;
        var max_diff = 0;
        //var max_number_one = 0;
        //var max_number_two = 0;

        var max_values = 0;
        var max_calc_one = 0;
        var max_calc_two = 0;

		var lights_counted = 1;
		
        for (var i = 1; i < 23; i++) 
		{
                var element_value = document.forms[0].elements[i].value;
                var element_checked = document.forms[0].elements[i].checked;

                var setArray = element_value.split('|');
                var rated = parseInt(setArray[0]);		// running wattage
                var surge = parseInt(setArray[1]);		// surge wattage

				if (document.forms[0].hs_lc.value != '0') 
				{
					// If lights are to be counted.
					if (lights_counted) 
					{
						// Okay, make sure the lights won't be counted again.
						lights_counted = 0;
						
						// Make sure number of lights is a number
						if (isNaN(document.forms[0].hs_lc.value)) 
						{
							alert('Number of Light Bulbs must be a Number.');
							return 1;
						}
						// Determine number of lights from text box.
						var number_lights = document.forms[0].hs_lc.value;
						total = total + number_lights * 75;
					}
				}
				// Next check this checkbox.  If it is checked...
				if (element_checked) 
				{
					// Add the running wattage to the current total running wattage.
					total = total + rated;

					var this_difference = surge - rated;

					if (this_difference > max_values) 
					{
						max_values = this_difference;
						max_calc_one = rated;
						max_calc_two = surge;
					}
				}
					
		} // End the for-loop

        var running = total;
		total = total - max_calc_one + max_calc_two;

		self.open("http://www.generatordepotusa.com/wattage_wizard_result.asp?surge="+total+"&running="+running, "_self");
}

function my_resetf() {
        document.forms[0].reset();
        self.open("http://www.generatordepotusa.com/wattage_wizard.asp", "_self");
}

// Display a thumbnail that allows the user to open in the image in a larger window.
//	tn_img: path of the thumbnail image
//	tn_width: width of the thumbnail image
//	img: path of the larger image, often the same as tn_img
//	x: x-coordinate of the resulting window
//	windowx: width of the resulting window
function displayThumbnail(tn_img, tn_width, img, x, windowx)
{
document.write("<a href=\"javascript:openimg('" + img + "','" + x + "','" + windowx + "')\">");
document.write("<IMG SRC=\"" + tn_img + "\" border=\"0\" width=\"" + tn_width + "\"></a>");
}

//	img: path of the larger image to display in the resulting window
//	x: x-coordinate of the resulting window
//	windowx: width of the resulting window
function openimg(img, x, windowx) 
{
  var msgWindow = window.open('','','width=' + windowx 
  	+ ',screenX=' + x 
	+ ',height=400' 
	+ ',resizable=yes,scrollbars=yes');
  
  doc = msgWindow.document;
  doc.open('text/html');
  doc.write('<HTML><HEAD><TITLE>GeneratorDepotUSA<\/TITLE><\/HEAD><BODY bgcolor="white">');
 
  //doc.write("<table width=\"" + windowx + "px\"><tr><td align=\"center\" valign=\"middle\"><IMG SRC=\"" + img + "\" border=\"0\" width=\"" + x + "px\"></td></tr>");
  doc.write("<table width=\"" + windowx + "px\"><tr><td align=\"center\" valign=\"middle\"><IMG SRC=\"" + img + "\" border=\"0\"></td></tr>");
 
  doc.write('<tr><td align=\"center\" valign=\"middle\"><form name="viewn"><input type="button" value="Close Window" onClick="self.close()"><\/form></td></tr></table><\/BODY><\/HTML>');
  doc.close();
}

