
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

//Last-child hack
$('ul.menu > li:last-child').addClass('last-child');



// place any jQuery/helper plugins in here, instead of separate, slower script files.
/* EXTERNAL 
give anchors with attribute rel="external" a target attribute of "_blank" */

function external() {
 if (document.getElementsByTagName) {
  var i, a;
  a = document.getElementsByTagName('a');
 
 for (i in a) {
   var childNode = a[i];
	 if (childNode.nodeType === 1) {
	 		if (a[i].getAttribute('href') && a[i].getAttribute('rel') == 'external') a[i].target = '_blank';
	 }
 }
 
 }
}

/*
CSS Browser Selector v0.3.2
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; 
 
// ColorBox v1.3.16 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(a,b,c){function ba(b){if(!T){O=b,Z(a.extend(J,a.data(O,e))),x=a(O),P=0,J.rel!=="nofollow"&&(x=a("."+V).filter(function(){var b=a.data(this,e).rel||this.rel;return b===J.rel}),P=x.index(O),P===-1&&(x=x.add(O),P=x.length-1));if(!R){R=S=!0,q.show();if(J.returnFocus)try{O.blur(),a(O).one(k,function(){try{this.focus()}catch(a){}})}catch(c){}p.css({opacity:+J.opacity,cursor:J.overlayClose?"pointer":"auto"}).show(),J.w=X(J.initialWidth,"x"),J.h=X(J.initialHeight,"y"),U.position(0),n&&y.bind("resize."+o+" scroll."+o,function(){p.css({width:y.width(),height:y.height(),top:y.scrollTop(),left:y.scrollLeft()})}).trigger("resize."+o),$(g,J.onOpen),I.add(C).hide(),H.html(J.close).show()}U.load(!0)}}function _(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;J.slideshow&&x[1]&&(d=function(){E.text(J.slideshowStop).unbind(c).bind(i,function(){if(P<x.length-1||J.loop)a=setTimeout(U.next,J.slideshowSpeed)}).bind(h,function(){clearTimeout(a)}).one(c+" "+j,e),q.removeClass(b+"off").addClass(b+"on"),a=setTimeout(U.next,J.slideshowSpeed)},e=function(){clearTimeout(a),E.text(J.slideshowStart).unbind([i,h,j,c].join(" ")).one(c,d),q.removeClass(b+"on").addClass(b+"off")},J.slideshowAuto?d():e())}function $(b,c){c&&c.call(O),a.event.trigger(b)}function Z(b){for(var c in b)a.isFunction(b[c])&&c.substring(0,2)!=="on"&&(b[c]=b[c].call(O));b.rel=b.rel||O.rel||"nofollow",b.href=a.trim(b.href||a(O).attr("href")),b.title=b.title||O.title}function Y(a){return J.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)}function X(a,b){b=b==="x"?y.width():y.height();return typeof a=="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function W(c,d){var e=b.createElement("div");c&&(e.id=f+c),e.style.cssText=d||!1;return a(e)}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0},e="colorbox",f="cbox",g=f+"_open",h=f+"_load",i=f+"_complete",j=f+"_cleanup",k=f+"_closed",l=f+"_purge",m=a.browser.msie&&!a.support.opacity,n=m&&a.browser.version<7,o=f+"_IE6",p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J={},K,L,M,N,O,P,Q,R,S,T=!1,U,V=f+"Element";U=a.fn[e]=a[e]=function(b,c){var f=this,g;if(!f[0]&&f.selector)return f;b=b||{},c&&(b.onComplete=c);if(!f[0]||f.selector===undefined)f=a("<a/>"),b.open=!0;f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(V)}),g=b.open,a.isFunction(g)&&(g=g.call(f)),g&&ba(f[0]);return f},U.init=function(){y=a(c),q=W().attr({id:e,"class":m?f+(n?"IE6":"IE"):""}),p=W("Overlay",n?"position:absolute":"").hide(),r=W("Wrapper"),s=W("Content").append(z=W("LoadedContent","width:0; height:0; overflow:hidden"),B=W("LoadingOverlay").add(W("LoadingGraphic")),C=W("Title"),D=W("Current"),F=W("Next"),G=W("Previous"),E=W("Slideshow").bind(g,_),H=W("Close")),r.append(W().append(W("TopLeft"),t=W("TopCenter"),W("TopRight")),W(!1,"clear:left").append(u=W("MiddleLeft"),s,v=W("MiddleRight")),W(!1,"clear:left").append(W("BottomLeft"),w=W("BottomCenter"),W("BottomRight"))).children().children().css({"float":"left"}),A=W(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(p,q.append(r,A)),s.children().hover(function(){a(this).addClass("hover")},function(){a(this).removeClass("hover")}).addClass("hover"),K=t.height()+w.height()+s.outerHeight(!0)-s.height(),L=u.width()+v.width()+s.outerWidth(!0)-s.width(),M=z.outerHeight(!0),N=z.outerWidth(!0),q.css({"padding-bottom":K,"padding-right":L}).hide(),F.click(function(){U.next()}),G.click(function(){U.prev()}),H.click(function(){U.close()}),I=F.add(G).add(D).add(E),s.children().removeClass("hover"),a("."+V).live("click",function(a){a.button!==0&&typeof a.button!="undefined"||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),ba(this))}),p.click(function(){J.overlayClose&&U.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;R&&J.escKey&&b===27&&(a.preventDefault(),U.close()),R&&J.arrowKey&&x[1]&&(b===37?(a.preventDefault(),G.click()):b===39&&(a.preventDefault(),F.click()))})},U.remove=function(){q.add(p).remove(),a("."+V).die("click").removeData(e).removeClass(V)},U.position=function(a,c){function g(a){t[0].style.width=w[0].style.width=s[0].style.width=a.style.width,B[0].style.height=B[1].style.height=s[0].style.height=u[0].style.height=v[0].style.height=a.style.height}var d,e=Math.max(b.documentElement.clientHeight-J.h-M-K,0)/2+y.scrollTop(),f=Math.max(y.width()-J.w-N-L,0)/2+y.scrollLeft();d=q.width()===J.w+N&&q.height()===J.h+M?0:a,r[0].style.width=r[0].style.height="9999px",q.dequeue().animate({width:J.w+N,height:J.h+M,top:e,left:f},{duration:d,complete:function(){g(this),S=!1,r[0].style.width=J.w+N+L+"px",r[0].style.height=J.h+M+K+"px",c&&c()},step:function(){g(this)}})},U.resize=function(a){if(R){a=a||{},a.width&&(J.w=X(a.width,"x")-N-L),a.innerWidth&&(J.w=X(a.innerWidth,"x")),z.css({width:J.w}),a.height&&(J.h=X(a.height,"y")-M-K),a.innerHeight&&(J.h=X(a.innerHeight,"y"));if(!a.innerHeight&&!a.height){var b=z.wrapInner("<div style='overflow:auto'></div>").children();J.h=b.height(),b.replaceWith(b.children())}z.css({height:J.h}),U.position(J.transition==="none"?0:J.speed)}},U.prep=function(b){function h(b){U.position(b,function(){var b,d,g,h,j=x.length,k,n;!R||(n=function(){B.hide(),$(i,J.onComplete)},m&&Q&&z.fadeIn(100),C.html(J.title).add(z).show(),j>1?(typeof J.current=="string"&&D.html(J.current.replace(/\{current\}/,P+1).replace(/\{total\}/,j)).show(),F[J.loop||P<j-1?"show":"hide"]().html(J.next),G[J.loop||P?"show":"hide"]().html(J.previous),b=P?x[P-1]:x[j-1],g=P<j-1?x[P+1]:x[0],J.slideshow&&E.show(),J.preloading&&(h=a.data(g,e).href||g.href,d=a.data(b,e).href||b.href,h=a.isFunction(h)?h.call(g):h,d=a.isFunction(d)?d.call(b):d,Y(h)&&(a("<img/>")[0].src=h),Y(d)&&(a("<img/>")[0].src=d))):I.hide(),J.iframe?(k=a("<iframe/>").addClass(f+"Iframe")[0],J.fastIframe?n():a(k).load(n),k.name=f+ +(new Date),k.src=J.href,J.scrolling||(k.scrolling="no"),m&&(k.frameBorder=0,k.allowTransparency="true"),a(k).appendTo(z).one(l,function(){k.src="//about:blank"})):n(),J.transition==="fade"?q.fadeTo(c,1,function(){q[0].style.filter=""}):q[0].style.filter="",y.bind("resize."+f,function(){U.position(0)}))})}function g(){J.h=J.h||z.height(),J.h=J.mh&&J.mh<J.h?J.mh:J.h;return J.h}function d(){J.w=J.w||z.width(),J.w=J.mw&&J.mw<J.w?J.mw:J.w;return J.w}if(!!R){var c=J.transition==="none"?0:J.speed;y.unbind("resize."+f),z.remove(),z=W("LoadedContent").html(b),z.hide().appendTo(A.show()).css({width:d(),overflow:J.scrolling?"auto":"hidden"}).css({height:g()}).prependTo(s),A.hide(),a(Q).css({"float":"none"}),n&&a("select").not(q.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(j,function(){this.style.visibility="inherit"}),J.transition==="fade"?q.fadeTo(c,0,function(){h(0)}):h(c)}},U.load=function(b){var c,d,g=U.prep;S=!0,Q=!1,O=x[P],b||Z(a.extend(J,a.data(O,e))),$(l),$(h,J.onLoad),J.h=J.height?X(J.height,"y")-M-K:J.innerHeight&&X(J.innerHeight,"y"),J.w=J.width?X(J.width,"x")-N-L:J.innerWidth&&X(J.innerWidth,"x"),J.mw=J.w,J.mh=J.h,J.maxWidth&&(J.mw=X(J.maxWidth,"x")-N-L,J.mw=J.w&&J.w<J.mw?J.w:J.mw),J.maxHeight&&(J.mh=X(J.maxHeight,"y")-M-K,J.mh=J.h&&J.h<J.mh?J.h:J.mh),c=J.href,B.show(),J.inline?(W().hide().insertBefore(a(c)[0]).one(l,function(){a(this).replaceWith(z.children())}),g(a(c))):J.iframe?g(" "):J.html?g(J.html):Y(c)?(a(Q=new Image).addClass(f+"Photo").error(function(){J.title=!1,g(W("Error").text("This image could not be loaded"))}).load(function(){var a;Q.onload=null,J.scalePhotos&&(d=function(){Q.height-=Q.height*a,Q.width-=Q.width*a},J.mw&&Q.width>J.mw&&(a=(Q.width-J.mw)/Q.width,d()),J.mh&&Q.height>J.mh&&(a=(Q.height-J.mh)/Q.height,d())),J.h&&(Q.style.marginTop=Math.max(J.h-Q.height,0)/2+"px"),x[1]&&(P<x.length-1||J.loop)&&(Q.style.cursor="pointer",Q.onclick=function(){U.next()}),m&&(Q.style.msInterpolationMode="bicubic"),setTimeout(function(){g(Q)},1)}),setTimeout(function(){Q.src=c},1)):c&&A.load(c,function(b,c,d){g(c==="error"?W("Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},U.next=function(){!S&&x[1]&&(P<x.length-1||J.loop)&&(P=P<x.length-1?P+1:0,U.load())},U.prev=function(){!S&&x[1]&&(P||J.loop)&&(P=P?P-1:x.length-1,U.load())},U.close=function(){R&&!T&&(T=!0,R=!1,$(j,J.onCleanup),y.unbind("."+f+" ."+o),p.fadeTo(200,0),q.stop().fadeTo(300,0,function(){q.add(p).css({opacity:1,cursor:"auto"}).hide(),$(l),z.remove(),setTimeout(function(){T=!1,$(k,J.onClosed)},1)}))},U.element=function(){return a(O)},U.settings=d,a(U.init)})(jQuery,document,this);
 

/**
 * jQuery-Plugin "preloadCssImages"
 * by Scott Jehl, scott@filamentgroup.com
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/
 * demo page: http://www.filamentgroup.com/examples/preloadImages/index_v2.php
 * 
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Version: 5.0, 10.31.2008
 * Changelog:
 * 	02.20.2008 initial Version 1.0
 *    06.04.2008 Version 2.0 : removed need for any passed arguments. Images load from any and all directories.
 *    06.21.2008 Version 3.0 : Added options for loading status. Fixed IE abs image path bug (thanks Sam Pohlenz).
 *    07.24.2008 Version 4.0 : Added support for @imported CSS (credit: http://marcarea.com/). Fixed support in Opera as well. 
 *    10.31.2008 Version: 5.0 : Many feature and performance enhancements from trixta
 * --------------------------------------------------------------------
 */

