/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16.push(key+"="+_18[key]);}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);}if(Array.prototype.push==null){Array.prototype.push=function(_32){this[this.length]=_32;return this.length;};}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all["id"];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http: // www.codylindley.com)
 * Modified by Mikael Ramirez 
 *
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http: // www.opensource.org/licenses/mit-license.php
*/

var tb_pathToImage = "http://www.malespectrum.com/t2/images/thick-box-loading.gif";
var tb_autoSizeValue = false;
var tb_padding = 150;
var isImage = true;

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
 // on page load call tb_init
$(document).ready(function() { 
	tb_init('a.thickbox, area.thickbox, input.thickbox'); // pass where to apply thickbox
	imgLoader = new Image(); //  preload image
	imgLoader.src = tb_pathToImage;
});

 // add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk) {
	$(domChunk).click(function() {
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;
	});
}

// function called when the user clicks on a thickbox link
function tb_show(caption, url, imageGroup) {
	try {
		if (typeof document.body.style.maxHeight === "undefined") { // if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			// this is a trick not allow the browser to scroll since we can't do position: fixed in ie6
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) { // iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}
		else { // all others
			if (document.getElementById("TB_overlay") === null) {
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}
		
		if (tb_detectMacXFF())
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack"); // use png overlay so hide flash
		else
			$("#TB_overlay").addClass("TB_overlayBG"); // use background and opacity
		
		if (caption===null)
			caption="";
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>"); // add loader to the page
		$('#TB_load').show(); // show loader
		
		var baseURL;
		if (url.indexOf("?")!==-1) // ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
		else
			baseURL = url;
		 
	 	var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	 	var urlType = baseURL.toLowerCase().match(urlString);
	
	 	// code to show images	
		if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') {
			isImage = true;
			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if (imageGroup) {
				TB_TempArray = $("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
					if (!(TB_TempArray[TB_Counter].href == url)) {						
						if (TB_FoundURL) {
							TB_NextCaption = TB_TempArray[TB_Counter].title;
							TB_NextURL = TB_TempArray[TB_Counter].href;
							TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
						}
						else {
							TB_PrevCaption = TB_TempArray[TB_Counter].title;
							TB_PrevURL = TB_TempArray[TB_Counter].href;
							TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
						}
					}
					else {
						TB_FoundURL = true;
						TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
					}
				}
			}
			imgPreloader = new Image();
			imgPreloader.onload = function() {		
				imgPreloader.onload = null;
				
				 //  Resizing large images - orginal by Christian Montoya edited by me.
				var pagesize = tb_getPageSize();
				var x = pagesize.width - tb_padding;
				var y = pagesize.height - tb_padding;
				var imageWidth = imgPreloader.width;
				var imageHeight = imgPreloader.height;
			
				// by default we will not resize images to the fit inside the browser with a margin
				// but if you use set tb_autoSize(true) it will resize
				if (tb_autoSize()) {
					if (imageWidth > x) {
						imageHeight = imageHeight * (x / imageWidth); 
						imageWidth = x; 
						if (imageHeight > y) { 
							imageWidth = imageWidth * (y / imageHeight); 
							imageHeight = y; 
						}
					}
					else if (imageHeight > y) { 
						imageWidth = imageWidth * (y / imageHeight); 
						imageHeight = y; 
						if (imageWidth > x) { 
							imageHeight = imageHeight * (x / imageWidth); 
							imageWidth = x;
						}
					}
				}
				//  End Resizing
			
				TB_WIDTH = imageWidth + 30;
				TB_HEIGHT = imageHeight + 60;
				$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");
				$("#TB_closeWindowButton").click(tb_remove);
			
				if (!(TB_PrevHTML === "")) {
					function goPrev() {
						if ($(document).unbind("click", goPrev))
							$(document).unbind("click", goPrev);
						$("#TB_window").remove();
						$("body").append("<div id='TB_window'></div>");
						tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
						return false;	
					}
					$("#TB_prev").click(goPrev);
				}
			
				if (!(TB_NextHTML === "")) {		
					function goNext() {
						$("#TB_window").remove();
						$("body").append("<div id='TB_window'></div>");
						tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
						return false;	
					}
					$("#TB_next").click(goNext);
				
				}
				document.onkeydown = function(e) {	 
					if (e == null) //  ie
						keycode = event.keyCode;
					else  //  mozilla
						keycode = e.which;
					
					if (keycode == 27) //  close
						tb_remove();
					else if (keycode == 190) {  //  display previous image
						if (!(TB_NextHTML == "")) {
							document.onkeydown = "";
							goNext();
						}
					}
					else if (keycode == 188) {  //  display next image
						if (!(TB_PrevHTML == "")) {
							document.onkeydown = "";
							goPrev();
						}
					}	
				};
			
				tb_position();
				$("#TB_load").remove();
				$("#TB_ImageOff").click(tb_remove);
				$("#TB_window").css({display:"block"});  // for safari using css instead of show
			};
			
			imgPreloader.src = url;
		}
		else { // code to show iframe/ajax
			isImage = false;
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );
			var tbwPadding = 0;
			var tbhPadding = 0;
			TB_WIDTH = (params['width']*1) + tbwPadding || 630;  // defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + tbhPadding || 440;  // defaults to 440 if no paramaters were added to URL
			ajaxContentW = TB_WIDTH - tbwPadding;
			ajaxContentH = TB_HEIGHT - tbhPadding;
			
			if (url.indexOf('TB_iframe') != -1) { //  either iframe or ajax window
				urlNoQuery = url.split('TB_');
				$("#TB_iframeContent").remove();
				if (params['modal'] != "true") { // iframe no modal
					$("#TB_window").append(
						"<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div>" +
						"<div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div>" +
						"<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;' > </iframe>"
					);
				}
				else { // iframe modal
					$("#TB_overlay").unbind();
					$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
				}
			}
			else { //  not an iframe, ajax
				if ($("#TB_window").css("display") != "block") {
					if (params['modal'] != "true") { // ajax no modal
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
				}
				else { // ajax modal
					$("#TB_overlay").unbind();
					$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
				}
			}
			else { // this means the window is already up, we are just loading new content via ajax
				$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
				$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
				$("#TB_ajaxContent")[0].scrollTop = 0;
				$("#TB_ajaxWindowTitle").html(caption);
			}
		}
					
		$("#TB_closeWindowButton").click(tb_remove);
		
		if (url.indexOf('TB_inline') != -1) {	
			$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
			$("#TB_window").unload(function () {
				$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() );  //  move elements back when you're finished
			});
			tb_position();
			$("#TB_load").remove();
			$("#TB_window").css({display:"block"}); 
		}
		else if (url.indexOf('TB_iframe') != -1) {
			tb_position();
			if ($.browser.safari) { // safari needs help because it will not fire iframe onload
				$("#TB_load").remove();
				$("#TB_window").css({display:"block"});
			}
		}
		else {
			$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function() { // to do a post change this load method
				tb_position();
				$("#TB_load").remove();
				tb_init("#TB_ajaxContent a.thickbox");
				$("#TB_window").css({display:"block"});
			});
		}
	}
	if (!params['modal']) {
		document.onkeyup = function(e) {
			if (e == null) //  ie
				keycode = event.keyCode;
			else //  mozilla
				keycode = e.which;
			if (keycode == 27) //  close
				tb_remove();
		};
	}
	}
	catch(e) {}
}
 // helper functions below
