// 		console.log("test");
jQuery.noConflict();

/*
    Carousel
*/
 
//var player;
//function playerReady(obj) {
//	alert('the videoplayer '+obj['id']+' has been instantiated');
//	player = document.getElementById(obj['id']);
//	var len =player.getPlaylist().length;
//	arr=player.getPlaylist();
	//var jList=$("ul.mycarousel")
//	var z = 0;
//	var title;
//	jQuery.each(arr, function()  {
//	title=this.title;
//	//jList.append("<li><img src='http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg' id='0' width='50' height='50'  alt='' /></li>");
//	alert(title);
//	if (z == len - 1){
//	    lNum="{url: \"http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg\"}";
//      }else
//      {
//        	lNum="{url: \"http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg\"},";
//      }
//      z++;
//      //$("#" + this).text("My id is " + this + ".");
     // return (this != "four"); // will stop running to skip "five"
     
  //  }); 
  //  alert(lNum);
    //populate();
	
//Creating video

	function createRotate(container, w, ht) {
    var flashvars = {
        skin: "modieus.swf",
        file: "rotate/playlist.xml",
        playlist: "bottom"
    }
    var params = {
        base: ".",
        bgcolor: "#ffffff",
        allowfullscreen: "true"
    }
    var attributes = {}
    swfobject.embedSWF("rotate/new-System590x300.swf", "" + container + "", "" + w + "", "" + ht + "", "9.0.0", false, flashvars, params, attributes);
}


createVideo("videoSol", 360, 264, "homecod.xml");

	function createVideo(el, w, ht, theFile) {

    var flashvars = {
               file: "media/"+theFile,
               //autostart: "false",
               //playlistsize: "100",
               //playlist: "top",
               lightcolor: "ffffff",
               stretching:"fill",
               controlbar:"over",
              frontcolor: "ffffff",
               skin:"media/modieus.swf"
           }
           var params = {
               wmode: "opaque",
               allowfullscreen: "false",
               allowscriptaccess: "always"
           }
           var attributes = {
               id: ""+el+"",
               name: ""+el+""
           }
           
           swfobject.embedSWF("media/player.swf", ""+el+"", ""+w+"", ""+ht+"", "9.0.115", false, flashvars, params, attributes);
	}


    function changeVid(index)
{
        var player = document.getElementById("videoFeature");
        player.sendEvent("ITEM", index);
} 

if (jQuery("#videoSol").length>0) {
createVideo("videoSol", 600, 400, "homecod.xml");

}
//};

//var mycarousel_itemList = [

//    {url: "http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg", title: "Flower1"},
//    {url: "http://static.flickr.com/75/199481072_b4a0d09597_s.jpg", title: "Flower2"},
//    {url: "http://static.flickr.com/57/199481087_33ae73a8de_s.jpg", title: "Flower3"},
//    {url: "http://static.flickr.com/77/199481108_4359e6b971_s.jpg", title: "Flower4"},
//    {url: "http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg",  title: "Flower5"},
//    {url: "http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg", title: "Flower6"},
//    {url: "http://static.flickr.com/58/199481218_264ce20da0_s.jpg", title: "Flower7"},
//    {url: "http://static.flickr.com/69/199481255_fdfe885f87_s.jpg", title: "Flower8"},
//    {url: "http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg", title: "Flower9"},
//   {url: "http://static.flickr.com/70/229228324_08223b70fa_s.jpg"},lNum
//];

