/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/**
Popupwindow plugin for jQuery.
by: Tony Petruzzi
homepage: http://rip747.wordpress.com
plugin download: http://rip747.wordpress.com/2007/03/02/the-return-of-popupwindow-jquery-plugin/
*/
jQuery.fn.popupwindow=function(p){var g=p||{videos:{height:1200,width:800,status:1},window200:{height:200,width:200,status:1,resizable:0}};return this.each(function(c){var d,e,f,b,a;f=(jQuery(this).attr("rel")||"").split(",");d={height:600,width:600,toolbar:0,scrollbars:0,status:0,resizable:1,left:0,top:0,center:0,createnew:1,location:0,menubar:0};if(f.length==1&&f[0].split(":").length==1){a=f[0];if(typeof g[a]!="undefined"){d=jQuery.extend(d,g[a])}}else{for(var i=0;i<f.length;i++){b=f[i].split(":");if(typeof d[b[0]]!="undefined"&&b.length==2){d[b[0]]=b[1]}}}if(d.center==1){d.top=(screen.height-(d.height+110))/2;d.left=(screen.width-d.width)/2}e="location="+d.location+",menubar="+d.menubar+",height="+d.height+",width="+d.width+",toolbar="+d.toolbar+",scrollbars="+d.scrollbars+",status="+d.status+",resizable="+d.resizable+",left="+d.left+",screenX="+d.left+",top="+d.top+",screenY="+d.top;jQuery(this).bind("click",function(){var a=d.createnew?"PopUpWindow"+c:"PopUpWindow";window.open(this.href,a,e).focus();return false})})};

// Setting for Pop-up Window
var profiles =
	{

		videos:
		{
			height:630,
			width:820,
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			center:1, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:0, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0
		}

	};

// Adds a class focus to input text when focused
	function focusfix(selector, className) {
		$(selector).focus(function() {
			$(this).addClass(className);
		});
		// Removes class when focus is lost
		$(selector).blur(function() {
			$(this).removeClass(className);
		});
	}

$(function() {

	$("q").prepend("&ldquo;").append("&rdquo;");
	$("q q").prepend("&lsquo;").append("&rsquo;");
	// Add classes to input pseudotypes
	$("input[type='text'], input[type='password']").addClass("text");
	$("input[type='button'], input[type='submit'], input[type='checkbox'], input[type='image'], input[type='radio'], input[type='reset'], button").addClass("nontext");
	$("input[type='button'], input[type='submit'], input[type='reset'], button").addClass("button");
	// Focus on the first text input field in the first field on the page
	$("input[type='text']:first").focus();
	// Add focus class to inputs
	focusfix("input.text", "focus");
	// Courseware buttons	
	$("#accordion").accordion({ active: false, autoHeight: false, collapsible: true });
	// Add scrollbars
	$('#channels, #articles').jScrollPane({showArrows:true, scrollbarMargin: 0,  scrollbarWidth: 17, arrowSize: 16});
	$('.jScrollPaneDrag').append('<div class="jScrollPaneGrip" style="width: 9px"></div>');
	// Pop-up windows for videos
	$('.popupwindow').popupwindow(profiles);
	
	// Round Corners 
	$('#merchant_info, #dealer-logo').addClass('ui-corner-all');
	$('.moreInfo').addClass('ui-corner-bottom');
	$('#courseware h3 a span').addClass('ui-corner-left');
});


