// JavaScript Document
var stylevar = new Array('#E7F0D9','#DBE9C7');
var iframe = 'partner_listing';
var dealerURL = "iframe_partner_listing.php";
var master_state = "";
var currLoc = this.location;
var partner_page = 'index.php';

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 ( undefined===window.dealers ) return "<span class='olText'>Sorry, we're experiencing technical difficulties retrieving dealers for "+state+".</span>";
	  else{
		  if (!dealers[state]) return "<span class='olText'>Sorry, we don't have any service partners covering <b>"+state+"</b> at the moment.</span>";
		  else{
			this_state = dealers[state];
			output = "<table class='olTable' cellpadding=2 cellspacing=0 width='100%'>";
			output+= "<tr><td class='olTitleCell' colspan='2'>Regional service partners covering "+state+":</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 setState(){
	state = master_state;
	if(isIE4)
		window.navigate(partner_page+"?state="+state);
	else
		this.location.href = partner_page+"?state="+state;
	/*this.location+"?state="+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='Protec Q., Inc. 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);	}
  else if (isIE4) 	{ var whichDb     = document.all(el); 				}
  if 	(typeof(whichDb.style) == 'undefined') { return; 				}
  else 				{ whichDb.style.backgroundColor     = theColor;		}
  return true;
}

/* Function: Swaps content of iFrame in browser based on link clicked
 * References iFrame as DOM if poss (need ident code) to allow use of 
 * alternate objects (ilayer, div, etc.) for NN6-
 */
function swapiFrame(frameName,newSrc){
	if (!isDOM && !isIE4) {	return;}
	if (isDOM) {
		var whichFrame     = document.getElementById(frameName);
		//var whichTables = document.getElementById(el + 'Child');
	}
	else if (isIE4) {
		var whichFrame     = document.all(frameName);
	}
	if (typeof(whichFrame.style) == 'undefined') {return; }
	else { 
		whichFrame.src     = newSrc;
	}
}