function tb_showIframe() {
	$("#TB_load").remove();
	$("#TB_window").css({display:"block"});
}
function tb_remove() {
        $("#TB_window iframe").contents().find('object').remove();

	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").stop();
//	$("#TB_window").fadeOut(0,function() {$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") { // if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}
function tb_position() {
	var view = tb_getPageSize();
	var overSized = (TB_WIDTH >= view.width || TB_HEIGHT > view.height) ? true : false;

	if (overSized) {
		$("#TB_window").css({position: 'absolute'});
		// we're in ie6 so undo html{overflow:hidden} and TB_overlay{position: fixed}
		if (typeof document.body.style.maxHeight === "undefined") {
			$("html").css('overflow', 'auto');
			$("#TB_window").css({position: 'absolute', marginTop: 0});
		}
	}
	
	$("#TB_overlay").css('height', overlayHeight);
	$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	
	if (overSized) {
		$("#TB_window").css('top', tb_scrollTop());
	}
	else if (!(jQuery.browser.msie && jQuery.browser.version < 7))
		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});


	$("#TB_window").stop();
	$("#TB_window").fadeIn(186);

	var pg = tb_getDocSize();
	var overlayHeight = pg.height;
	if (overSized) {
		var popHeight = $("#TB_window").height();
		var scrollTop = tb_scrollTop();
		var botOfPopup = scrollTop + popHeight + 20;
		if (pg.height < botOfPopup)
			overlayHeight = botOfPopup;
	}
	$("#TB_overlay").css('height', overlayHeight);

	
}
function tb_parseQuery(query)  {
	 var Params = {};
	 if (!query)
		return Params; //  return empty object
	 var Pairs = query.split(/[;&]/);
	 for (var i = 0; i < Pairs.length; i++) {
		var KeyVal = Pairs[i].split('=');
		if (!KeyVal || KeyVal.length != 2)
			continue;
		var key = unescape(KeyVal[0]);
		var val = unescape(KeyVal[1]);
		val = val.replace(/\+/g, ' ');
		Params[key] = val;
	 }
	 return Params;
}
function tb_getPageSize() {
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	return {width: w, height: h}
}
function tb_detectMacXFF() {
	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1)
		return true;
	return false;
}
function tb_autoSize(val) {
	if (typeof(val) == 'undefined')
		return tb_autoSizeValue;
	tb_autoSizeValue = val;
}
// get the vertical scroll position of the browser
function tb_scrollTop() {
	if (typeof window.pageYOffset != 'undefined')
		return window.pageYOffset;
	else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0)
		return document.documentElement.scrollTop;
	else if (typeof document.body.scrollTop != 'undefined')
		return document.body.scrollTop
	return 0;
}
// get the full width and height of the page
function tb_getDocSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight){ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	return { 
		width: (xScroll < windowWidth) ? windowWidth : xScroll,
		height: (xScroll < windowHeight) ? windowHeight : yScroll
	}
}