;jQuery.preloadCssImages = function(settings){
	settings = jQuery.extend({
		statusTextEl: null,
		statusBarEl: null,
		errorDelay: 999, // handles 404-Errors in IE
		simultaneousCacheLoading: 2
	}, settings);
	var allImgs = [],
		loaded = 0,
		imgUrls = [],
		thisSheetRules,	
		errorTimer;
	
	function onImgComplete(){
		clearTimeout(errorTimer);
		if (imgUrls && imgUrls.length && imgUrls[loaded]) {
			loaded++;
			if (settings.statusTextEl) {
				var nowloading = (imgUrls[loaded]) ? 
					'Now Loading: <span>' + imgUrls[loaded].split('/')[imgUrls[loaded].split('/').length - 1] : 
					'Loading complete'; // wrong status-text bug fixed
				jQuery(settings.statusTextEl).html('<span class="numLoaded">' + loaded + '</span> of <span class="numTotal">' + imgUrls.length + '</span> loaded (<span class="percentLoaded">' + (loaded / imgUrls.length * 100).toFixed(0) + '%</span>) <span class="currentImg">' + nowloading + '</span></span>');
			}
			if (settings.statusBarEl) {
				var barWidth = jQuery(settings.statusBarEl).width();
				jQuery(settings.statusBarEl).css('background-position', -(barWidth - (barWidth * loaded / imgUrls.length).toFixed(0)) + 'px 50%');
			}
			loadImgs();
		}
	}
	
	function loadImgs(){
		//only load 1 image at the same time / most browsers can only handle 2 http requests, 1 should remain for user-interaction (Ajax, other images, normal page requests...)
		// otherwise set simultaneousCacheLoading to a higher number for simultaneous downloads
		if(imgUrls && imgUrls.length && imgUrls[loaded]){
			var img = new Image(); //new img obj
			img.src = imgUrls[loaded];	//set src either absolute or rel to css dir
			if(!img.complete){
				jQuery(img).bind('error load onreadystatechange', onImgComplete);
			} else {
				onImgComplete();
			}
			errorTimer = setTimeout(onImgComplete, settings.errorDelay); // handles 404-Errors in IE
		}
	}
	
	function parseCSS(sheets, urls) {
		var w3cImport = false,
			imported = [],
			importedSrc = [],
			baseURL;
		var sheetIndex = sheets.length;
		while(sheetIndex--){//loop through each stylesheet
			
			var cssPile = '';//create large string of all css rules in sheet
			
			if(urls && urls[sheetIndex]){
				baseURL = urls[sheetIndex];
			} else {
				var csshref = (sheets[sheetIndex].href) ? sheets[sheetIndex].href : 'window.location.href';
				var baseURLarr = csshref.split('/');//split href at / to make array
				baseURLarr.pop();//remove file path from baseURL array
				baseURL = baseURLarr.join('/');//create base url for the images in this sheet (css file's dir)
				if (baseURL) {
					baseURL += '/'; //tack on a / if needed
				}
			}
			if(sheets[sheetIndex].cssRules || sheets[sheetIndex].rules){
				thisSheetRules = (sheets[sheetIndex].cssRules) ? //->>> http://www.quirksmode.org/dom/w3c_css.html
					sheets[sheetIndex].cssRules : //w3
					sheets[sheetIndex].rules; //ie 
				var ruleIndex = thisSheetRules.length;
				while(ruleIndex--){
					if(thisSheetRules[ruleIndex].style && thisSheetRules[ruleIndex].style.cssText){
						var text = thisSheetRules[ruleIndex].style.cssText;
						if(text.toLowerCase().indexOf('url') != -1){ // only add rules to the string if you can assume, to find an image, speed improvement
							cssPile += text; // thisSheetRules[ruleIndex].style.cssText instead of thisSheetRules[ruleIndex].cssText is a huge speed improvement
						}
					} else if(thisSheetRules[ruleIndex].styleSheet) {
						imported.push(thisSheetRules[ruleIndex].styleSheet);
						w3cImport = true;
					}
					
				}
			}
			//parse cssPile for image urls
			var tmpImage = cssPile.match(/[^\("]+\.(gif|jpg|jpeg|png)/g);//reg ex to get a string of between a "(" and a ".filename" / '"' for opera-bugfix
			if(tmpImage){
				var i = tmpImage.length;
				while(i--){ // handle baseUrl here for multiple stylesheets in different folders bug
					var imgSrc = (tmpImage[i].charAt(0) == '/' || tmpImage[i].match('://')) ? // protocol-bug fixed
						tmpImage[i] : 
						baseURL + tmpImage[i];
					
					if(jQuery.inArray(imgSrc, imgUrls) == -1){
						imgUrls.push(imgSrc);
					}
				}
			}
			
			if(!w3cImport && sheets[sheetIndex].imports && sheets[sheetIndex].imports.length) {
				for(var iImport = 0, importLen = sheets[sheetIndex].imports.length; iImport < importLen; iImport++){
					var iHref = sheets[sheetIndex].imports[iImport].href;
					iHref = iHref.split('/');
					iHref.pop();
					iHref = iHref.join('/');
					if (iHref) {
						iHref += '/'; //tack on a / if needed
					}
					var iSrc = (iHref.charAt(0) == '/' || iHref.match('://')) ? // protocol-bug fixed
						iHref : 
						baseURL + iHref;
					
					importedSrc.push(iSrc);
					imported.push(sheets[sheetIndex].imports[iImport]);
				}
				
				
			}
		}//loop
		if(imported.length){
			parseCSS(imported, importedSrc);
			return false;
		}
		var downloads = settings.simultaneousCacheLoading;
		while( downloads--){
			setTimeout(loadImgs, downloads);
		}
	}
	parseCSS(document.styleSheets);
	return imgUrls;
};

/*
 * jQuery.ImageSwitch
 * Version: 1.1.0
 * http://www.hieu.co.uk/ImageSwitch/
 *
 * Copyright (c) 2009 Hieu Pham - http://www.hieu.co.uk
 * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
 * http://www.opensource.org/licenses/cddl1.php
 *
 * Date: 24/01/2011
 * Revision: 50
 */
 //This function to preload the image before using it in the function
 var Debug = function(mess, line){
	if(!$("#Debug"))
	{
		$("body").append("<div id='Debug'></div>");
	}
	if(line){
		$("#Debug").html($("#Debug").html()+"<br/>"+mess);
	}
	else{
		$("#Debug").html($("#Debug").html()+mess);
	}
};
var max_ImageSwitch_Effect_ID = 0;

(function($) {
    $.fn.ImageSwitch = function(Arguements, FuntionHandle) {
        var defaults = {
            Type: "FadeIn", // Type of effect to run the function
            NewImage: "", //The new image will be loaded in
            EffectOriginal: true,
            Speed: 1000, //Speed of the effect
            StartLeft: 50, //The position the effect start compare to the original position could be (-)
            StartTop: 0,
            StartOpacity: 0, //Which start opacity it would be
            EndLeft: -50, //The position the effect end compare to the original position could be (-)
            EndTop: 0,
            EndOpacity: 0, //Which start opacity it would be
            Direction: "RightLeft", //Which Way the image will be sroll
            Door1: "", //The image for the door 1
            Door2: "" //The image for the door 2
        };

        var Args = $.extend(defaults, Arguements);
        var Obj = this; // Just a way to reference to this obj in case we need to pass in another event handle
        //To specific which obj ID the effect will associate to
        var EffectID = 0;

        var EffectImageId; //The id of effect image layer : #GrpEffectImg + EffectID
        var EffectDivId1; //The id of effect div layer : #GrpEffectDiv2 + EffectID
        var EffectDivId2; //The id of effect div layer : #GrpEffectDiv2 + EffectID

        var EndFunction = function() {
            Obj.data("imageswitch", -1);
        };
        if ($.isFunction(FuntionHandle)) {
            EndFunction = function() {
                FuntionHandle();
                Obj.data(Obj, -1);
            };
        }
        //-----------------------------------------------------------------------------------------------------------
        //The original image will be fade out when the new image will fade in
        var FadeImage = function() {
            //Generate the effect map, move the effect map overlay the original map
            Obj.parent().append("<img class='GrpEffectImg' id='" + EffectImageId.replace("#", "") + "'/>");
            $(EffectImageId).attr("src", Obj.attr("src"));
            $(EffectImageId).css("position", "absolute");
            $(EffectImageId).css("top", Obj.position().top);
            $(EffectImageId).css("left", Obj.position().left);
            $(EffectImageId).css("opacity", 1);

            //Change image of the original map
            Obj.attr("src", Args.NewImage);

            //Need something special when user want to keep no effect for the orignal
            if (Args.EffectOriginal) {
                //Set the start opacity, as the effect will fade out we set in start at 1, vice versa for the original
                Obj.css("opacity", Args.StartOpacity);

                //Fade in the original image
                Obj.animate({ "opacity": 1 }, Args.Speed);
            }

            //Start effect animation
            $(EffectImageId).animate({ "opacity": 0 }, Args.Speed, function() {
                //Remove the effect image when finish the effect
                $(EffectImageId).remove();
                EndFunction();
            });
        };
        //-----------------------------------------------------------------------------------------------------------
        //The new image will fly from the startPosition with the StartOpacity

        var Fly = function(FlyIn) {
            //Generate the effect map, move the effect map overlay the original map
            $("body").append("<img class='GrpEffectImg' id='" + EffectImageId.replace("#", "") + "'/>");
            $(EffectImageId).css("position", "absolute");
            if (FlyIn) {
                //As the new image will fly in, so we set the effect image src = new image
                $(EffectImageId).attr("src", Args.NewImage);
                $(EffectImageId).css("top", Obj.offset().top + Args.StartTop);
                $(EffectImageId).css("left", Obj.offset().left + Args.StartLeft);
                $(EffectImageId).css("opacity", Args.StartOpacity);
                EndTop = Obj.offset().top;
                EndLeft = Obj.offset().left;
                //Change the opacity base on the input				
                EndOpacity = 1;
            } else {
                //As the old image will fly out, so we set the effect image src = new image
                //The effect image will be on top of the old image and hide the old image
                //So we could set the old image with the new src
                $(EffectImageId).attr("src", Obj.attr("src"));
                Obj.attr("src", Args.NewImage);
                $(EffectImageId).css("top", Obj.offset().top);
                $(EffectImageId).css("left", Obj.offset().left);
                $(EffectImageId).css("opacity", 1);
                EndTop = Obj.offset().top + Args.EndTop;
                EndLeft = Obj.offset().left + Args.EndLeft;
                //Change the opacity base on the input				
                EndOpacity = Args.EndOpacity;
            }
            //Let the effect start fly in
            $(EffectImageId).animate({ "opacity": EndOpacity, "top": EndTop,
                "left": EndLeft
            }, Args.Speed,
				function() {
				    Obj.attr("src", Args.NewImage);
				    $(EffectImageId).remove();
				    EndFunction();
				});
        };
        //-----------------------------------------------------------------------------------------------------------
        //The new image will scoll in and kick the old image out.
        //With the setting ScollIn = false, The original image will scroll out and reveal the new image
        var Scroll = function(ScrollIn) {
            //Save the original status so we could set it in the end
            var backup = Obj.clone(true);
            //Create a viewport for it
            Obj.wrap("<div id='GrpViewport-" + EffectID + "'></div>");
            $("#GrpViewport-" + EffectID).css("overflow", "hidden");
            $("#GrpViewport-" + EffectID).width(Obj.width());
            $("#GrpViewport-" + EffectID).height(Obj.height());
            //Generate the effect map, move the effect map overlay the original map				
            $("#GrpViewport-" + EffectID).append("<img class='GrpEffectImg' id='" + EffectImageId.replace("#", "") + "'/>");
            $(EffectImageId).css("position", "absolute");
            //Find where the Effect Image start
            var StartTop = 0;
            var StartLeft = 0;
            switch (Args.Direction) {
                case "RightLeft": StartLeft = -Obj.width(); break;
                case "LeftRight": StartLeft = Obj.width(); break;
                case "TopDown": StartTop = -Obj.height(); break;
                case "DownTop": StartTop = Obj.height(); break;
            }
            //In scroll in using the Start position, else, Set it to 0 so it could scroll out
            //Also need o set the destination of the animate different
            if (ScrollIn) {
                $(EffectImageId).attr("src", Args.NewImage);
                $(EffectImageId).css("top", StartTop);
                $(EffectImageId).css("left", StartLeft);
                $(EffectImageId).css("opacity", Args.StartOpacity);
                EndTop = 0;
                EndLeft = 0;
                //Don't change the opacity if it scroll in
                EndOpacity = 1;
            } else {
                $(EffectImageId).attr("src", Obj.attr("src"));
                $(EffectImageId).css("left", 0);
                $(EffectImageId).css("top", 0);
                Obj.attr("src", Args.NewImage);
                EndTop = StartTop;
                EndLeft = StartLeft;
                //Change the opacity base on the input				
                EndOpacity = Args.EndOpacity;
            }
            //We need to treat absolute position different					
            //In some case there're text arround the image, it could be a bit mess up
            if (Obj.css("position") != "absolute") {
                $("#GrpViewport-" + EffectID).css("position", "relative");
                Obj.css("position", "absolute");
            }
            else {
                $("#GrpViewport-" + EffectID).css("position", "absolute");
                $("#GrpViewport-" + EffectID).css("left", Obj.css("left"));
                $("#GrpViewport-" + EffectID).css("top", Obj.css("top"));
                Obj.css("top", 0);
                Obj.css("left", 0);
            }
            //if effect the original image, then move it as well
            if (Args.EffectOriginal && ScrollIn) {
                //Move the original image along
                Obj.animate({ "top": -StartTop,
                    "left": -StartLeft
                }, Args.Speed);
            }
            //Start the effect
            $(EffectImageId).animate({ "opacity": EndOpacity, "top": EndTop, "left": EndLeft }, Args.Speed,
					function() {
					    //Finish the effect, and replace the viewport with this area
					    backup.attr("src", Args.NewImage);
					    //Also remove the Attr for imageswitch
					    backup.removeAttr("imageswitch");
					    $("#GrpViewport-" + EffectID).replaceWith(backup);
					    EndFunction();
					});
        };
        //-----------------------------------------------------------------------------------------------------------
        //A door come out create an effect door close.then open the new image
        var SingleDoor = function() {
            //Save the original status so we could set it in the end
            var backup = Obj.clone(true);
            //Create a viewport for it
            Obj.wrap("<div id='GrpViewport'></div>");
            $("#GrpViewport").css("overflow", "hidden");
            $("#GrpViewport").width(Obj.width());
            $("#GrpViewport").height(Obj.height());
            //Generate the effect map, move the effect map overlay the original map				
            $("#GrpViewport").append("<div class='GrpEffectDiv' id='" + EffectDivId1.replace("#", "") + "'/>");
            $(EffectDivId1).attr("src", Args.NewImage);
            $(EffectDivId1).css("position", "absolute");
            $(EffectDivId1).css("background-color", "#FFF");
            if (Args.Door1.length > 0) {
                $(EffectDivId1).css("background", Args.Door1);
            }
            $(EffectDivId1).width(Obj.width());
            $(EffectDivId1).height(Obj.height());
            //Find where the Effect Image start
            var StartTop = 0;
            var StartLeft = 0;
            switch (Args.Direction) {
                case "RightLeft": StartLeft = -Obj.width(); break;
                case "LeftRight": StartLeft = Obj.width(); break;
                case "TopDown": StartTop = -Obj.height(); break;
                case "DownTop": StartTop = Obj.height(); break;
            }
            $(EffectDivId1).css("top", StartTop);
            $(EffectDivId1).css("left", StartLeft);

            //We need to treat absolute position different	
            if (Obj.css("position") != "absolute") {
                $("#GrpViewport").css("position", "relative");
                Obj.css("position", "absolute");
            }
            else {
                $("#GrpViewport").css("position", "absolute");
                $("#GrpViewport").css("left", Obj.css("left"));
                $("#GrpViewport").css("top", Obj.css("top"));
                Obj.css("top", 0);
                Obj.css("left", 0);
            }
            //Start Close the Door
            $(EffectDivId1).animate({ "top": 0, "left": 0 }, Args.Speed, function() {
                //Finish the first effect change the image and open the door
                Obj.attr("src", Args.NewImage);
                //Start open the door
                $(EffectDivId1).animate({ "top": StartTop, "left": StartLeft }, Args.Speed, function() {
                    //Reset style
                    backup.attr("src", Args.NewImage);
                    //Also remove the Attr for imageswitch
                    backup.removeAttr("imageswitch");
                    $("#GrpViewport").replaceWith(backup);
                    EndFunction();
                });
            });
        };
        //-----------------------------------------------------------------------------------------------------------
        //Same with single door but with this effect, there will be 2 door
        var DoubleDoor = function() {
            //Save the original status so we could set it in the end
            var orgPosition = Obj.css("position");
            var orgLeft = Obj.css("left");
            var orgTop = Obj.css("top");
            //Create a viewport for it
            Obj.wrap("<div id='GrpViewport'></div>");
            $("#GrpViewport").css("overflow", "hidden");
            $("#GrpViewport").width(Obj.width());
            $("#GrpViewport").height(Obj.height());
            //Generate the effect map, move the effect map overlay the original map				
            $("#GrpViewport").append("<div class='GrpEffectDiv' id='" + EffectDivId1.replace("#", "") + "'/>");
            $(EffectDivId1).css("position", "absolute");
            $(EffectDivId1).css("background-color", "#FFF");
            if (Args.Door1.length > 0) {
                $(EffectDivId1).css("background", Args.Door1);
            }
            $(EffectDivId1).width(Obj.width());
            $(EffectDivId1).height(Obj.height());
            //We need the second door
            $("#GrpViewport").append("<div class='GrpEffectDiv1' id='" + EffectDivId2.replace("#", "") + "'/>");
            $(EffectDivId2).css("position", "absolute");
            $(EffectDivId2).css("background-color", "#FFF");
            if (Args.Door2.length > 0) {
                $(EffectDivId2).css("background", Args.Door2);
            }
            $(EffectDivId2).width(Obj.width());
            $(EffectDivId2).height(Obj.height());

            //Find where the Effect Image start
            var StartTop = 0;
            var StartLeft = 0;
            switch (Args.Direction) {
                case "RightLeft": StartLeft = -Obj.width(); break;
                case "LeftRight": StartLeft = Obj.width(); break;
                case "TopDown": StartTop = -Obj.height(); break;
                case "DownTop": StartTop = Obj.height(); break;
            }
            $(EffectDivId1).css("top", StartTop);
            $(EffectDivId1).css("left", StartLeft);
            $(EffectDivId2).css("top", -StartTop);
            $(EffectDivId2).css("left", -StartLeft);

            //set the background for the door effect so it look different
            if (!Args.EffectOriginal) {
                $(EffectDivId1).css("background", "#FFF url(" + Args.NewImage + ") no-repeat " + -StartLeft / 2 + "px " + -StartTop / 2 + "px");
                $(EffectDivId2).css("background", "#FFF url(" + Args.NewImage + ") no-repeat " + StartLeft / 2 + "px " + StartTop / 2 + "px");
            }

            //We need to treat absolute position different					
            if (Obj.css("position") != "absolute") {
                $("#GrpViewport").css("position", "relative");
                Obj.css("position", "absolute");
            }
            else {
                $("#GrpViewport").css("position", "absolute");
                $("#GrpViewport").css("left", orgLeft);
                $("#GrpViewport").css("top", orgTop);
                Obj.css("position", "absolute");
                Obj.css("top", 0);
                Obj.css("left", 0);
            }
            //Start Close the Door
            $(EffectDivId1).animate({ "top": StartTop / 2, "left": StartLeft / 2 }, Args.Speed, function() {
                //Finish the first effect change the image and open the door
                Obj.attr("src", Args.NewImage);
                //If EffectOriginal isn't on mean two door stick into the new image, then stop here. Else carry on
                if (!Args.EffectOriginal) {
                    Obj.css("position", orgPosition);
                    Obj.css("top", orgTop);
                    Obj.css("left", orgLeft);
                    $("#GrpViewport").replaceWith(Obj);
                } else {
                    //Start open the door
                    $(EffectDivId1).animate({ "top": StartTop, "left": StartLeft }, Args.Speed, function() {
                        //Reset style
                        Obj.css("position", orgPosition);
                        Obj.css("top", orgTop);
                        Obj.css("left", orgLeft);
                        $("#GrpViewport").replaceWith(Obj);
                    });
                }
            });
            $(EffectDivId2).animate({ "top": -StartTop / 2, "left": -StartLeft / 2 }, Args.Speed, function() {
                //Finish the first effect change the image and open the door
                Obj.attr("src", Args.NewImage);
                //If EffectOriginal isn't on mean two door stick into the new image, then stop here. Else carry on
                if (!Args.EffectOriginal) {
                    EndFunction();
                } else {
                    //Start open the door
                    $(EffectDivId2).animate({ "top": -StartTop, "left": -StartLeft }, Args.Speed, function() {
                        //Run the end effect
                        EndFunction();
                    });
                }
            });
        };
        //-----------------------------------------------------------------------------------------------------------
        //The new image will flip from the back of the old one to the top
        //If FlipIn is false, then the old image will flip to the back reveal the new one
        var Flip = function(FlipIn) {
            var backup = Obj.clone(true);
            if (Obj.css("z-index") == 'auto') {
                Obj.css("z-index", 100);
            }
            //if (position different then absolute and relative then it should be relative)
            if (Obj.css("position") != "absolute") {
                Obj.css("position", "relative");
            }
            //Generate the effect map, move the effect map overlay the original map
            $("body").append("<img class='GrpEffectImg'  id='" + EffectImageId.replace("#", "") + "'/>");
            $(EffectImageId).css("position", "absolute");
            $(EffectImageId).css("top", Obj.offset().top);
            $(EffectImageId).css("left", Obj.offset().left);

            if (FlipIn) {
                $(EffectImageId).css("opacity", Args.StartOpacity);
                //So this layer will be under the original image
                $(EffectImageId).css("z-index", Obj.css("z-index") - 1);
                $(EffectImageId).attr("src", Args.NewImage);
            } else {
                $(EffectImageId).css("opacity", 1);
                //This layer will be on top the original image
                $(EffectImageId).css("z-index", Obj.css("z-index") + 1);
                //Turn in to the fake old image
                $(EffectImageId).attr("src", Obj.attr("src"));
                Obj.attr("src", Args.NewImage);

            }

            //Find where the effect layer stop
            if (Math.abs(Args.EndTop) < Obj.height() && Math.abs(Args.EndLeft) < Obj.width()) {
                EndTop = Obj.offset().top;
                EndLeft = Obj.offset().left + Obj.width();
            } else {
                EndTop = Obj.offset().top + Args.EndTop;
                EndLeft = Obj.offset().left + Args.EndLeft;
            }
            EndOpacity = 1;

            //Let the effect start, 
            $(EffectImageId).animate({ "opacity": EndOpacity, "top": EndTop,
                "left": EndLeft
            }, Args.Speed,
				function() {
				    //Now the effect image is out, move it back again
				    if (FlipIn) {
				        $(EffectImageId).css("z-index", 101);
				    } else {
				        EndOpacity = Args.EndOpacity;
				        $(EffectImageId).css("z-index", 2);
				    }
				    $(EffectImageId).animate({ "opacity": EndOpacity, "top": Obj.offset().top,
				        "left": Obj.offset().left
				    }, Args.Speed,
						function() {
						    //Restore the image to the original
						    backup.attr("src", Args.NewImage);
						    //Also remove the Attr for imageswitch
						    backup.removeAttr("imageswitch");
						    Obj.replaceWith(backup);
						    $(EffectImageId).remove();
						    EndFunction();
						});
				});
        };

        return this.each(function() {
            Obj = $(this);
            if (!Obj.ImageAnimating()) {

                EffectID = max_ImageSwitch_Effect_ID;
                max_ImageSwitch_Effect_ID += 1;

                //Mark the effect is running				
                Obj.data(Obj, EffectID);
                EffectImageId = "#GrpEffectImg-" + EffectID; //The id of effect image layer : #GrpEffectImg- + EffectID
                EffectDivId1 = "#GrpEffectDiv1-" + EffectID; //The id of effect div layer : #GrpEffectDiv1- + EffectID
                EffectDivId2 = "#GrpEffectDiv2-" + EffectID; //The id of effect div layer : #GrpEffectDiv2- + EffectID

                var TempImg = new Image();
                TempImg.src = Args.NewImage;
                $.ImagePreload(Args.NewImage, function() {
                    switch (Args.Type) {
                        case "FadeIn": FadeImage(); break;
                        case "FlyIn": Fly(true); break;
                        case "FlyOut": Fly(false); break;
                        case "FlipIn": Flip(true); break;
                        case "FlipOut": Flip(false); break;
                        case "ScrollIn": Scroll(true); break;
                        case "ScrollOut": Scroll(false); break;
                        case "SingleDoor": SingleDoor(); break;
                        case "DoubleDoor": DoubleDoor(); break;
                    }
                });
            }
        });
    };
})(jQuery);

//Check if a IS effect is running
(function($){
	$.fn.ImageAnimating = function(){
		if(this.data("imageswitch")>0){
			return true;
		}else{
			return false;
		}
	};
})(jQuery);
//Stop a specific the IS effect if it's running
(function($){
	$.fn.ImageStop = function(clearQueue, gotoEnd, EndFunction){
		return this.each(function(){
			if($(this).ImageAnimating()){
				var EffectID = $.data(this,"imageswitch");
				$("#GrpEffectImg-"+EffectID).stop(clearQueue, gotoEnd);
				$("#GrpEffectDiv-"+EffectID).stop(clearQueue, gotoEnd);
				$("#GrpEffectDiv1-"+EffectID).stop(clearQueue, gotoEnd);
				$(this).stop(clearQueue, gotoEnd);
				$("#GrpEffectImg-"+EffectID).remove();
				$("#GrpEffectDiv-"+EffectID).remove();
				$("#GrpEffectDiv1-"+EffectID).remove();
				if($.isFunction(EndFunction)){
					EndFunction();
				}
			}
		});
	};
})(jQuery);
//Stop all the IS effect running
(function($){
	$.ImageStopAll = function(clearQueue, gotoEnd, EndFunction){
		$(".GrpEffectImg").stop(clearQueue, gotoEnd);
		$(".GrpEffectDiv").stop(clearQueue, gotoEnd);
		$(".GrpEffectDiv1").stop(clearQueue, gotoEnd);
		$(this).stop(clearQueue, gotoEnd);
		$(".GrpEffectImg").remove();
		$(".GrpEffectDiv").remove();
		$(".GrpEffectDiv1").remove();
		$.data(this, "imageswitch", -1);
		if($.isFunction(EndFunction)){
			EndFunction();
		}
	};
})(jQuery);
//Preload a specific image
(function($){
	$.ImagePreload = function(FileName, EndFunction){
		var TempImage = new Image();
		TempImage.src = FileName;
		if($.isFunction(EndFunction)){
			$(TempImage).load(EndFunction());
		}
	};
})(jQuery);

// IE font-face ClearType fix - V0.1
// Authord by Michael Strand of Allcreatives.net
// Usage, changes, FAQ etc. see - http://allcreatives.net/2009/12/05/jquery-plugin-ie-font-face-cleartype-fix/
// The IE font-face ClearType fix plugin is dual licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) and 
// [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses.

// There is one configuration setting to be changed below if you have the PNG image in different location from this file.

(function($) {
    $.fn.ieffembedfix = function() {
		
		// CONFIGURE THE PATH TO YOUR 1BY1 PNG HERE, RELATIVE TO THE LOCATION OF THIS JS FILE.
		
		var pngimgurl = "hIEfix.png";
		
		//alert('fix ie');
		
    return this.each(function() {
        //check for IE7/8
        if ($.browser.msie) {
          if ($.browser.version < 9) {
					  //alert('fix ie');
						$(this).css({
						
							filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + pngimgurl + '",sizingMethod=crop',
							zoom: '1'
						});
					}
        }
        });
    }
})(jQuery);


