// JavaScript Document
var stylevar = new Array('#A8A8FF','#CCCCFF');
var iframe = 'project_listing';
var dealerURL = "iframe_projects.php";
var master_state = "";

var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
				  && typeof(document.createElement) != 'undefined')
			   ? 1 : 0;
var isIE4      = (typeof(document.all) != 'undefined'
				  && parseInt(navigator.appVersion) >= 4)
			   ? 1 : 0;
var isNS4      = (typeof(document.layers) != 'undefined')
			   ? 1 : 0;
var capable    = (isDOM || isIE4 || isNS4)
			   ? 1 : 0;
// Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
if (capable) {
	if (typeof(window.opera) != 'undefined') {
		capable = 0;
	}
	else if (typeof(navigator.userAgent) != 'undefined') {
		var browserName = ' ' + navigator.userAgent.toLowerCase();
		if (browserName.indexOf('konqueror') > 0) {
			capable = 0;
		}
	} // end if... else if...
} // end if


if(navigator.userAgent.indexOf('MSIE') > 0) var ie5 = true;
	else var ie5 = false;

function listDealers(state){
	  var styleindex = 0;
	  master_state = state;
	  state = state.toUpperCase();
	  //If no dealers, return error message.
	  if (!dealers[state]) return "<i>We do not have any listings for the city of "+state+"...</i>";
	  else{
	  	this_state = dealers[state];
		output = "<table class='popupText' cellpadding=2 cellspacing=0 width='100%'>";
		output+= "<tr><td style='border-bottom:#333333 1px solid'><b>Name</b></td><td style='border-bottom:#333333 1px solid'><b>City</b></td></tr>";
		for(i=0;i<this_state.length;i++){
			output+= "<tr bgcolor="+stylevar[styleindex]+"><td valign=top>"+this_state[i][1]+"</td><td valign=top>"+this_state[i][2]+"</td></tr>";
			if(styleindex==0)styleindex=1;
			else styleindex=0;
		}
		output+= "</table>";
		return output;	
	  }
}
function setLocation(){
	state = master_state;
	var new_url = dealerURL+"?state="+state;

	if(ie5)	parent.frames[0].location.href=new_url;
	else var dealerinfo = window.open(new_url,"dealer_window","height=400,width=450,title='Jarow Helmets - Dealer Listing'");
 
}

/**
 * Hilight/un-hilight a database when the mouse pass over/out it
 *
 * @param  string  the name of the database to act on
 * @param  boolean the color to be used
 *
 * @access  public
 */
function hilightBase(el, theColor)
{
  if (!isDOM && !isIE4) {
    return;
  }

  if (isDOM) {
    var whichDb     = document.getElementById(el);
    //var whichTables = document.getElementById(el + 'Child');
  }
  else if (isIE4) {
    var whichDb     = document.all(el);
    //var whichTables = document.all(el + 'Child');
  }

  if (typeof(whichDb.style) == 'undefined') {
    return;
  }
  /*else if (whichTables) {
    whichDb.style.backgroundColor     = theColor;
    whichTables.style.backgroundColor = theColor;
  } */
  else {
    whichDb.style.backgroundColor     = theColor;
  }

  return true;
} // end of the 'hilightBase()' function