/**
 * jCarousel - Riding carousels with jQuery
 *   http://sorgalla.com/jcarousel/
 *
 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Built on top of the jQuery library
 *   http://jquery.com
 *
 * Inspired by the "Carousel Component" by Bill Scott
 *   http://billwscott.com/carousel/
 */

(function($) {
    /**
     * Creates a carousel for all matched elements.
     *
     * @example $("#mycarousel").jcarousel();
     * @before <ul id="mycarousel" class="jcarousel-skin-name"><li>First item</li><li>Second item</li></ul>
     * @result
     *
     * <div class="jcarousel-skin-name">
     *   <div class="jcarousel-container">
     *     <div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
     *     <div class="jcarousel-next"></div>
     *     <div class="jcarousel-clip">
     *       <ul class="jcarousel-list">
     *         <li class="jcarousel-item-1">First item</li>
     *         <li class="jcarousel-item-2">Second item</li>
     *       </ul>
     *     </div>
     *   </div>
     * </div>
     *
     * @name jcarousel
     * @type jQuery
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/jCarousel
     */
    $.fn.jcarousel = function(o) {
        return this.each(function() {
            new $jc(this, o);
        });
    };

    // Default configuration properties.
    var defaults = {
        vertical: false,
        start: 1,
        offset: 1,
        size: null,
        scroll: 3,
        visible: null,
        animation: 'normal',
        easing: 'swing',
        auto: 0,
        wrap: null,
        initCallback: null,
        reloadCallback: null,
        itemLoadCallback: null,
        itemFirstInCallback: null,
        itemFirstOutCallback: null,
        itemLastInCallback: null,
        itemLastOutCallback: null,
        itemVisibleInCallback: null,
        itemVisibleOutCallback: null,
        buttonNextHTML: '<div></div>',
        buttonPrevHTML: '<div></div>',
        buttonNextEvent: 'click',
        buttonPrevEvent: 'click',
        buttonNextCallback: null,
        buttonPrevCallback: null
    };

    /**
     * The jCarousel object.
     *
     * @constructor
     * @name $.jcarousel
     * @param Object e The element to create the carousel for.
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/jCarousel
     */
    $.jcarousel = function(e, o) {
        this.options    = $.extend({}, defaults, o || {});

        this.locked     = false;

        this.container  = null;
        this.clip       = null;
        this.list       = null;
        this.buttonNext = null;
        this.buttonPrev = null;

        this.wh = !this.options.vertical ? 'width' : 'height';
        this.lt = !this.options.vertical ? 'left' : 'top';

        // Extract skin class
        var skin = '', split = e.className.split(' ');

        for (var i = 0; i < split.length; i++) {
            if (split[i].indexOf('jcarousel-skin') != -1) {
                $(e).removeClass(split[i]);
                var skin = split[i];
                break;
            }
        }

        if (e.nodeName == 'UL' || e.nodeName == 'OL') {
            this.list = $(e);
            this.container = this.list.parent();

            if (this.container.hasClass('jcarousel-clip')) {
                if (!this.container.parent().hasClass('jcarousel-container'))
                    this.container = this.container.wrap('<div></div>');

                this.container = this.container.parent();
            } else if (!this.container.hasClass('jcarousel-container'))
                this.container = this.list.wrap('<div></div>').parent();
        } else {
            this.container = $(e);
            this.list = $(e).find('>ul,>ol,div>ul,div>ol');
        }

        if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1)
        	this.container.wrap('<div class=" '+ skin + '"></div>');

        this.clip = this.list.parent();

        if (!this.clip.length || !this.clip.hasClass('jcarousel-clip'))
            this.clip = this.list.wrap('<div></div>').parent();

        this.buttonPrev = $('.jcarousel-prev', this.container);

        if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null)
            this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev();

        this.buttonPrev.addClass(this.className('jcarousel-prev'));

        this.buttonNext = $('.jcarousel-next', this.container);

        if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null)
            this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev();

        this.buttonNext.addClass(this.className('jcarousel-next'));

        this.clip.addClass(this.className('jcarousel-clip'));
        this.list.addClass(this.className('jcarousel-list'));
        this.container.addClass(this.className('jcarousel-container'));

        var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
        var li = this.list.children('li');

        var self = this;

        if (li.size() > 0) {
            var wh = 0, i = this.options.offset;
            li.each(function() {
                self.format(this, i++);
                wh += self.dimension(this, di);
            });

            this.list.css(this.wh, wh + 'px');

            // Only set if not explicitly passed as option
            if (!o || o.size === undefined)
                this.options.size = li.size();
        }

        // For whatever reason, .show() does not work in Safari...
        this.container.css('display', 'block');
        this.buttonNext.css('display', 'block');
        this.buttonPrev.css('display', 'block');

        this.funcNext   = function() { self.next(); };
        this.funcPrev   = function() { self.prev(); };
        this.funcResize = function() { self.reload(); };

        if (this.options.initCallback != null)
            this.options.initCallback(this, 'init');

        if ($.browser.safari) {
            this.buttons(false, false);
            $(window).bind('load', function() { self.setup(); });
        } else
            this.setup();
    };

    // Create shortcut for internal use
    var $jc = $.jcarousel;

    $jc.fn = $jc.prototype = {
        jcarousel: '0.2.3'
    };

    $jc.fn.extend = $jc.extend = $.extend;

    $jc.fn.extend({
        /**
         * Setups the carousel.
         *
         * @name setup
         * @type undefined
         * @cat Plugins/jCarousel
         */
        setup: function() {
            this.first     = null;
            this.last      = null;
            this.prevFirst = null;
            this.prevLast  = null;
            this.animating = false;
            this.timer     = null;
            this.tail      = null;
            this.inTail    = false;

            if (this.locked)
                return;

            this.list.css(this.lt, this.pos(this.options.offset) + 'px');
            var p = this.pos(this.options.start);
            this.prevFirst = this.prevLast = null;
            this.animate(p, false);

            $(window).unbind('resize', this.funcResize).bind('resize', this.funcResize);
        },

        /**
         * Clears the list and resets the carousel.
         *
         * @name reset
         * @type undefined
         * @cat Plugins/jCarousel
         */
        reset: function() {
            this.list.empty();

            this.list.css(this.lt, '0px');
            this.list.css(this.wh, '10px');

            if (this.options.initCallback != null)
                this.options.initCallback(this, 'reset');

            this.setup();
        },

        /**
         * Reloads the carousel and adjusts positions.
         *
         * @name reload
         * @type undefined
         * @cat Plugins/jCarousel
         */
        reload: function() {
            if (this.tail != null && this.inTail)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail);

            this.tail   = null;
            this.inTail = false;

            if (this.options.reloadCallback != null)
                this.options.reloadCallback(this);

            if (this.options.visible != null) {
                var self = this;
                var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0;
                $('li', this.list).each(function(i) {
                    wh += self.dimension(this, di);
                    if (i + 1 < self.first)
                        lt = wh;
                });

                this.list.css(this.wh, wh + 'px');
                this.list.css(this.lt, -lt + 'px');
            }

            this.scroll(this.first, false);
        },

        /**
         * Locks the carousel.
         *
         * @name lock
         * @type undefined
         * @cat Plugins/jCarousel
         */
        lock: function() {
            this.locked = true;
            this.buttons();
        },

        /**
         * Unlocks the carousel.
         *
         * @name unlock
         * @type undefined
         * @cat Plugins/jCarousel
         */
        unlock: function() {
            this.locked = false;
            this.buttons();
        },

        /**
         * Sets the size of the carousel.
         *
         * @name size
         * @type undefined
         * @param Number s The size of the carousel.
         * @cat Plugins/jCarousel
         */
        size: function(s) {
            if (s != undefined) {
                this.options.size = s;
                if (!this.locked)
                    this.buttons();
            }

            return this.options.size;
        },

        /**
         * Checks whether a list element exists for the given index (or index range).
         *
         * @name get
         * @type bool
         * @param Number i The index of the (first) element.
         * @param Number i2 The index of the last element.
         * @cat Plugins/jCarousel
         */
        has: function(i, i2) {
            if (i2 == undefined || !i2)
                i2 = i;

            if (this.options.size !== null && i2 > this.options.size)
            	i2 = this.options.size;

            for (var j = i; j <= i2; j++) {
                var e = this.get(j);
                if (!e.length || e.hasClass('jcarousel-item-placeholder'))
                    return false;
            }

            return true;
        },

        /**
         * Returns a jQuery object with list element for the given index.
         *
         * @name get
         * @type jQuery
         * @param Number i The index of the element.
         * @cat Plugins/jCarousel
         */
        get: function(i) {
            return $('.jcarousel-item-' + i, this.list);
        },

        /**
         * Adds an element for the given index to the list.
         * If the element already exists, it updates the inner html.
         * Returns the created element as jQuery object.
         *
         * @name add
         * @type jQuery
         * @param Number i The index of the element.
         * @param String s The innerHTML of the element.
         * @cat Plugins/jCarousel
         */
        add: function(i, s) {
            var e = this.get(i), old = 0, add = 0;

            if (e.length == 0) {
                var c, e = this.create(i), j = $jc.intval(i);
                while (c = this.get(--j)) {
                    if (j <= 0 || c.length) {
                        j <= 0 ? this.list.prepend(e) : c.after(e);
                        break;
                    }
                }
            } else
                old = this.dimension(e);

            e.removeClass(this.className('jcarousel-item-placeholder'));
            typeof s == 'string' ? e.html(s) : e.empty().append(s);

            var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
            var wh = this.dimension(e, di) - old;

            if (i > 0 && i < this.first)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px');

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px');

            return e;
        },

        /**
         * Removes an element for the given index from the list.
         *
         * @name remove
         * @type undefined
         * @param Number i The index of the element.
         * @cat Plugins/jCarousel
         */
        remove: function(i) {
            var e = this.get(i);

            // Check if item exists and is not currently visible
            if (!e.length || (i >= this.first && i <= this.last))
                return;

            var d = this.dimension(e);

            if (i < this.first)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');

            e.remove();

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
        },

        /**
         * Moves the carousel forwards.
         *
         * @name next
         * @type undefined
         * @cat Plugins/jCarousel
         */
        next: function() {
            this.stopAuto();

            if (this.tail != null && !this.inTail)
                this.scrollTail(false);
            else
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
        },

        /**
         * Moves the carousel backwards.
         *
         * @name prev
         * @type undefined
         * @cat Plugins/jCarousel
         */
        prev: function() {
            this.stopAuto();

            if (this.tail != null && this.inTail)
                this.scrollTail(true);
            else
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
        },

        /**
         * Scrolls the tail of the carousel.
         *
         * @name scrollTail
         * @type undefined
         * @param Bool b Whether scroll the tail back or forward.
         * @cat Plugins/jCarousel
         */
        scrollTail: function(b) {
            if (this.locked || this.animating || !this.tail)
                return;

            var pos  = $jc.intval(this.list.css(this.lt));

            !b ? pos -= this.tail : pos += this.tail;
            this.inTail = !b;

            // Save for callbacks
            this.prevFirst = this.first;
            this.prevLast  = this.last;

            this.animate(pos);
        },

        /**
         * Scrolls the carousel to a certain position.
         *
         * @name scroll
         * @type undefined
         * @param Number i The index of the element to scoll to.
         * @param Bool a Flag indicating whether to perform animation.
         * @cat Plugins/jCarousel
         */
        scroll: function(i, a) {
            if (this.locked || this.animating)
                return;

            this.animate(this.pos(i), a);
        },

        /**
         * Prepares the carousel and return the position for a certian index.
         *
         * @name pos
         * @type Number
         * @param Number i The index of the element to scoll to.
         * @cat Plugins/jCarousel
         */
        pos: function(i) {
            if (this.locked || this.animating)
                return;

            if (this.options.wrap != 'circular')
                i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);

            var back = this.first > i;
            var pos  = $jc.intval(this.list.css(this.lt));

            // Create placeholders, new list width/height
            // and new list position
            var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
            var c = back ? this.get(f) : this.get(this.last);
            var j = back ? f : f - 1;
            var e = null, l = 0, p = false, d = 0;

            while (back ? --j >= i : ++j < i) {
                e = this.get(j);
                p = !e.length;
                if (e.length == 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    c[back ? 'before' : 'after' ](e);
                }

                c = e;
                d = this.dimension(e);

                if (p)
                    l += d;

                if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
                    pos = back ? pos + d : pos - d;
            }

            // Calculate visible items
            var clipping = this.clipping();
            var cache = [];
            var visible = 0, j = i, v = 0;
            var c = this.get(i - 1);

            while (++visible) {
                e = this.get(j);
                p = !e.length;
                if (e.length == 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    // This should only happen on a next scroll
                    c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
                }

                c = e;
                var d = this.dimension(e);
                if (d == 0) {
                    //console.log('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
                    return 0;
                }

                if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
                    cache.push(e);
                else if (p)
                    l += d;

                v += d;

                if (v >= clipping)
                    break;

                j++;
            }

             // Remove out-of-range placeholders
            for (var x = 0; x < cache.length; x++)
                cache[x].remove();

            // Resize list
            if (l > 0) {
                this.list.css(this.wh, this.dimension(this.list) + l + 'px');

                if (back) {
                    pos -= l;
                    this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
                }
            }

            // Calculate first and last item
            var last = i + visible - 1;
            if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
                last = this.options.size;

            if (j > last) {
                visible = 0, j = last, v = 0;
                while (++visible) {
                    var e = this.get(j--);
                    if (!e.length)
                        break;
                    v += this.dimension(e);
                    if (v >= clipping)
                        break;
                }
            }

            var first = last - visible + 1;
            if (this.options.wrap != 'circular' && first < 1)
                first = 1;

            if (this.inTail && back) {
                pos += this.tail;
                this.inTail = false;
            }

            this.tail = null;
            if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
                var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
                if ((v - m) > clipping)
                    this.tail = v - clipping - m;
            }

            // Adjust position
            while (i-- > first)
                pos += this.dimension(this.get(i));

            // Save visible item range
            this.prevFirst = this.first;
            this.prevLast  = this.last;
            this.first     = first;
            this.last      = last;

            return pos;
        },

        /**
         * Animates the carousel to a certain position.
         *
         * @name animate
         * @type undefined
         * @param mixed p Position to scroll to.
         * @param Bool a Flag indicating whether to perform animation.
         * @cat Plugins/jCarousel
         */
        animate: function(p, a) {
            if (this.locked || this.animating)
                return;

            this.animating = true;

            var self = this;
            var scrolled = function() {
                self.animating = false;

                if (p == 0)
                    self.list.css(self.lt,  0);

                if (self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size)
                    self.startAuto();

                self.buttons();
                self.notify('onAfterAnimation');
            };

            this.notify('onBeforeAnimation');

            // Animate
            if (!this.options.animation || a == false) {
                this.list.css(this.lt, p + 'px');
                scrolled();
            } else {
                var o = !this.options.vertical ? {'left': p} : {'top': p};
                this.list.animate(o, this.options.animation, this.options.easing, scrolled);
            }
        },

        /**
         * Starts autoscrolling.
         *
         * @name auto
         * @type undefined
         * @param Number s Seconds to periodically autoscroll the content.
         * @cat Plugins/jCarousel
         */
        startAuto: function(s) {
            if (s != undefined)
                this.options.auto = s;

            if (this.options.auto == 0)
                return this.stopAuto();

            if (this.timer != null)
                return;

            var self = this;
            this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000);
        },

        /**
         * Stops autoscrolling.
         *
         * @name stopAuto
         * @type undefined
         * @cat Plugins/jCarousel
         */
        stopAuto: function() {
            if (this.timer == null)
                return;

            clearTimeout(this.timer);
            this.timer = null;
        },

        /**
         * Sets the states of the prev/next buttons.
         *
         * @name buttons
         * @type undefined
         * @cat Plugins/jCarousel
         */
        buttons: function(n, p) {
            if (n == undefined || n == null) {
                var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size)
                    n = this.tail != null && !this.inTail;
            }

            if (p == undefined || p == null) {
                var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1)
                    p = this.tail != null && this.inTail;
            }

            var self = this;

            this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent, this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true);
            this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent, this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true);

            if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) {
                this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); });
                this.buttonNext[0].jcarouselstate = n;
            }

            if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) {
                this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); });
                this.buttonPrev[0].jcarouselstate = p;
            }
        },

        notify: function(evt) {
            var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');

            // Load items
            this.callback('itemLoadCallback', evt, state);

            if (this.prevFirst !== this.first) {
                this.callback('itemFirstInCallback', evt, state, this.first);
                this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
            }

            if (this.prevLast !== this.last) {
                this.callback('itemLastInCallback', evt, state, this.last);
                this.callback('itemLastOutCallback', evt, state, this.prevLast);
            }

            this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
            this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
        },

        callback: function(cb, evt, state, i1, i2, i3, i4) {
            if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation'))
                return;

            var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb];

            if (!$.isFunction(callback))
                return;

            var self = this;

            if (i1 === undefined)
                callback(self, state, evt);
            else if (i2 === undefined)
                this.get(i1).each(function() { callback(self, this, i1, state, evt); });
            else {
                for (var i = i1; i <= i2; i++)
                    if (i !== null && !(i >= i3 && i <= i4))
                        this.get(i).each(function() { callback(self, this, i, state, evt); });
            }
        },

        create: function(i) {
            return this.format('<li></li>', i);
        },

        format: function(e, i) {
            var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i));
            $e.attr('jcarouselindex', i);
            return $e;
        },

        className: function(c) {
            return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical');
        },

        dimension: function(e, d) {
            var el = e.jquery != undefined ? e[0] : e;

            var old = !this.options.vertical ?
                el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') :
                el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom');

            if (d == undefined || old == d)
                return old;

            var w = !this.options.vertical ?
                d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') :
                d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom');

            $(el).css(this.wh, w + 'px');

            return this.dimension(el);
        },

        clipping: function() {
            return !this.options.vertical ?
                this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) :
                this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth'));
        },

        index: function(i, s) {
            if (s == undefined)
                s = this.options.size;

            return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1;
        }
    });

    $jc.extend({
        /**
         * Gets/Sets the global default configuration properties.
         *
         * @name defaults
         * @descr Gets/Sets the global default configuration properties.
         * @type Hash
         * @param Hash d A set of key/value pairs to set as configuration properties.
         * @cat Plugins/jCarousel
         */
        defaults: function(d) {
            return $.extend(defaults, d || {});
        },

        margin: function(e, p) {
            if (!e)
                return 0;

            var el = e.jquery != undefined ? e[0] : e;

            if (p == 'marginRight' && $.browser.safari) {
                var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;

                $.swap(el, old, function() { oWidth = el.offsetWidth; });

                old['marginRight'] = 0;
                $.swap(el, old, function() { oWidth2 = el.offsetWidth; });

                return oWidth2 - oWidth;
            }

            return $jc.intval($.css(el, p));
        },

        intval: function(v) {
            v = parseInt(v);
            return isNaN(v) ? 0 : v;
        }
    });

})(jQuery);



