function popUp(pPath, pWidth, pHeight) 
{
	window.open(pPath, "HobbyZonePopUp", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + pWidth + ",height=" + pHeight + ",left=50,top=50");
}
	/* Cookies */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

//jquery
$(document).ready(function(){
	
	$('a[href$="pdf"]').addClass('pdf');
	$('a[href$="wmv"]').addClass('wmv');
	$('a[href$="mov"]').addClass('mov');
	
	//homepage slides
	$("a.homeLeadNav").click(function(event){
		event.preventDefault();
		var leadClicked = $(this).html();
		//alert(leadClicked);
		$("a.homeLeadNav").removeClass("selected");
		$(this).addClass("selected");
		var thisBrowser = navigator.userAgent;
		
		if(thisBrowser.indexOf("MSIE")!= -1){
			$("div#homeSlides div.homeSlide").hide();
			$("div#homeSlides div.homeSlide:nth-child("+leadClicked+")").show();
		}else{
			$("div#homeSlides").fadeOut(200, function(){
			$("div#homeSlides div.homeSlide").hide();
			$("div#homeSlides div.homeSlide:nth-child("+leadClicked+")").show();
			$("div#homeSlides").fadeIn(700);
			});
		}
		try{
			pageTracker._trackEvent("HP Main Slides", leadClicked, $("div#homeSlides div.homeSlide:nth-child("+leadClicked+")").attr("title"));
		}catch(err){}
	});
	
	//storelocator zebra rows
	$("div.StoreLocatorRow:even").addClass("alt");
	//related parts zebra 
	$("table.relPartsList tr:even td").addClass("alt");
	//zebra rows for all select boxes
	$("select > option:nth-child(even)").addClass("alt");
	//articles zebra rows
	$("div.articlesList:even").addClass("alt");
	//article pages zebra
	$("div.art_pageNames:odd").addClass("alt");
	
	$('input, textarea').placeholder();

});

/**************Plugins**********************/

/*placeholder plugin*/
/*! http://mths.be/placeholder v1.8.6 by @mathias */
(function(e,g,$){var a='placeholder' in g.createElement('input'),c='placeholder' in g.createElement('textarea'),h=$.fn,i;if(a&&c){i=h.placeholder=function(){return this};i.input=i.textarea=true}else{i=h.placeholder=function(){return this.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind('focus.placeholder',b).bind('blur.placeholder',d).trigger('blur.placeholder').end()};i.input=a;i.textarea=c;$(function(){$('form').bind('submit.placeholder',function(){var j=$('.placeholder',this).each(b);setTimeout(function(){j.each(d)},10)})});$(e).bind('unload.placeholder',function(){$('.placeholder').val('')})}function f(k){var j={},l=/^jQuery\d+$/;$.each(k.attributes,function(n,m){if(m.specified&&!l.test(m.name)){j[m.name]=m.value}});return j}function b(){var j=$(this);if(j.val()===j.attr('placeholder')&&j.hasClass('placeholder')){if(j.data('placeholder-password')){j.hide().next().show().focus().attr('id',j.removeAttr('id').data('placeholder-id'))}else{j.val('').removeClass('placeholder')}}}function d(){var n,m=$(this),j=m,l=this.id;if(m.val()===''){if(m.is(':password')){if(!m.data('placeholder-textinput')){try{n=m.clone().attr({type:'text'})}catch(k){n=$('<input>').attr($.extend(f(this),{type:'text'}))}n.removeAttr('name').data('placeholder-password',true).data('placeholder-id',l).bind('focus.placeholder',b);m.data('placeholder-textinput',n).data('placeholder-id',l).before(n)}m=m.removeAttr('id').hide().prev().attr('id',l).show()}m.addClass('placeholder').val(m.attr('placeholder'))}else{m.removeClass('placeholder')}}}(this,document,jQuery));


	/*Highlight*/
/*
highlight v3
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>
*/

jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};

jQuery.fn.removeHighlight = function() {
 return this.find("span.highlight").each(function() {
  this.parentNode.firstChild.nodeName;
  with (this.parentNode) {
   replaceChild(this.firstChild, this);
   normalize();
  }
 }).end();
};