jQuery(document).ready(function() {
    var enable_scrolling = jQuery("meta[name=Javazineoption1]").attr('content');
    var enable_tooltips = jQuery("meta[name=Javazineoption2]").attr('content');
    var enable_tabs = jQuery("meta[name=Javazineoption3]").attr('content');
    var enable_footer = jQuery("meta[name=Javazineoption4]").attr('content');
    //Coda
    if (jQuery("#coda-slider-1").length > 0) {
        jQuery('.cpanel').html('<p><img src="../images/loading.gif" alt="loading..." /></p>');

        jQuery('#coda-slider-1').codaSlider({
            dynamicArrows: false,
            dynamicTabs: false,
            autoHeight: false
        });
        jQuery('#coda-slider-1').slideDown('slow');
        jQuery('#panela').load("homecoda.html").slideDown();
        jQuery('#panelb').load("upcomingcoda.html");
		/*Fancy Box*/
	// jQuery("a.light").fancybox({'hideOnContentClick': true}); 
	
    
    }
	
	//Checking if the mapcontainer exist
    if (jQuery("#map").length > 0) {
        var mymap = new MeOnTheMap({
            container: "map",
            html: "NEC Youth Ministries<img src=\"../images/ypac_logo.gif\"/><br/>Ph:(718) 291 8006.",
            address: "115-50 Merrick Blvd Queens, NY 11434",
            zoomLevel: 16
        });

        mymap.adjustMapCenter({
            x: 0,
            y: -80
        });
    }
    
	    
    jQuery("#0").click(
function(e) {
    // make the imagerotator jump to the next image.
    player.sendEvent('ITEM', '0');
    //var title= player.getPlaylist().length();

});

    jQuery("#previous").click(
function(e) {
    // make the imagerotator jump to the next image.
    document.getElementById('r2').sendEvent('prev');
    e.preventDefault();
});
    jQuery("#next").click(
function(e) {
    // make the imagerotator jump to the next image.
    document.getElementById('r2').sendEvent('next');
    e.preventDefault();
});

    //	if (enable_footer == 1){slidePanel();}
    //	searchpanel();
    //	mainmenu();
    //	if (enable_tooltips == 1){
    //	simple_tooltip("a","tooltip");
    //	tooltip('a', 'tooltip2');
    //	tooltip2('a', 'tooltip', 'title');

    //	
    //	}
    //noscript();
    //	if (enable_scrolling == 1){scroller(".infowrap", ".infowrap ul", ".teaser_infobox");}
    //	if (enable_tabs == 1){tab('.widget_block','.widgettitle','.widget');}
    //   $("#jDrawer-1").jDrawer({ event: "click" });
    //$("#jDrawer-2").jDrawer({ speed: 500, sticky: false });
    ////        $("#jDrawer-3").jDrawer({ direction: "left", sticky: false });
    //        $("#jDrawer-4").jDrawer({ direction: "left", event: "click" });
    //        $("#jDrawer-5").jDrawer();
    //          $("#jDrawer-6").jDrawer({ callback: function() { alert("hover"); } });

    //if (jQuery("#song").length>0) {
        var flashvars = {
            autostart: "false",
            icons: "false",
            playlistsize: "100",
            playlistsize: "100",
            stretching: "fill",
            playlist: "top",
            file: "../media/playlist.xml",
            lightcolor: "74A45A",
            duration: "33",
            backcolor: "FCFCFC",
            frontcolor: "013565",
            screencolor: "ffffff",
            skin: "../media/bekle.swf",
            displayheight: "30",
            volume: "50",
            controlbar: "bottom"
        }
        var params = {
            wmode: "transparent",
            allowfullscreen: "false",
            allowscriptaccess: "always",
            menu: "0"
        }
        var attributes = "";
        swfobject.embedSWF("/media/player.swf", "song", "230", "80", "9.0.115", false, flashvars, params, attributes);
   // }
    jQuery(".stripe tr").mouseover(function() { jQuery(this).addClass("over"); }).mouseout(function() { jQuery(this).removeClass("over"); });
    jQuery(".stripe tr:even").addClass("alt");

    k_fader(".preview_images a", ".featured_item"); // this is the mainpages fading script-> when a image is clicked a fadeout followed by a fade in occurs
    k_pointer(); // this script manages the pointer below the preview pics
    k_autoslide(".preview_images a", 14000); // this script starts the automatic slideshow, number represents the time between the transition in milliseconds
    k_newsticker(".ticker span", 10000); // starts the newsticker, number defines the time between transitions in milliseconds
    k_next_slide(".preview_images a", ".featured_item", ".show-next"); // shows the next slide
    nec_improvements(); // adds some improvements to the site
    // The flash videos
 /*   swfobject.embedSWF("http://necyouthministries.org/media/adShow.swf", "ads", "220", "400", "9.0.0", "expressInstall.swf", { paramXMLPath: "../media/param.xml",xmlFilePath:"http://yovinc.com/galleries/necyouth/images.php?gallery=4",initialURL: escape(document.location) }, { menu: 'false', allowscriptaccess: "always", wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact' });
	//Sidebar Ads 2
	 swfobject.embedSWF("../media/adShow.swf", "ads2", "220", "220", "9.0.0", "expressInstall.swf", { paramXMLPath: "../media/param.xml",xmlFilePath:"http://yovinc.com/galleries/necyouth/images.php?gallery=7",initialURL: escape(document.location) }, { menu: 'false', allowscriptaccess: "always", wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact' });
	*/
	 swfobject.embedSWF("../media/adShow.swf", "galc", "640", "480", "9.0.0", "expressInstall.swf", { paramXMLPath: "../media/param.xml",xmlFilePath:"http://yovinc.com/galleries/necyouth/images.php?gallery=3",initialURL: escape(document.location) }, { menu: 'false', allowscriptaccess: "always", wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact' });	
	  /*swfobject.embedSWF("viewer.swf", "galc", "640", "480", "9.0.0", "expressInstall.swf", { filePath: "http://yovinc.com/galleries/necyouth/images.php?gallery=3" }, { menu: 'false', wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact', allowFullScreen:'true' });*/
	  createGallery("ads",220,400,"http://yovinc.com/galleries/necyouth/images.php?album=5");
	  createGallery("ads2",220,220,"http://yovinc.com/galleries/necyouth/images.php?album=13");
	  createGallery("topad",920,90,"http://yovinc.com/galleries/necyouth/images.php?album=14");
	 function createGallery(gal,w,h,f) {
	var flashvars = {
	    paramXMLPath: "http://www.necyouthministries.org/media/param.xml",
		xmlFilePath:f,
		initialURL: escape(document.location)
	}
	var params = {}
	params.allowscriptaccess = "always";
	params.allownetworking = "all";
	params.wmode = "transparent";
	params.menu = "false";          
	var attributes = {}
	swfobject.embedSWF("http://www.necyouthministries.org/media/adShow.swf", ""+gal+"", "" + w + "", "" + h + "", "9.0.0", false, flashvars, params, attributes);  

}
//Transparent header
featHeader("home/settings", "fheader", 960, 300); 

function featHeader(fx, con,w,h,css) {
    var flashvars = {};
    jQuery("#intro").height(h);
    flashvars.settingsXML = "http://www.baydaonline.org/Data/rotatordata/" + fx + ".xml";
		var params = {};
			params.allowscriptaccess = "always";
			params.allownetworking = "all";
			params.wmode = "transparent";
			params.menu ="false";
		var attributes = {};
		attributes.wmode = "transparent";
		attributes.id = "slider";
		swfobject.embedSWF("http://www.baydaonline.org/ClientScript/rotator/banner.swf", "" + con + "", "" + w + "", "" + h + "", "9", "expressInstall.swf", flashvars, attributes);
}

	 function createVideo(container, w, ht, file) {

    var flashvars = {
            autostart: "false",
            icons: "false",
            playlistsize: "100",
            playlistsize: "100",
            stretching: "fill",
            playlist: "top",
            file: "../media/"+file,
            lightcolor: "74A45A",
            duration: "33",
            backcolor: "FCFCFC",
            frontcolor: "013565",
            screencolor: "ffffff",
            skin: "../media/modieus.swf",
            displayheight: "30",
            volume: "50",
            controlbar: "bottom"
        }
        var params = {
            wmode: "transparent",
            allowfullscreen: "false",
            allowscriptaccess: "always",
            menu: "0"
        }
        var attributes = "";
        swfobject.embedSWF("/media/player.swf", ""+container+"", ""+w+"", ""+ht+"", "9.0.115", false, flashvars, params, attributes);

    //swfobject.embedSWF(""+player+"", ""+container+"", ""+w+"", ""+ht+"", "9.0.45.0", "http://www.necsoccerl.org/lib/swfobject/expressInstall.swf", { filePath: ""+path+"" }, { menu: 'false', wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact', allowFullScreen: 'true' });

}

    /*swfobject.embedSWF("media/homeList.swf", "Fc", "659", "300", "9.0.0", "expressInstall.swf", { filePath: "http://bhivevilla.com/adminoffice/jamaica/images.php?gallery=2" }, { menu: 'false', wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact' });
    swfobject.embedSWF("media/vid_display.swf", "video", "690", "300", "9.0.0", "expressInstall.swf", { filePath: "http://bhivevilla.com/adminoffice/jamaica/images.php?gallery=2" }, { menu: 'false', wmode: 'opaque', align: 'bottom', salign: 'LT', quality: 'high', menu: 'false', scale: 'exact' });*/
 /*   jQuery('.accordion:eq(0) > div').hide();*/
    jQuery('.accordion:eq(0) > a').click(function() {

        if (jQuery(this).next().is(":visible")) {

            jQuery(this).next().slideUp();
            jQuery(this).css("background-color", "");
            jQuery(".minmax:contains('-')").text("+");

        } else {

            jQuery(".minmax:contains('-')").text("+");

            jQuery('.accordion:visible > div').slideUp('fast');
            jQuery('.accordion:visible > a').css("background-color", "");

            jQuery(this).next().slideToggle('fast');
            jQuery(this).css("background-color", "#f9f9f9");

            var string = jQuery(this).html();
            string = string.replace("+", "-");
            jQuery(this).html(string);
        }



        //jQuery("ul#botnav").superfish().find('ul').bgIframe({ opacity: false });
        //jQuery("ul#botnav").superfish();

        jQuery('h1.test').sifr({
            font: 'andalus',
            path: 'media/',
            color: '#fff',
            width: 500,
            height: 60,
            flashvars: { w: 500, h: 90 },
            expressInstall: true // user will be prompted to update their flash player with an expressInstall option
        });
        jQuery('h3').sifr({ font: 'forte', path: 'media/', color: '#121', width: 250, height: 30, flashvars: { w: 250, h: 30} });
        jQuery('p#intro').sifr({ font: 'trajan', path: 'media/', color: '#F5F4F3', width: 250, height: 30, flashvars: { w: 250, h: 30, emcolor: '#BF0303'} });
        jQuery('h3.maint').sifr({ font: 'trajan', path: 'media/', color: '#BF0303', width: 250, height: 30, flashvars: { w: 250, h: 30, emcolor: '#BF0303', wmode: 'opaque'} });
        jQuery('h2.head').sifr({ font: 'trajan', path: 'media/', color: '#BF0303', width: 540, height: 40, flashvars: { w: 540, h: 40, wmode: 'opaque'} });
        jQuery('h6').sifr({ font: 'trajan', path: 'media/', color: '#fff', width: 200, height: 15, flashvars: { w: 200, h: 15, wmode: 'opaque'} });
        jQuery('div.title').sifr({ font: 'trajan', path: 'media/', color: '#fff', width: 200, height: 20, flashvars: { w: 200, h: 20, wmode: 'opaque'} }); /**/

        /*Video*/
        jQuery('div.videos div').hide();
        var origHeight = jQuery('div.videos').css("height");

        jQuery('div.videos img').hover(function() {

            jQuery(this).css("opacity", ".5");
            var thisParam = jQuery(this);

            jQuery('div.videos').stop().animate({ "height": "310px" }, function() {
                jQuery(thisParam).parent('a').next('div').stop().show();
            });

        }, function() {

            jQuery(this).css("opacity", "1");
            jQuery('div.videos div').hide(); jQuery('div.videos').stop().animate({ "height": origHeight });
        });
    });
});
 function k_next_slide($items_to_click, $items_to_fade,$next)
{
	$items = jQuery($items_to_fade);
	$click_these_items = jQuery($items_to_click);
	var x = 0;
	
	$items.each(function(i)
	{
		jQuery(this).find($next).click(function()
		{
		i+1 < $click_these_items.length ? x = i + 1 : x = 0;	
		$click_these_items.filter(":eq("+x+")").trigger('click');
		return false;
		});
	});
}

function k_newsticker($items_to_fade, $display_time)
{
	
	tickerchange = setInterval(k_start_ticker, $display_time);
	var $tickeritem = jQuery($items_to_fade);
	var i = 1;
	
	function k_start_ticker()
	{
	$tickeritem.filter(":eq("+i+")").trigger('fade');
	i+1 < $tickeritem.length ? i++ : i = 0;	
	}
	
	  $tickeritem.each(function(i)
	  {
		  jQuery(this).bind("fade",function()
		  {	
			  $new_ticker_item = $tickeritem.filter(":eq("+i+")");
			  
			  if( $new_ticker_item.css("display") == "none" )
			  {
				  $tickeritem.filter(":visible").fadeOut(400, function()
				  {	
					  $new_ticker_item.fadeIn(400);
				  });
			  }
			  
		  });
	  });
}


function k_autoslide($items_to_click, $display_time)
{	
	interval = setInterval(k_start_autoplay, $display_time);
	var $click_these_items = jQuery($items_to_click);
	var i = 1;
	
	$click_these_items.click(function($eventobject, $autoplay)
	{
		if(interval && !$autoplay) clearInterval(interval);
	});
	
	
	function k_start_autoplay()
	{	
		
		$click_these_items.filter(":eq("+i+")").trigger('click',[true]);
		i+1 < $click_these_items.length ? i++ : i = 0;
		
	}
	
}


function k_fader($items_to_click, $items_to_fade)
{	
	var $item = jQuery($items_to_fade);
	
	jQuery($items_to_click).each(function(i)
	{
		jQuery(this).click(function()
		{	
			$new_item = $item.filter(":eq("+i+")");
			
			if( $new_item.css("display") == "none" )
			{
				$item.filter(":visible").fadeOut(400, function()
				{	
					$new_item.fadeIn(400);
				});
			}
			
			return false;
			
		});
		
	});
	
}

function k_pointer()
{	
	var $wrapper = jQuery(".preview_images");
	var $slider = jQuery('<div class="pointer"></div>').appendTo($wrapper);
	
	var $slider_half = $slider.width()/2;
	jQuery(".preview_images a").each(function(i)
	{
		jQuery(this).click(function()
		{	
			jQuery(".current_prev").removeClass('current_prev');
			jQuery(this).addClass('current_prev');
			
			$image_pos = jQuery(this).position();
			$newposition = $image_pos.left + jQuery(this).width()/2 - $slider_half;
			$slider.animate({"left":$newposition},600,"easeOutBack");
		});
		
	});
	
}

 function nec_improvements()
{
	//jQuery("#home-blogposts-nav").prepend("<div class='corner_left ie6fix'></div><div class='corner_right ie6fix'></div>");
	
	if((jQuery.browser.msie && parseInt(jQuery.browser.version) < 7))
	{
		jQuery("#main, #featured, #featured_bottom").addClass("ie6fix");
	}
}
 
 function slidePanel(){
	var footer = jQuery(".footer").html();
	jQuery(".footer ul").remove();
	jQuery("#top").prepend("<span class='footer_scroll give_text_tooltip' title='Browse Archives'></span><div class='footer advanced_footer'><div class='footer_bg'>"+ footer +"</div></div>");	
	jQuery(".advanced_footer .footer_meta").remove();
	jQuery(".advanced_footer").css({opacity:0.97});
	
	jQuery(".footer_scroll").click(function(){
	  jQuery(".advanced_footer").slideToggle("slow");
	  jQuery(this).toggleClass("active");
	});

	}

function searchpanel(){
	var searchpanel = jQuery(".noscript").html();
	jQuery(".noscript").remove();
	jQuery("#top").prepend("<span class='searchpanel_scroll give_text_tooltip' title='Search Site'></span><div class='searchpanel'><div class='adjustor'>"+ searchpanel +"</div></div>");	
	
	jQuery(".searchpanel_scroll").click(function(){
	  jQuery(".searchpanel").slideToggle("slow");
	  jQuery(this).toggleClass("active");
	});

	}


function simple_tooltip(target_items, name){
 jQuery(target_items).each(function(i){
									
		jQuery("body").append("<div class='"+name+"' id='"+name+i+"'><img src='"+jQuery(this).attr('rel')+"' alt='' /></div>");
		
		var toolheight = jQuery("#"+name+i+" img").height();
		var toolwidth = jQuery("#"+name+i+" img").width();
		var my_tooltip = jQuery("#"+name+i);
		
		
		my_tooltip.css({height:toolheight+"px" , width:toolwidth+"px"}).after("<div class='wrap_"+name+"' id='wrap_"+name+i+"'></div>");
		
		
		var my_tooltip = jQuery("#"+name+i);
		var my_tooltip_wrap = jQuery("#wrap_"+name+i);
		if(jQuery(this).attr("rel") != "" && jQuery(this).attr("rel") != "undefined" ){
		
		jQuery(this).removeAttr("title").mouseover(function(){

				my_tooltip.css({display:"block", height:toolheight+"px", width:toolwidth+"px"});
				
		}).mousemove(function(kmouse){
				toolheight = jQuery("#"+name+i+" img").height();
		        toolwidth = jQuery("#"+name+i+" img").width();
				my_tooltip_wrap.css({display:"block", opacity:0.7, height:(toolheight+20)+"px", width:(toolwidth+20)+"px"});
				var border_top = jQuery(window).scrollTop(); 
				var border_right = jQuery(window).width();
				var left_pos;
				var top_pos;
				var offset = 30;
				if(border_right - (offset *2) >= my_tooltip.width() + kmouse.pageX){
					left_pos = kmouse.pageX+offset;
					} else{
					left_pos = kmouse.pageX-my_tooltip.width()-offset;
					}
					
				if(border_top + offset>= kmouse.pageY - my_tooltip.height()){
					top_pos = kmouse.pageY+offset;
					} else{
					top_pos = kmouse.pageY-my_tooltip.height()-offset;
					}	
				
				
				my_tooltip.css({left:left_pos, top:top_pos});
				my_tooltip_wrap.css({left:left_pos, top:top_pos});
		}).mouseout(function(){
				my_tooltip.css({left:"-9999px"});
				my_tooltip_wrap.css({left:"-9999px"});

		});
		
		}
	});
}

       function createRotator(data, container, id, width, height)
       {
            var flashvars = {file:""+ data +"",overstretch:"true",backcolor:"0xFFFFFF",screencolor:"0xF5F5F5", shownavigation:"false",linkfromdisplay:"true",enablejs:"true"};
			var params = {allowfullscreen:"true",menu:"false",allowscriptaccess:"sameDomain",wmode:"opaque"};
			var attributes = {};
			attributes.id = ""+id+"";
			swfobject.embedSWF("media/imagerotator.swf", ""+ container +"", ""+width+"", ""+height+"", "9.0.0", false, flashvars, params, attributes);

       }
 

       function showlist(theHeight) { document.getElementById("wrapper").style.height = theHeight + "px"; }

       function createPlayer(theFile, el, w, h) {
           var flashvars = {
               file: theFile,
               //autostart: "false",
               //playlistsize: "100",
               //playlist: "top",
               lightcolor: "ffffff",
               stretching:"fill",
               //duration:"33",
               controlbar:"over",
               //backcolor:"FFFFFF",
              frontcolor: "ffffff",
               skin:"media/modieus.swf"
           }
           var params = {
               wmode: "opaque",
               allowfullscreen: "false",
               allowscriptaccess: "always"
           }
           var attributes = {
               id: ""+el+"",
               name: ""+el+""
           }
           
           swfobject.embedSWF("media/player.swf", ""+el+"", ""+w+"", ""+h+"", "9.0.115", false, flashvars, params, attributes);
       }
       function vidPlayer(vidFile, container) {
           var flashvars = {
               //movie: vidFile
           }
           var params = {
               wmode: "transparent",
               allowfullscreen: "false",
               allowscriptaccess: "always",
               movie: vidFile
           }
           var attributes = {
               id: "vid",
               name: "vid"
           }
           swfobject.embedSWF(vidFile, "vid", "250", "264", "9.0.115", false, flashvars, params, attributes);
       }
/*Carousel*/
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function tooltip(target_items, name) {
    $(target_items).each(function(i) {
        $("body").append("<div class='" + name + "' id='" + name + i + "'><p>" + $(this).attr('title') + "</p></div>");
        var my_tooltip = $("#" + name + i);

        if ($(this).attr("title") != "" && $(this).attr("title") != "undefined") {

            $(this).removeAttr("title").mouseover(function() {
                my_tooltip.css({ opacity: 0.8, display: "none" }).fadeIn(400);
            }).mousemove(function(kmouse) {
                var border_top = $(window).scrollTop();
                var border_right = $(window).width();
                var left_pos;
                var top_pos;
                var offset = 15;
                if (border_right - (offset * 2) >= my_tooltip.width() + kmouse.pageX) {
                    left_pos = kmouse.pageX + offset;
                } else {
                    left_pos = border_right - my_tooltip.width() - offset;
                }

                if (border_top + (offset * 2) >= kmouse.pageY - my_tooltip.height()) {
                    top_pos = border_top + offset;
                } else {
                    top_pos = kmouse.pageY - my_tooltip.height() - offset;
                }

                my_tooltip.css({ left: left_pos, top: top_pos });
            }).mouseout(function() {
                my_tooltip.css({ left: "-9999px" });
            });

        }

    });
}


//function tab(wrapper, header, content){
//    jQuery(".widget_block").removeClass("tablist");
//	jQuery(".nowidget").addClass("tablist");
//    
//	var title = wrapper + " " + header;
//	var container_to_hide = wrapper + " " + content;
//	disable = false;
//	

//jQuery(title).css({display: "none"}).each(
//					  function(i){
//						 if (i == 0){
//						jQuery(wrapper).prepend("<a href='/' class='widgettitle advanced_link active'>"+jQuery(this).html()+"</a>");
//							}else{
//						jQuery(".advanced_link:last").after("<a href='/'class='widgettitle advanced_link'>"+jQuery(this).html()+"</a>");
//							}
//						 }
//					  );

//jQuery(container_to_hide).each(
//						 function(i){
//						jQuery(this).addClass("tablist list_"+i); 
//							if(i != 0){
//								jQuery(this).css({display: "none"});
//							}
//						  }
//					 );

//jQuery(".advanced_link").each(
//					  function(i){
//						jQuery( this ).bind ("click",function(){
//												if(jQuery(this).hasClass('active')){return false}
//														 if(disable == false){disable = true;
//														 jQuery(".advanced_link").removeClass("active");
//														 jQuery(this).addClass("active");
//														 jQuery(container_to_hide+":visible").slideUp(400,function(){
//																	jQuery(".list_"+i).slideDown(400, function(){disable=false; });
//																								   });
//														 }
//														 return false;

//														 });
//						  }
//					  );
//}




function my_smothscroll(){
jQuery('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = jQuery(this.hash);
      $target = $target.length && $target
      || jQuery('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        jQuery('html,body')
        .animate({scrollTop: targetOffset}, 700);
       return false;
      }
    }
  });
}


