// JavaScript Document

function PopSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.target && a.target.indexOf("_Pop") == 0) {
			a.onclick = Pop;
		}
	}
}

function Pop() {
	var a = this.target.split(":");
	var sFeatures = a[1];
	window.open(this.href, a.length > 2 ? a[2] : String((new Date()).getTime()), sFeatures);
	return false;
	alert("hi")
}

function RolloverSetup() {
	var img, sh, sn, sd
	for (var i = 0; (img = document.images[i]); i++) {
		if (img.getAttribute) {

			sn = img.getAttribute("src");
			sh = img.getAttribute("hsrc");
			sd = img.getAttribute("dsrc");

			if (sn != "" && sn != null) {
				img.n = new Image();
				img.n.src = img.src;
			
				if (sh != "" && sh != null) {
					img.h = new Image();
					img.h.src = sh;
					img.onmouseover = SwapOn
					img.onmouseout  = SwapOff
				}

				if (sd != "" && sd != null) {
					img.d = new Image();
					img.d.src = sd;
					img.onmousedown = SwapDown
				}
			}
		}
	}
}

function SwapOn() {
	this.src = this.h.src;
}

function SwapOff() {
	this.src  = this.n.src;
}

function SwapDown() {
	this.src  = this.d.src;
	this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
	SwapUp.img = this;
	document.onmouseup = SwapUp;
}

function SwapUp() {
	var ths = SwapUp.img;
	ths.src = ths.n.src;
	if (ths.temp) document.onmouseup = ths.temp;
}


function initPage()
{
    // quit if this function has already been called
    if (arguments.callee.done) return;

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;
	RolloverSetup();
}

// this is to handle letting everything else fire off (3 seconds) and
// actually finish loading the page...
function initPage2()
{
	return false;
}

//for Safari
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            initPage(); // call the onload handler
        }
    }, 10);
}
// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        initPage(); // call the onload handler
    }
};
/*@end @*/

if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", initPage, false);
}



// JavaScript Document

// Random number generator from DART
<!--
var axel = Math.random() + "";
var ord = axel * 1000000000000000000;
//-->
/*
// GETTING MAKE AND MODEL FROM TITLE
<!--
	var strTitle = document.title;
	var strYear = strTitle.substring(0, strTitle.indexOf(' ')); 
	var strMakeModel = strTitle.substring(strYear.length + 1, strTitle.length);
	var strMake = strMakeModel.substring(0, strMakeModel.lastIndexOf(' '));
	var strModel = strMakeModel.substring(strMake.length + 1);
-->
*/
// hover script necessary for IE to work - from HTMLdogs.com
<!--
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
	   sfEls[i].onmouseover=function() {
	       this.className+=" sfhover";
	   }
	   sfEls[i].onmouseout=function() {
	       this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	   }
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//-->

/* Accessible popups */
function acpopup(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}

//BREADCRUMB SCRIPT
function spawn(expr,qty,reversed){
var spawnee=[expr];
for(s=1;s<qty;s++){
spawnee[s]=expr+spawnee[s-1];
}
return reversed? spawnee.reverse() : spawnee();
}

function mw_crumbs(divider,default_page,root){
if(!divider) {divider=" > "}
if(!default_page){default_page="index.htm"}
var m=location.toString(),h="";
m=m.substring(m.indexOf("/")+1);
m=m.split("/");
var howmany=spawn("../",m.length,true);
howmany[m.length]=default_page;
for(i=1;i<m.length-1;i++){
h+=("<a href="+howmany[i+2]+">"+unescape( m[i]+"<\/a>"+divider))
}
h += document.title;
if(root) {
h=h.replace(eval("/"+location.host+"/"),root)
}
return h
}
