function loadFlash(file, w, h, base, flashVars) {
	document.writeln(getFlashOutput(file, w, h, base, flashVars));
}
function loadFlashSEO(tag, file, w, h, base, flashVars) {	
	document.getElementsByTagName(tag)[0].innerHTML = getFlashOutput(file, w, h, base, flashVars + "&text=" + document.getElementsByTagName(tag)[0].innerHTML);
}
function getFlashOutput(file, w, h, base, flashVars) {
	var output = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""+
		"	codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0\""+
		"	width=\""+w+"\""+
		"	height=\""+h+"\""+
		"	name=\"flashFile\""+
		"	id=\"flashFile\">"+
		"	<param name=\"movie\" value=\""+file+"\">"+
		"	<param name=\"base\" value=\""+base+"\">"+
		"	<param name=\"flashVars\" value=\""+flashVars+"\">"+
		"	<param name=\"quality\" value=\"high\">"+
		"	<param name=\"menu\" value=\"false\">"+
		"	<param name=\"wmode\" value=\"transparent\">"+
		"	<embed"+
		"		src=\""+file+"\""+
		"		base=\""+base+"\""+
		"		width=\""+w+"\""+
		"		height=\""+h+"\""+
		"		flashVars=\""+flashVars+"\""+
		"		quality=\"high\""+
		"		pluginspage=\"http://www.macromedia.com/go/getflashplayer\""+
		"		type=\"application/x-shockwave-flash\""+
		"		menu=\"false\""+
		"		wmode=\"transparent\""+
		"		swLiveConnect=\"true\""+
		"		name=\"flashFile\">"+
		"	</embed>"+
		"</object>";
	return output;
}

function redirect( url ){
	var timeout_id = window.setTimeout(function(){ getURL(url); }, 5000);	
}

function getURL( url ){
	window.location.href = url;
}

function errorCheck(){
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	
	var error = new Array();
	
	if( name.value == '' ) error.push('Name');
	if( email.value == '' ) error.push('Email');
	
	if( error.length > 0 ){
		var msg = 'The following fields are required to continue:' + "\n\n";
			msg += error.join(", ");
		
		alert(msg);
		
		return false;
	}
	
	return true;
}

function addBookmark(title, url){
  if(window.sidebar){ // Firefox
	window.sidebar.addPanel(unescape(title), unescape(url), '');
  }else if(window.opera){ //Opera
    var a = document.createElement("A");
    a.rel = "sidebar";
    a.target = "_search";
    a.title = title;
    a.href = url;
    a.click();
  } else if(document.all){ //IE
    window.external.AddFavorite(url, title);
  }else{
	alert('You need press COMMAND + D to bookmark our site.');
  }
}

function eraseFirst( obj ){
	if( obj.value == 'YOUR EMAIL ADDRESS' )
		obj.value = '';
	else if(obj.value == '')
		obj.value = 'YOUR EMAIL ADDRESS';
}

function firstToKnow(){    
	var know = document.getElementById('first_to_email');
	var urlString = 'email=' + know.value;
    
    var myConn = new XHConn();
    if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
    
    var fnWhenDone = function (oXML){	
		know.value = 'YOUR EMAIL ADDRESS';
		alert('You are now the first to know. Thank You!');
		
		return false;
    };
    
    myConn.connect("_includes/inc.first_to_know.php", "POST", urlString, fnWhenDone);	
	
	return false;
}

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

// mozXPath [http://km0ti0n.blunted.co.uk/mozxpath/] km0ti0n@gmail.com
// Code licensed under Creative Commons Attribution-ShareAlike License 
// http://creativecommons.org/licenses/by-sa/2.5/
if( document.implementation.hasFeature("XPath", "3.0") ){
	if( typeof XMLDocument == "undefined" ){ XMLDocument = Document; }
  XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
    if( !xNode ) { xNode = this; } 
		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for( var i = 0; i < aItems.snapshotLength; i++){aResult[i] =  aItems.snapshotItem(i);	}
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode){
		if( !xNode ) { xNode = this; } 
		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 ){return xItems[0];	}
		else{return null;	}
	}
	Element.prototype.selectNodes = function(cXPathString){
		if(this.ownerDocument.selectNodes){	return this.ownerDocument.selectNodes(cXPathString, this);}
		else{throw "For XML Elements Only";}
	}
	Element.prototype.selectSingleNode = function(cXPathString){	
		if(this.ownerDocument.selectSingleNode){return this.ownerDocument.selectSingleNode(cXPathString, this);	}
		else{throw "For XML Elements Only";}
	}
}

var imageArrowBlack = new Image();
	imageArrowBlack.src = 'images/category_arrow_on.jpg';
	
var imageArrow = new Image();
	imageArrow.src = 'images/category_arrow_off.jpg';
	
function catMouseOver( id ){
	document.getElementById('cat_' + id).style.color = '#D02121';
	document.getElementById('arr_' + id).src = 'images/category_arrow_on.jpg';
}

function catMouseOut( id ){
	document.getElementById('cat_' + id).style.color = '#8C8786';
	document.getElementById('arr_' + id).src = 'images/category_arrow_off.jpg';
}
	