/* =================================================================== */
//Browser check and preload and functionality of rollover images
var IS_DOM = (document.getElementById) ? true : false;
var IS_IE = (document.all) ? true : false;
var IS_IE50 = (navigator.userAgent.indexOf("IE 5.0") != -1);
var IS_Mac = (navigator.appVersion.indexOf("Mac") != -1);
/* =================================================================== */

/* =================================================================== */
// function to add events crossbrowser
// from: http://www.dustindiaz.com/rock-solid-addevent/
// uncomment the EventCache lines if using EventCache function from code lib
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		//EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		//EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}
/* =================================================================== */
 

// Get an ID 
function getThis(sId)
{
	var oObject;
	oObject = false;
	
	if (IS_DOM) {
		if (document.getElementById(sId)) {
			oObject = document.getElementById(sId);
		}
	}
	
	return oObject;
}


/* =================================================================== */
// various link functionality - popups, external, onstate
// original script taken from Jeremy Keith
// dependencies: cssjs(), addEvent()
var anchors = {
	a : Object,
	doPopups : function() {
		if (!document.getElementsByTagName) return false;
		var links = document.getElementsByTagName("a");
		for (var i=0; i < links.length; i++) {
			var anchor = links[i];
			if (anchor.getAttribute('href') && anchor.rel.match('external')) {
				anchor.onclick = function() {
					return anchors.openWin(this,"");
				}
				cssjs('add',anchor,'external');
			}
		    if (cssjs('check',anchor,'popup')) {
				anchor.onclick = function() {
					return anchors.openWin(this,"toolbar=no");
				}
		    }
		    if (cssjs('check',anchor,'popupFull')) {
				anchor.onclick = function() {
					return anchors.openWin(this,"");
				}
		    }
		      if (cssjs('check',anchor,'newWin')) {
				anchor.onclick = function() {
					return anchors.openWin(this,"width=600, height=500,toolbar=1,location=1,menubar=1,status=1,resizable=1");
				}
		    }
			if (anchor.href == location.href) {
				cssjs('add',anchor,'onstate');
			}
		}
	},
	openWin : function(o,params) {
		window.open(o.href, "newwin","" + params + "");
		return false;
	}
}
addEvent(window,'load',anchors.doPopups);
/* =================================================================== */

/* =================================================================== */
// function to add/remove classes from elements
// written by Christian Heilmann 
// more info here http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
// call like cssjs('add',containerOBJ,classname);
function cssjs(a,o,c1,c2){
	switch (a){
		case 'swap':
			o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			var rep=o.className.match(' '+c1)?' '+c1:c1;
			o.className=o.className.replace(rep,'');
		break;
		case 'check':
			return new RegExp("(^|\\s)" + c1 + "(\\s|$)").test(o.className)
		break;
	}
}

/* =================================================================== */
  	
	  
//Quotes
function quotes() {
	  $("a.quote").mouseover(function(){
		  $(this).parents(".focusAreaContent").children("div").show();
	  });
	 $("div.quoteOverlay").hover(function(){
			//nothing to see here, move along
		},function(){
			$(this).hide();
		});
  }
 
 
 /* Show/Hide Select box - Country dropdown */
function selectList() {
	$("body").addClass("hasJS");

	$("div.select").show();
	 
	$("a.showSelect").toggle(function(){
	     $(".selectList") .slideDown("normal")
	   },function(){
	     $(".selectList") .slideUp("normal")
	   });
 }
 
 
/* Product Image Rollovers */
function productImagesOn(sName)
{
	$("#focusImages div#focusImage" + sName + "Lg").show();
	return false;
}

function productImagesOff(sName)
{
	$("#focusImages div#focusImage" + sName + "Lg").hide();
	return false;
}


$(document).ready(selectList);
$(document).ready(quotes);