function mainmenu(){
	if(!jQuery.browser.msie){// IE  - 2nd level Fix
	jQuery(" #nav ul ").css({opacity:"0.95"});
	}
jQuery("#nav a").removeAttr('title');
jQuery(" #nav ul ").css({display: "none"}); // Opera Fix
jQuery(" #nav > li > ul").parent().find("a:first").append("<span class='sub_list'>&nbsp;</span>");
jQuery(" #nav ul li > ul").parent().find("a:first").append("<span class='sub_sub_list'>&nbsp;</span>");

jQuery(" #nav li").hover(function(){
		jQuery(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		jQuery(this).find('ul:first').css({visibility: "hidden"});
		});
}


function noscript(){

    
    $content =jQuery(".widget_rss h3 a:eq(1)").html();
    jQuery(".widget_rss h3 a").remove();
    jQuery(".widget_rss h3").append($content);
	
	}	

	
	function scroller(wrapping_element, scrolling_element, appendbuttons){
		
	if (jQuery(wrapping_element).length > 0){
	offset = jQuery(wrapping_element).offset();
	scrolling_area = jQuery(scrolling_element).height() - jQuery(wrapping_element).height();
	
	var SCROLL_FIX = jQuery(wrapping_element).height();
	var scroll_amount = 0;
	var currentPos = jQuery(scrolling_element).position();
	var animating = false;
	var ticker=0;
	var height_of_rest=0;
	var prevurl;
	
	jQuery(".teaserbox").prepend("<span><a href='' title=''>Vist this Site</a></span>");
	prevurl = jQuery(scrolling_element +" li:eq(0) a").attr("href");
	jQuery(".teaserbox span a").attr({href: prevurl});
	
	jQuery(".teaserbox span").click(function(){
	  window.location=prevurl; return false;
	});

	
	
	
	jQuery(scrolling_element +" li:eq("+ticker+") a").addClass("ticker");
		
	jQuery(scrolling_element +" li a").each(function(i){
													 jQuery(this).bind("click", function(){
															  clearInterval(newsticker_interval);
															  if(!(jQuery(".teaser_img_item_"+i).hasClass("displayme"))){
															  jQuery(".displayme").fadeOut(400, function(){
																										 jQuery(this).removeClass("displayme");
																										 
																										 });
															  jQuery(".teaser_img_item_"+i).fadeIn(400).addClass("displayme");
															  jQuery(".teaser_excerpt_"+i).slideDown(1000).addClass("displayme");
															  prevurl = jQuery(scrolling_element +" li:eq("+i+") a").attr("href");
															  jQuery(".teaserbox span a").attr({href: prevurl});
															  jQuery(".ticker").removeClass("ticker");
															  jQuery(this).addClass("ticker");
															  }
															  return false;
															  });
													 
													 
													 });
	
	function newsticker(){
		height_of_rest=0;
		jQuery(scrolling_element +" li:gt("+ticker+")").each(function(){
																	 height_of_rest += jQuery(this).height();
																	  });
		
		var amount_to_scroll;
		currentPos = jQuery(scrolling_element).position();
		
		if(height_of_rest >= jQuery(wrapping_element).height()){
		amount_to_scroll = jQuery(scrolling_element +" li:eq("+ticker+")").height() - currentPos.top;
		}else{
		amount_to_scroll = jQuery(scrolling_element).height() - jQuery(wrapping_element).height();
		}

		if(ticker + 2 > jQuery(scrolling_element +" li").length){
		amount_to_scroll = 0;
		ticker = -1;
			}
		if (scrolling_area > 0){
		jQuery(scrolling_element).animate({top: -amount_to_scroll},250);
		}
		
		
		
		ticker++;
		jQuery(".ticker").removeClass("ticker");
		prevurl = jQuery(scrolling_element +" li:eq("+ticker+") a").attr("href");
		jQuery(".teaserbox span a").attr({href: prevurl});
		
		jQuery(scrolling_element +" li:eq("+ticker+") a").addClass("ticker");
		jQuery(".displayme").fadeOut(400, function(){jQuery(this).removeClass("displayme");});
		
		jQuery(".teaser_img_item_"+ticker).fadeIn(400).addClass("displayme");
		jQuery(".teaser_excerpt_"+ticker).slideDown(1000).addClass("displayme");
	
		}
		
	newsticker_interval = setInterval(newsticker,10000);
if (scrolling_area > 0){
	jQuery(appendbuttons).append("<span class='scrollup disabled'>UP</span> <span class='scrolldown'>DOWN</span>");
	jQuery(".scrolldown").bind("click",function(){scroll_items("down",SCROLL_FIX)});
	jQuery(".scrollup").bind("click",function(){scroll_items("up",SCROLL_FIX)});
	
	function scroll_items(direction,amount){
		clearInterval(newsticker_interval);
		
		if (animating == false){
		animating = true;	
		currentPos = jQuery(scrolling_element).position();
		
		if (direction == "down") {
			if ((currentPos.top*-1) + amount < jQuery(scrolling_element).height() - jQuery(wrapping_element).height()){
				scroll_amount += amount;
			}else{
				scroll_amount = jQuery(scrolling_element).height() - jQuery(wrapping_element).height();
				jQuery(".scrolldown").addClass("disabled");
			}jQuery(".scrollup").removeClass("disabled");
		}else
		if (direction == "up"){
			if(scroll_amount -  amount >= 0){
			scroll_amount -= amount;
			}else{
			scroll_amount = 0;
			jQuery(".scrollup").addClass("disabled");
			}jQuery(".scrolldown").removeClass("disabled");
		}
		jQuery(scrolling_element).animate({top: -scroll_amount},290, function(){animating = false;});
		
		
		}
	}
	}
}
}

function tooltip2(selector, selectname, atrribute){
jQuery(selector).each(function(i){
			if (jQuery(this).attr(atrribute) != ""){
			jQuery("body").append("<div class='"+selectname+"' id='"+selectname+i+"'>"+jQuery(this).attr(atrribute)+"</div>");
			
			jQuery(this).removeAttr(atrribute).mouseover(function(e){
					jQuery("#"+selectname+i).css({opacity:0.85, display:"none", visibility:"visible"}).animate({"padding": "9px"}, 100).fadeIn(800);
			}).mousemove(function(e){
					jQuery("#"+selectname+i).css({left:e.pageX+14, top:e.pageY+14});
			}).mouseout(function(){
					jQuery("#"+selectname+i).css({display:"none", visibility:"hidden"});				  
			});
			
			
			}
		});
 	}

 	

	  
//$(document).ready(function() {
//    simple_tooltip("a", "tooltip");
//});
 	/*
 	* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 	*
 	* Uses the built in easing capabilities added In jQuery 1.1
 	* to offer multiple easing options
 	*
 	* TERMS OF USE - jQuery Easing
 	* 
 	* Open source under the BSD License. 
 	* 
 	* Copyright © 2008 George McGinley Smith
 	* All rights reserved.
 	* 
 	* Redistribution and use in source and binary forms, with or without modification, 
 	* are permitted provided that the following conditions are met:
 	* 
 	* Redistributions of source code must retain the above copyright notice, this list of 
 	* conditions and the following disclaimer.
 	* Redistributions in binary form must reproduce the above copyright notice, this list 
 	* of conditions and the following disclaimer in the documentation and/or other materials 
 	* provided with the distribution.
 	* 
 	* Neither the name of the author nor the names of contributors may be used to endorse 
 	* or promote products derived from this software without specific prior written permission.
 	* 
 	* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 	* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 	* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 	*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 	*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 	*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 	* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 	*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 	* OF THE POSSIBILITY OF SUCH DAMAGE. 
 	*
 	*/

 	// t: current time, b: begInnIng value, c: change In value, d: duration
 	jQuery.easing['jswing'] = jQuery.easing['swing'];

 	jQuery.extend(jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function(x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function(x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function(x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function(x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function(x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function(x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function(x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function(x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function(x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function(x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function(x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function(x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function(x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function(x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function(x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function(x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});

 	/*
 	*
 	* TERMS OF USE - EASING EQUATIONS
 	* 
 	* Open source under the BSD License. 
 	* 
 	* Copyright © 2001 Robert Penner
 	* All rights reserved.
 	* 
 	* Redistribution and use in source and binary forms, with or without modification, 
 	* are permitted provided that the following conditions are met:
 	* 
 	* Redistributions of source code must retain the above copyright notice, this list of 
 	* conditions and the following disclaimer.
 	* Redistributions in binary form must reproduce the above copyright notice, this list 
 	* of conditions and the following disclaimer in the documentation and/or other materials 
 	* provided with the distribution.
 	* 
 	* Neither the name of the author nor the names of contributors may be used to endorse 
 	* or promote products derived from this software without specific prior written permission.
 	* 
 	* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 	* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 	* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 	*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 	*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 	*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 	* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 	*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 	* OF THE POSSIBILITY OF SUCH DAMAGE. 
 	*
 	*/





/**
 * 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;

            i = $jc.intval(i);
            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) {
                    alert('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);

/****************************************
				Twitter
***************************************/

var tweetUsers = ['NECYouthMin'];
var buildString = "";

jQuery(document).ready(function(){

	jQuery('#twitter-ticker').slideDown('slow');
	
	for(var i=0;i<tweetUsers.length;i++)
	{
		if(i!=0) buildString+='+OR+';
		buildString+='from:'+tweetUsers[i];
	}
	
	var fileref = document.createElement('script');
	
	fileref.setAttribute("type","text/javascript");
	fileref.setAttribute("src", "http://search.twitter.com/search.json?q="+buildString+"&callback=TweetTick&rpp=50");
	
	document.getElementsByTagName("head")[0].appendChild(fileref);
	
});

function TweetTick(ob)
{
	var container=jQuery('#tweet-container');
	container.html('');
	
	jQuery(ob.results).each(function(el){
	
		var str = '	<div class="tweet">\
					<div class="avatar"><a href="http://twitter.com/'+this.from_user+'" target="_blank"><img src="'+this.profile_image_url+'" alt="'+this.from_user+'" /></a></div>\
					<div class="user"><a href="http://twitter.com/'+this.from_user+'" target="_blank">'+this.from_user+'</a></div>\
					<div class="time">'+relativeTime(this.created_at)+'</div>\
					<div class="txt">'+formatTwitString(this.text)+'</div>\
					</div>';
		
		container.append(str);
	
	});
	//jQuery('#tweet-container').jScrollPane();
	//container.jScrollPane();
}

function formatTwitString(str)
{
	str=' '+str;
	str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'<a href="$1" target="_blank">$1</a>');
	str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@<a href="http://twitter.com/$2" target="_blank">$2</a>');
	str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1<a href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');
	return str;
}

function relativeTime(pastTime)
{	
	var origStamp = Date.parse(pastTime);
	var curDate = new Date();
	var currentStamp = curDate.getTime();
	
	var difference = parseInt((currentStamp - origStamp)/1000);

	if(difference < 0) return false;

	if(difference <= 5)				return "Just now";
	if(difference <= 20)			return "Seconds ago";
	if(difference <= 60)			return "A minute ago";
	if(difference < 3600)			return parseInt(difference/60)+" minutes ago";
	if(difference <= 1.5*3600) 		return "One hour ago";
	if(difference < 23.5*3600)		return Math.round(difference/3600)+" hours ago";
	if(difference < 1.5*24*3600)	return "One day ago";
	
	var dateArr = pastTime.split(' ');
	return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+(dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');
}

/* http://keith-wood.name/countdown.html
   Countdown for jQuery v1.5.4.
   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
   Please attribute the author if you use it. */

/* Display a countdown timer.
   Attach it with options like:
   $('div selector').countdown(
       {until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */

(function($) { // Hide scope, no $ conflict

/* Countdown manager. */
function Countdown() {
	this.regional = []; // Available regional settings, indexed by language code
	this.regional[''] = { // Default regional settings
		// The display texts for the counters
		labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
		// The display texts for the counters if only one
		labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
		compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
		timeSeparator: ':', // Separator for time periods
		isRTL: false // True for right-to-left languages, false for left-to-right
	};
	this._defaults = {
		until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
			// or numeric for seconds offset, or string for unit offset(s):
			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
		since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
			// or numeric for seconds offset, or string for unit offset(s):
			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
		timezone: null, // The timezone (hours or minutes from GMT) for the target times,
			// or null for client local
		serverSync: null, // A function to retrieve the current server time for synchronisation
		format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
			// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
		layout: '', // Build your own layout for the countdown
		compact: false, // True to display in a compact format, false for an expanded one
		description: '', // The description displayed for the countdown
		expiryUrl: '', // A URL to load upon expiry, replacing the current page
		expiryText: '', // Text to display upon expiry, replacing the countdown
		alwaysExpire: false, // True to trigger onExpiry even if never counted down
		onExpiry: null, // Callback when the countdown expires -
			// receives no parameters and 'this' is the containing division
		onTick: null // Callback when the countdown is updated -
			// receives int[7] being the breakdown by period (based on format)
			// and 'this' is the containing division
	};
	$.extend(this._defaults, this.regional['']);
}

var PROP_NAME = 'countdown';

var Y = 0; // Years
var O = 1; // Months
var W = 2; // Weeks
var D = 3; // Days
var H = 4; // Hours
var M = 5; // Minutes
var S = 6; // Seconds

$.extend(Countdown.prototype, {
	/* Class name added to elements to indicate already configured with countdown. */
	markerClassName: 'hasCountdown',
	
	/* Shared timer for all countdowns. */
	_timer: setInterval(function() { $.countdown._updateTargets(); }, 980),
	/* List of currently active countdown targets. */
	_timerTargets: [],
	
	/* Override the default settings for all instances of the countdown widget.
	   @param  options  (object) the new settings to use as defaults */
	setDefaults: function(options) {
		this._resetExtraLabels(this._defaults, options);
		extendRemove(this._defaults, options || {});
	},

	/* Convert a date/time to UTC.
	   @param  tz     (number) the hour or minute offset from GMT, e.g. +9, -360
	   @param  year   (Date) the date/time in that timezone or
	                  (number) the year in that timezone
	   @param  month  (number, optional) the month (0 - 11) (omit if year is a Date)
	   @param  day    (number, optional) the day (omit if year is a Date)
	   @param  hours  (number, optional) the hour (omit if year is a Date)
	   @param  mins   (number, optional) the minute (omit if year is a Date)
	   @param  secs   (number, optional) the second (omit if year is a Date)
	   @param  ms     (number, optional) the millisecond (omit if year is a Date)
	   @return  (Date) the equivalent UTC date/time */
	UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
		if (typeof year == 'object' && year.constructor == Date) {
			ms = year.getMilliseconds();
			secs = year.getSeconds();
			mins = year.getMinutes();
			hours = year.getHours();
			day = year.getDate();
			month = year.getMonth();
			year = year.getFullYear();
		}
		var d = new Date();
		d.setUTCFullYear(year);
		d.setUTCDate(1);
		d.setUTCMonth(month || 0);
		d.setUTCDate(day || 1);
		d.setUTCHours(hours || 0);
		d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
		d.setUTCSeconds(secs || 0);
		d.setUTCMilliseconds(ms || 0);
		return d;
	},

	/* Attach the countdown widget to a div.
	   @param  target   (element) the containing division
	   @param  options  (object) the initial settings for the countdown */
	_attachCountdown: function(target, options) {
		var $target = $(target);
		if ($target.hasClass(this.markerClassName)) {
			return;
		}
		$target.addClass(this.markerClassName);
		var inst = {options: $.extend({}, options),
			_periods: [0, 0, 0, 0, 0, 0, 0]};
		$.data(target, PROP_NAME, inst);
		this._changeCountdown(target);
	},

	/* Add a target to the list of active ones.
	   @param  target  (element) the countdown target */
	_addTarget: function(target) {
		if (!this._hasTarget(target)) {
			this._timerTargets.push(target);
		}
	},

	/* See if a target is in the list of active ones.
	   @param  target  (element) the countdown target
	   @return  (boolean) true if present, false if not */
	_hasTarget: function(target) {
		return ($.inArray(target, this._timerTargets) > -1);
	},

	/* Remove a target from the list of active ones.
	   @param  target  (element) the countdown target */
	_removeTarget: function(target) {
		this._timerTargets = $.map(this._timerTargets,
			function(value) { return (value == target ? null : value); }); // delete entry
	},

	/* Update each active timer target. */
	_updateTargets: function() {
		for (var i = 0; i < this._timerTargets.length; i++) {
			this._updateCountdown(this._timerTargets[i]);
		}
	},

	/* Redisplay the countdown with an updated display.
	   @param  target  (jQuery) the containing division
	   @param  inst    (object) the current settings for this instance */
	_updateCountdown: function(target, inst) {
		var $target = $(target);
		inst = inst || $.data(target, PROP_NAME);
		if (!inst) {
			return;
		}
		$target.html(this._generateHTML(inst));
		$target[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('countdown_rtl');
		var onTick = this._get(inst, 'onTick');
		if (onTick) {
			onTick.apply(target, [inst._hold != 'lap' ? inst._periods :
				this._calculatePeriods(inst, inst._show, new Date())]);
		}
		var expired = inst._hold != 'pause' &&
			(inst._since ? inst._now.getTime() <= inst._since.getTime() :
			inst._now.getTime() >= inst._until.getTime());
		if (expired && !inst._expiring) {
			inst._expiring = true;
			if (this._hasTarget(target) || this._get(inst, 'alwaysExpire')) {
				this._removeTarget(target);
				var onExpiry = this._get(inst, 'onExpiry');
				if (onExpiry) {
					onExpiry.apply(target, []);
				}
				var expiryText = this._get(inst, 'expiryText');
				if (expiryText) {
					var layout = this._get(inst, 'layout');
					inst.options.layout = expiryText;
					this._updateCountdown(target, inst);
					inst.options.layout = layout;
				}
				var expiryUrl = this._get(inst, 'expiryUrl');
				if (expiryUrl) {
					window.location = expiryUrl;
				}
			}
			inst._expiring = false;
		}
		else if (inst._hold == 'pause') {
			this._removeTarget(target);
		}
		$.data(target, PROP_NAME, inst);
	},

	/* Reconfigure the settings for a countdown div.
	   @param  target   (element) the containing division
	   @param  options  (object) the new settings for the countdown or
	                    (string) an individual property name
	   @param  value    (any) the individual property value
	                    (omit if options is an object) */
	_changeCountdown: function(target, options, value) {
		options = options || {};
		if (typeof options == 'string') {
			var name = options;
			options = {};
			options[name] = value;
		}
		var inst = $.data(target, PROP_NAME);
		if (inst) {
			this._resetExtraLabels(inst.options, options);
			extendRemove(inst.options, options);
			this._adjustSettings(target, inst);
			$.data(target, PROP_NAME, inst);
			var now = new Date();
			if ((inst._since && inst._since < now) ||
					(inst._until && inst._until > now)) {
				this._addTarget(target);
			}
			this._updateCountdown(target, inst);
		}
	},

	/* Reset any extra labelsn and compactLabelsn entries if changing labels.
	   @param  base     (object) the options to be updated
	   @param  options  (object) the new option values */
	_resetExtraLabels: function(base, options) {
		var changingLabels = false;
		for (var n in options) {
			if (n.match(/[Ll]abels/)) {
				changingLabels = true;
				break;
			}
		}
		if (changingLabels) {
			for (var n in base) { // Remove custom numbered labels
				if (n.match(/[Ll]abels[0-9]/)) {
					base[n] = null;
				}
			}
		}
	},
	
	/* Calculate interal settings for an instance.
	   @param  target  (element) the containing division
	   @param  inst    (object) the current settings for this instance */
	_adjustSettings: function(target, inst) {
		var serverSync = this._get(inst, 'serverSync');
		serverSync = (serverSync ? serverSync.apply(target, []) : null);
		var now = new Date();
		var timezone = this._get(inst, 'timezone');
		timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
		inst._since = this._get(inst, 'since');
		if (inst._since) {
			inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
			if (inst._since && serverSync) {
				inst._since.setMilliseconds(inst._since.getMilliseconds() +
					now.getTime() - serverSync.getTime());
			}
		}
		inst._until = this.UTCDate(timezone, this._determineTime(this._get(inst, 'until'), now));
		if (serverSync) {
			inst._until.setMilliseconds(inst._until.getMilliseconds() +
				now.getTime() - serverSync.getTime());
		}
		inst._show = this._determineShow(inst);
	},

	/* Remove the countdown widget from a div.
	   @param  target  (element) the containing division */
	_destroyCountdown: function(target) {
		var $target = $(target);
		if (!$target.hasClass(this.markerClassName)) {
			return;
		}
		this._removeTarget(target);
		$target.removeClass(this.markerClassName).empty();
		$.removeData(target, PROP_NAME);
	},

	/* Pause a countdown widget at the current time.
	   Stop it running but remember and display the current time.
	   @param  target  (element) the containing division */
	_pauseCountdown: function(target) {
		this._hold(target, 'pause');
	},

	/* Pause a countdown widget at the current time.
	   Stop the display but keep the countdown running.
	   @param  target  (element) the containing division */
	_lapCountdown: function(target) {
		this._hold(target, 'lap');
	},

	/* Resume a paused countdown widget.
	   @param  target  (element) the containing division */
	_resumeCountdown: function(target) {
		this._hold(target, null);
	},

	/* Pause or resume a countdown widget.
	   @param  target  (element) the containing division
	   @param  hold    (string) the new hold setting */
	_hold: function(target, hold) {
		var inst = $.data(target, PROP_NAME);
		if (inst) {
			if (inst._hold == 'pause' && !hold) {
				inst._periods = inst._savePeriods;
				var sign = (inst._since ? '-' : '+');
				inst[inst._since ? '_since' : '_until'] =
					this._determineTime(sign + inst._periods[0] + 'y' +
						sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
						sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + 
						sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
				this._addTarget(target);
			}
			inst._hold = hold;
			inst._savePeriods = (hold == 'pause' ? inst._periods : null);
			$.data(target, PROP_NAME, inst);
			this._updateCountdown(target, inst);
		}
	},

	/* Return the current time periods.
	   @param  target  (element) the containing division
	   @return  (number[7]) the current periods for the countdown */
	_getTimesCountdown: function(target) {
		var inst = $.data(target, PROP_NAME);
		return (!inst ? null : (!inst._hold ? inst._periods :
			this._calculatePeriods(inst, inst._show, new Date())));
	},

	/* Get a setting value, defaulting if necessary.
	   @param  inst  (object) the current settings for this instance
	   @param  name  (string) the name of the required setting
	   @return  (any) the setting's value or a default if not overridden */
	_get: function(inst, name) {
		return (inst.options[name] != null ?
			inst.options[name] : $.countdown._defaults[name]);
	},

	/* A time may be specified as an exact value or a relative one.
	   @param  setting      (string or number or Date) - the date/time value
	                        as a relative or absolute value
	   @param  defaultTime  (Date) the date/time to use if no other is supplied
	   @return  (Date) the corresponding date/time */
	_determineTime: function(setting, defaultTime) {
		var offsetNumeric = function(offset) { // e.g. +300, -2
			var time = new Date();
			time.setTime(time.getTime() + offset * 1000);
			return time;
		};
		var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
			offset = offset.toLowerCase();
			var time = new Date();
			var year = time.getFullYear();
			var month = time.getMonth();
			var day = time.getDate();
			var hour = time.getHours();
			var minute = time.getMinutes();
			var second = time.getSeconds();
			var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
			var matches = pattern.exec(offset);
			while (matches) {
				switch (matches[2] || 's') {
					case 's': second += parseInt(matches[1], 10); break;
					case 'm': minute += parseInt(matches[1], 10); break;
					case 'h': hour += parseInt(matches[1], 10); break;
					case 'd': day += parseInt(matches[1], 10); break;
					case 'w': day += parseInt(matches[1], 10) * 7; break;
					case 'o':
						month += parseInt(matches[1], 10); 
						day = Math.min(day, $.countdown._getDaysInMonth(year, month));
						break;
					case 'y':
						year += parseInt(matches[1], 10);
						day = Math.min(day, $.countdown._getDaysInMonth(year, month));
						break;
				}
				matches = pattern.exec(offset);
			}
			return new Date(year, month, day, hour, minute, second, 0);
		};
		var time = (setting == null ? defaultTime :
			(typeof setting == 'string' ? offsetString(setting) :
			(typeof setting == 'number' ? offsetNumeric(setting) : setting)));
		if (time) time.setMilliseconds(0);
		return time;
	},

	/* Determine the number of days in a month.
	   @param  year   (number) the year
	   @param  month  (number) the month
	   @return  (number) the days in that month */
	_getDaysInMonth: function(year, month) {
		return 32 - new Date(year, month, 32).getDate();
	},

	/* Generate the HTML to display the countdown widget.
	   @param  inst  (object) the current settings for this instance
	   @return  (string) the new HTML for the countdown display */
	_generateHTML: function(inst) {
		// Determine what to show
		inst._periods = periods = (inst._hold ? inst._periods :
			this._calculatePeriods(inst, inst._show, new Date()));
		// Show all 'asNeeded' after first non-zero value
		var shownNonZero = false;
		var showCount = 0;
		for (var period = 0; period < inst._show.length; period++) {
			shownNonZero |= (inst._show[period] == '?' && periods[period] > 0);
			inst._show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
			showCount += (inst._show[period] ? 1 : 0);
		}
		var compact = this._get(inst, 'compact');
		var layout = this._get(inst, 'layout');
		var labels = (compact ? this._get(inst, 'compactLabels') : this._get(inst, 'labels'));
		var timeSeparator = this._get(inst, 'timeSeparator');
		var description = this._get(inst, 'description') || '';
		var showCompact = function(period) {
			var labelsNum = $.countdown._get(inst, 'compactLabels' + periods[period]);
			return (inst._show[period] ? periods[period] +
				(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
		};
		var showFull = function(period) {
			var labelsNum = $.countdown._get(inst, 'labels' + periods[period]);
			return (inst._show[period] ?
				'<span class="countdown_section"><span class="countdown_amount">' +
				periods[period] + '</span><br/>' +
				(labelsNum ? labelsNum[period] : labels[period]) + '</span>' : '');
		};
		return (layout ? this._buildLayout(inst, layout, compact) :
			((compact ? // Compact version
			'<span class="countdown_row countdown_amount' +
			(inst._hold ? ' countdown_holding' : '') + '">' + 
			showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + 
			(inst._show[H] ? this._minDigits(periods[H], 2) : '') +
			(inst._show[M] ? (inst._show[H] ? timeSeparator : '') +
			this._minDigits(periods[M], 2) : '') +
			(inst._show[S] ? (inst._show[H] || inst._show[M] ? timeSeparator : '') +
			this._minDigits(periods[S], 2) : '') :
			// Full version
			'<span class="countdown_row countdown_show' + showCount +
			(inst._hold ? ' countdown_holding' : '') + '">' +
			showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
			showFull(H) + showFull(M) + showFull(S)) + '</span>' +
			(description ? '<span class="countdown_row countdown_descr">' + description + '</span>' : '')));
	},

	/* Construct a custom layout.
	   @param  inst     (object) the current settings for this instance
	   @param  layout   (string) the customised layout
	   @param  compact  (boolean) true if using compact labels
	   @return  (string) the custom HTML */
	_buildLayout: function(inst, layout, compact) {
		var labels = this._get(inst, (compact ? 'compactLabels' : 'labels'));
		var labelFor = function(index) {
			return ($.countdown._get(inst,
				(compact ? 'compactLabels' : 'labels') + inst._periods[index]) ||
				labels)[index];
		};
		var digit = function(value, position) {
			return Math.floor(value / position) % 10;
		};
		var subs = {desc: this._get(inst, 'description'), sep: this._get(inst, 'timeSeparator'),
			yl: labelFor(Y), yn: inst._periods[Y], ynn: this._minDigits(inst._periods[Y], 2),
			ynnn: this._minDigits(inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
			y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
			ol: labelFor(O), on: inst._periods[O], onn: this._minDigits(inst._periods[O], 2),
			onnn: this._minDigits(inst._periods[O], 3), o1: digit(inst._periods[O], 1),
			o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
			wl: labelFor(W), wn: inst._periods[W], wnn: this._minDigits(inst._periods[W], 2),
			wnnn: this._minDigits(inst._periods[W], 3), w1: digit(inst._periods[W], 1),
			w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
			dl: labelFor(D), dn: inst._periods[D], dnn: this._minDigits(inst._periods[D], 2),
			dnnn: this._minDigits(inst._periods[D], 3), d1: digit(inst._periods[D], 1),
			d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
			hl: labelFor(H), hn: inst._periods[H], hnn: this._minDigits(inst._periods[H], 2),
			hnnn: this._minDigits(inst._periods[H], 3), h1: digit(inst._periods[H], 1),
			h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
			ml: labelFor(M), mn: inst._periods[M], mnn: this._minDigits(inst._periods[M], 2),
			mnnn: this._minDigits(inst._periods[M], 3), m1: digit(inst._periods[M], 1),
			m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
			sl: labelFor(S), sn: inst._periods[S], snn: this._minDigits(inst._periods[S], 2),
			snnn: this._minDigits(inst._periods[S], 3), s1: digit(inst._periods[S], 1),
			s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100)};
		var html = layout;
		// Replace period containers: {p<}...{p>}
		for (var i = 0; i < 7; i++) {
			var period = 'yowdhms'.charAt(i);
			var re = new RegExp('\\{' + period + '<\\}(.*)\\{' + period + '>\\}', 'g');
			html = html.replace(re, (inst._show[i] ? '$1' : ''));
		}
		// Replace period values: {pn}
		$.each(subs, function(n, v) {
			var re = new RegExp('\\{' + n + '\\}', 'g');
			html = html.replace(re, v);
		});
		return html;
	},

	/* Ensure a numeric value has at least n digits for display.
	   @param  value  (number) the value to display
	   @param  len    (number) the minimum length
	   @return  (string) the display text */
	_minDigits: function(value, len) {
		value = '0000000000' + value;
		return value.substr(value.length - len);
	},

	/* Translate the format into flags for each period.
	   @param  inst  (object) the current settings for this instance
	   @return  (string[7]) flags indicating which periods are requested (?) or
	            required (!) by year, month, week, day, hour, minute, second */
	_determineShow: function(inst) {
		var format = this._get(inst, 'format');
		var show = [];
		show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
		show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
		show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
		show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
		show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
		show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
		show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
		return show;
	},
	
	/* Calculate the requested periods between now and the target time.
	   @param  inst  (object) the current settings for this instance
	   @param  show  (string[7]) flags indicating which periods are requested/required
	   @param  now   (Date) the current date and time
	   @return  (number[7]) the current time periods (always positive)
	            by year, month, week, day, hour, minute, second */
	_calculatePeriods: function(inst, show, now) {
		// Find endpoints
		inst._now = now;
		inst._now.setMilliseconds(0);
		var until = new Date(inst._now.getTime());
		if (inst._since && now.getTime() < inst._since.getTime()) {
			inst._now = now = until;
		}
		else if (inst._since) {
			now = inst._since;
		}
		else {
			until.setTime(inst._until.getTime());
			if (now.getTime() > inst._until.getTime()) {
				inst._now = now = until;
			}
		}
		// Calculate differences by period
		var periods = [0, 0, 0, 0, 0, 0, 0];
		if (show[Y] || show[O]) {
			// Treat end of months as the same
			var lastNow = $.countdown._getDaysInMonth(now.getFullYear(), now.getMonth());
			var lastUntil = $.countdown._getDaysInMonth(until.getFullYear(), until.getMonth());
			var sameDay = (until.getDate() == now.getDate() ||
				(until.getDate() >= Math.min(lastNow, lastUntil) &&
				now.getDate() >= Math.min(lastNow, lastUntil)));
			var getSecs = function(date) {
				return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
			};
			var months = Math.max(0,
				(until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
				((until.getDate() < now.getDate() && !sameDay) ||
				(sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
			periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
			periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
			// Adjust for months difference and end of month if necessary
			var adjustDate = function(date, offset, last) {
				var wasLastDay = (date.getDate() == last);
				var lastDay = $.countdown._getDaysInMonth(date.getFullYear() + offset * periods[Y],
					date.getMonth() + offset * periods[O]);
				if (date.getDate() > lastDay) {
					date.setDate(lastDay);
				}
				date.setFullYear(date.getFullYear() + offset * periods[Y]);
				date.setMonth(date.getMonth() + offset * periods[O]);
				if (wasLastDay) {
					date.setDate(lastDay);
				}
				return date;
			};
			if (inst._since) {
				until = adjustDate(until, -1, lastUntil);
			}
			else {
				now = adjustDate(new Date(now.getTime()), +1, lastNow);
			}
		}
		var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
		var extractPeriod = function(period, numSecs) {
			periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
			diff -= periods[period] * numSecs;
		};
		extractPeriod(W, 604800);
		extractPeriod(D, 86400);
		extractPeriod(H, 3600);
		extractPeriod(M, 60);
		extractPeriod(S, 1);
		return periods;
	}
});

/* jQuery extend now ignores nulls!
   @param  target  (object) the object to update
   @param  props   (object) the new settings
   @return  (object) the updated object */
function extendRemove(target, props) {
	$.extend(target, props);
	for (var name in props) {
		if (props[name] == null) {
			target[name] = null;
		}
	}
	return target;
}

/* Process the countdown functionality for a jQuery selection.
   @param  command  (string) the command to run (optional, default 'attach')
   @param  options  (object) the new settings to use for these countdown instances
   @return  (jQuery) for chaining further calls */
$.fn.countdown = function(options) {
	var otherArgs = Array.prototype.slice.call(arguments, 1);
	if (options == 'getTimes') {
		return $.countdown['_' + options + 'Countdown'].
			apply($.countdown, [this[0]].concat(otherArgs));
	}
	return this.each(function() {
		if (typeof options == 'string') {
			$.countdown['_' + options + 'Countdown'].apply($.countdown, [this].concat(otherArgs));
		}
		else {
			$.countdown._attachCountdown(this, options);
		}
	});
};

/* Initialise the countdown functionality. */
$.countdown = new Countdown(); // singleton instance

})(jQuery);

//Google Map

jQuery.fn.googleMap = function(address, options) {
  var defaults = {
    lat: 44.081996,
    long: -123.0286928,
    zoom: 14,
    mapTypeId: google.maps.MapTypeId.HYBRID
  };

  options = jQuery.extend(defaults, options || {});

  var center = new google.maps.LatLng(options.lat, options.long);
  var map = new google.maps.Map(this.get(0), jQuery.extend(options, { center: center }));

  var geocoder = new google.maps.Geocoder();
  geocoder.geocode({ address: address }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
        map.set_center(results[0].geometry.location);
        var marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map
        });
      }
    }
  });
};


jQuery(function () {

			});