/* 	BLRollOver and BLPopup
	Author: Mikael Ramirez

	This library is meant to supersede the DreamWeaver mouse over library and works with
	PNG fixes applied for IE 6.

 	Credits: 
	http://events in IE 5
*/

if (typeof Array.prototype.push != "function") {
	Array.prototype.push = ArrayPush;
	function ArrayPush(value) {
		this[this.length] = value;
	}
}

if (typeof blurri == "undefined")
	var blurri = {};
if (typeof blurri.blRollOver == "undefined")
	blurri.blRollOver = {};
if (typeof blurri.blPopup == "undefined")
	blurri.blPopup = {};
if (typeof blurri.lib == "undefined")
	blurri.lib = {};

blurri.timerID  = 0;
blurri.TIME_OUT_LEN = 800;
blurri.offX = 0;
blurri.offY = 0;
blurri.ieFix = false;
blurri.callbackData = null;
blurri.callbackClear = null;

if (!window.opera) {
	if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
		blurri.ieFix = true;
}
/* START POPUP CODE */ 
blurri.blPopup = function(_cs, _id, _callbackData, _callbackClear) {
 	if (typeof _callbackData != 'undefined')
		blurri.callbackData = _callbackData;
	if (typeof _callbackClear != 'undefined')
		blurri.callbackClear = _callbackClear;
	blurri.blPopup.s = {classname: _cs, popup: _id};
	blurri.lib.addEvent(window, "load", blurri.lib.setupPopup);
}
blurri.lib.setupPopup = function() {
	var cs = blurri.blPopup.s.classname;
	if (!cs.length)
		return;
	if (!(blurri.blPopup.popup = document.getElementById(blurri.blPopup.s['popup'])))
		return;

	/* 	in ie6 and 5.5 the popup will not cover form controls even if the z-index is higher than them
		so the only fix is to use an iframe underneath it in these browsers */
	if (blurri.ieFix) {
		var shim = document.createElement('iframe');
		shim.id = 'popupShim';
		shim.name = 'popupShim';
		shim.style.position = 'absolute';
		shim.style.visibility = 'hidden';
		shim.style.left = 0;
		shim.style.top = 0;
		shim.width = 2;
		shim.height = 2;
		shim.src = 'about:blank';
		shim.frameBorder = 0;
		shim.scrolling = 'no';
		blurri.blPopup.shim = shim;
		var bodyRef = document.getElementsByTagName("body").item(0);
		bodyRef.appendChild(shim);
	}

	var b = blurri.lib.getElementsByClassName(null, "a", cs);
	if (b.length) {
		for (var i=0, len=b.length; i<len; i++) {
			blurri.lib.addEvent(b[i], 'mouseover', blurri.lib.popupOver);














































			blurri.lib.addEvent(b[i], 'mouseout', blurri.lib.popupOut);
		}
	}
	delete blurri.blPopup.s;
}
blurri.lib.popupShow = function(sh) {
	var popup = blurri.blPopup.popup;
	var shim = blurri.blPopup.shim;
	popup.style.visibility = sh;

	if (blurri.ieFix && (typeof shim != undefined)) {
		shim.style.visibility = sh;
		shim.style.left  = popup.style.left;
		shim.style.top = popup.style.top;
		shim.style.width = popup.clientWidth;	
		shim.style.height = popup.clientHeight;
	}
}
blurri.lib.popupOver = function() {
	blurri.timerID = window.setTimeout ("blurri.lib.popupShow('visible')", blurri.TIME_OUT_LEN);
	blurri.lib.addEvent(this, 'mousemove', blurri.lib.popupMove);
	if (blurri.callbackData)
		blurri.callbackData(blurri.blPopup.popup, this.id);
}
blurri.lib.popupOut = function() {
	if (blurri.timerID) {
		window.clearTimeout (blurri.timerID);
		blurri.timerID = 0;
	}
	blurri.lib.popupShow('hidden');
	blurri.lib.removeEvent(this, 'mousemove', blurri.lib.popupMove);
	if (blurri.callbackClear)
		blurri.callbackClear(blurri.blPopup.popup);
}
blurri.lib.popupMove = function(e) {
	blurri.lib.movePopup(blurri.blPopup.popup, e);
}
blurri.lib.movePopup = function(obj, e) {
	var p = blurri.lib;
	var shim = blurri.blPopup.shim;
	var off = 10;
	var objx = parseInt(p.mx(e))+off;
	var objy = parseInt(p.my(e))+off;

	if (objx + obj.clientWidth >= (p.getViewportWidth()-15))
		objx -= (obj.clientWidth+(off*2));
	if (objy + obj.clientHeight >= (p.getViewportHeight()+p.getVerticalScroll()-15))
		objy -= (obj.clientHeight+(off*2));

	obj.style.left = (objx.toString() + 'px');
	obj.style.top = (objy.toString() + 'px');

	if (blurri.ieFix && (typeof shim != undefined)) {
		shim.style.left  = obj.style.left;
		shim.style.top = obj.style.top;
	}
	
}
/* END POPUP CODE */

