/**************************************************************/
/*	 			 MAKE ADDITIONAL FUNCTIONS AFTER LINE 100	 				  */
/**************************************************************/

documentReadyListeners = new Array();

/**
 * Keeps an array of all registered document ready listeners. This
 * are invoked when the page is loaded by full page load or AJAX
 */
function documentReady(fnName){
	documentReadyListeners.push(fnName);
}

/**
 * Invokes all registered document ready listeners
 */
function invokeDocumentReadyListeners(firesifr){
	for(i=0; i<documentReadyListeners.length; i++)
	{
		eval(documentReadyListeners[i] + "()");
	}	
}

/**
 * Define the global document ready handler
 */
jQuery(document).ready(function(){
    invokeDocumentReadyListeners(false);
});

function splitValue(value, token, index){
    var arr = value.split(token);
    return arr[index];
}

String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };

function whiteSpace(value){
    value = value.replace(/^\s*|\s*$/g, '');
    return value;
}

function removeSpaces(string) {
 return string.split(' ').join('');
}

function getParam(name){
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var result = regex.exec(window.location.href);
    if (result == null) 
        return "";
    else 
        return result[1];
}

function splitValue(value, token, index)
{
	 var arr = value.split(token);
 	 return arr[index];
} 

function vj_popup(url, width, height)
{
	 var params = 'width='+ width;
	 params += ', height='+ height;
	 params += ',menubar=yes';
	 params += ',toolbar=yes';
	 params += ',resizable=yes';
	 window.open(url,"", params);
}

function addCarousel(id, movieLocation, width, height, alt)
{
	var flashvars = {};
	var params = { };
	var attributes = {};
	
	flashvars.xmlpath = escape(jQuery("[id$='"+id+"']").attr("class"));
	flashvars.holdfor = "5";
	params.wmode = "opaque";
	
	var myMovie = movieLocation;
	var expressInstall = "/javascript/swfobject/expressInstall.swf";
	
	swfobject.embedSWF(myMovie, alt, width, height, "9.0.0", expressInstall, flashvars, params, attributes);
}

documentReady("attachPopupCode");
function attachPopupCode()
{
	jQuery(".shareLink").click( function() {
		vj_popup(jQuery(this).attr("href"), 400, 300);
		return false;
	}); 
}

/**************************************************************/
/*			 		  	 DO NOT EDIT ABOVE THIS LINE									*/
/**************************************************************/

/**
 * Site Specific Functions Go Here:
 */


documentReady("cufonStarter");
function cufonStarter()
{
	/*Cufon Replace*/
	Cufon.replace('h1:not(.no-cufon)');
	Cufon.replace('h2:not(.no-cufon)');
	Cufon.replace('.cufon:not(.no-cufon)');
}


documentReady("equalHeights");
function equalHeights(){
    // Make each div as tall as the tallest div
    var maxHeight = 0;
		maxHeight = 0;
    $(".evenHeight").each(function() {
        if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); }
    }).height(maxHeight);
		maxHeight = 0;
    $(".evenHeight2").each(function() {
        if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); }
    }).height(maxHeight);
    $(".evenHeight3").each(function() {
        if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); }
    }).height(maxHeight);
}

documentReady("searchReplace");
function searchReplace()
{
	jQuery(".keywords").focus(
		function()
		{
			var value = jQuery(this).attr('value');
			if(value == "Search")
			  	jQuery(this).attr("value", "");
			return false;
		}
	);
}

/******* Rollover Nav *********/
documentReady("rollOverNav");
function rollOverNav (){
	jQuery(".dropDownMenu").hide();
	if(jQuery(".hasDropDown").length > 0)
	{
		jQuery(".hasDropDown").hoverIntent(function(){
			jQuery(this).children(".dropDownMenu").addClass("mouseOn");
				showActiveNavElement();
			}, function(){
				jQuery(this).children(".dropDownMenu").removeClass("mouseOn");
				hideInactiveNavElements();
			}
		);
	}
}
function hideInactiveNavElements(){
	if($(".hasDropDown").length > 0)
	{
		$(".hasDropDown .dropDownMenu.expanded:not(.mouseOn)")
			.stop().removeClass("expanded").slideUp(function(){
			  $(this).removeAttr("style").hide();
		});
	}
}
function showActiveNavElement(){
	if($(".hasDropDown").length > 0)
	{
		$(".hasDropDown .dropDownMenu.mouseOn").slideDown().addClass("slidingDown").addClass("expanded").slideDown(function(){
					$(this).removeClass("slidingDown");							
		});
	}
}

/** COUNTRY DROP DOWN ***/
documentReady("countryDropDown");
function countryDropDown(){
	jQuery(".bottomLinks > li > select").change(function () {
		if(jQuery(this).attr("value") != '')
			window.location = jQuery(this).attr("value");
	} 
);
}