/* START ROLLOVER CODE */
blurri.blRollOver = function (_array) {
	blurri.blRollOver.s = _array;
	blurri.lib.addEvent(window, "load", blurri.lib.setupButtons);
}
blurri.lib.setupButtons = function() {
	var da = blurri.blRollOver.s;
	if (!da)
		return;
	for (var c in da) {
		var pi1 = new Image();
		var pi2 = new Image();
		pi1.src = da[c][0];
		pi2.src = da[c][1];
		var b = blurri.lib.getElementsByClassName(null, "a", c);
		if (!b.length || da[c].length != 2)
			continue;
		for (var i=0, len=b.length; i<len; i++) {
			var img = b[i].getElementsByTagName("img");
			if (img.length) {
				b[i].outSrc = da[c][0];
				b[i].overSrc = da[c][1];
				blurri.lib.addEvent(b[i], 'mouseover', blurri.lib.buttonOver);
				blurri.lib.addEvent(b[i], 'mouseout', blurri.lib.buttonOut)
			}
		}
	}
	delete blurri.blRollOver.s;
}
blurri.lib.buttonOver = function() {
	var img = this.getElementsByTagName("img");
	img[0].src = this.overSrc;
}
blurri.lib.buttonOut = function() {
	var img = this.getElementsByTagName("img");
	img[0].src = this.outSrc;
}
/* END ROLLOVER CODE */

/* COMMON LIBRARY CODE */
blurri.lib.addEvent = function(obj, type, fn) {
	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]);
	}
	else
		obj.addEventListener(type, fn, false);
}
blurri.lib.removeEvent = function(obj, type, fn) {
	if (obj.detachEvent) {
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	}
	else
		obj.removeEventListener(type, fn, false);
}
blurri.lib.getElementsByClassName = function (oElm, strTagName, strClassName) {
	if (oElm == null)
		oElm = document;
	else
		oElm = document.getElementById(oElm);
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++) {
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className))
			arrReturnElements.push(oElement);
	}
	return (arrReturnElements);
}
// get the mouse x position
blurri.lib.mx = function(e) { 
	if (!e)
		var e = window.event;
	if (e && e.pageX)
		return e.pageX;


	else if (e && e.clientX) {
		return e.clientX + (
			document.documentElement.scrollLeft ?
			document.documentElement.scrollLeft :
			document.body.scrollLeft);
	}
	else
		return 0;
}
// get the mouse y position
blurri.lib.my = function(e) {
	if (!e)
		var e = window.event;
	if (e && e.pageY)
		return e.pageY;
	else if (e && e.clientY) {
		return e.clientY + (
			document.documentElement.scrollTop ?
			document.documentElement.scrollTop :
			document.body.scrollTop);
	}
  	else
		return 0;
}
// initialize this lib
blurri.init = function () {
	var p = blurri.lib;
	// All browsers but IE
	if (window.innerWidth) { 
		p.getViewportWidth = function()		{ return window.innerWidth; };
		p.getViewportHeight = function()	{ return window.innerHeight; };
		p.getHorizontalScroll = function()	{ return window.pageXOffset; };
		p.getVerticalScroll = function()	{ return window.pageYOffset; };
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
	    // These functions are for IE 6 when there is a DOCTYPE
		p.getViewportWidth = function()		{ return document.documentElement.clientWidth; };
		p.getViewportHeight = function()	{ return document.documentElement.clientHeight; };
		p.getHorizontalScroll = function()	{ return document.documentElement.scrollLeft; };
		p.getVerticalScroll = function() 	{ return document.documentElement.scrollTop; };
	}
	else if (document.body.clientWidth) {
	    // These are for IE4, IE5, and IE6 without a DOCTYPE
		p.getViewportWidth = function()		{ return document.body.clientWidth; };
		p.getViewportHeight = function()	{ return document.body.clientHeight; };
		p.getHorizontalScroll = function()	{ return document.body.scrollLeft; };
		p.getVerticalScroll = function()	{ return document.body.scrollTop; }
	}
	blurri.lib.addEvent (window, "load", blurri.init);
	delete blurri.init;
};
blurri.lib.addEvent (window, "load", blurri.init);

var BLRollOver = blurri.blRollOver;
var BLPopup = blurri.blPopup;




	jQuery('document').ready(function() {
    	$('#mainCarousel').jcarousel({scroll: 4});	
	});
	
	function writePromoPlayer(divID, vidUrl) {
		var so = new SWFObject('http://www.malespectrum.com/t2/images/simple-player.swf', divID + '_child','533', '332', "9", "#000000");
		so.addVariable('color','#298dcc');
		so.addVariable('noticeDisplay', false);
		so.addVariable('autoPlay', false);
		so.addVariable('autoPlay', false);
		so.addVariable('stillImage', 'http://www.malespectrum.com/t2/images/flash-player-still.png');
		so.addVariable('video', vidUrl);
		so.addParam ('wmode', 'opaque');
		so.addParam ('allowFullScreen', 'true');
		so.write(divID);
	}
	function writeScollerDex(divID) {
		var so = new SWFObject('http://www.malespectrum.com/t2/images/scrollerdex.swf', divID + '_child','602', '179', "9");
		so.addParam ('wmode', 'transparent');
		so.addVariable('jsWindowFunc', 'newWindowFunc');
		so.write(divID);
	}

function newWindowFunc(url) {
  window.open(url);
}