
jQuery.fn.fadeToggle = function(speed, easing, callback) { 
    return this.animate({opacity: 'toggle'}, speed, easing, callback); 

};

$jq(document).ready(function() {
	
	$jq('#closenews').click(function(e){$jq('.shortnews').fadeOut('slow');});
	$jq("#carousel-news").jcarousel({scroll:1,auto:5,wrap:'circular',vertical:true});
	
	$jq('a.right_option').bind("click",function(){
	  $jq(".mapcontainer").fadeOut("fast").css("z-index","1");
	  $jq($jq(this).attr("href")).fadeIn("fast").css("z-index","2");
	  $jq(".right_option_on").removeClass("right_option_on");
	  $jq($jq(this).attr("href")+"_link").addClass("right_option_on");
	  return false;});
	  
	// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
	if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
		$jq(function($jq) {
			$jq("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
				return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
			});
		});
	}
});

function slideSwitchNextStatic(  idname, slideinterval  ) {

    clearInterval(slideinterval);
    
	var $active = $jq(idname+' li.active');
 
    if ( $active.length == 0 ) $active = $jq(idname+' li:last');
 
    var $next =  $active.next().length ? $active.next() : $jq(idname+' li:first');
 
    $jq(idname+' li').css('opacity','1');
    $jq(idname+' li').css('display','none');
    
    $active.removeClass('active');
 
    $next.addClass('active').css('display','block');
    
    var triggerid = $next.attr("id");
    $jq(idname+'triggers .visible').removeClass('visible');
    $jq('#title'+triggerid).addClass('visible');
}

function slideSwitchToElement(  idname, idelement, slideinterval  ) {

    clearInterval(slideinterval);
    
	var $active = $jq(idname+' li.active');
 
    if ( $active.length == 0 ) $active = $jq(idname+' li:last');
 
    var $next = $jq(idelement);
 
    $jq(idname+' li').css('opacity','1');
    $jq(idname+' li').css('display','none');
    
    $active.removeClass('active');
 
    $next.addClass('active').css('display','block');
    
     var triggerid = $next.attr("id");
    $jq(idname+'triggers .visible').removeClass('visible');
    $jq('#title'+triggerid).addClass('visible');
}

function slideSwitchPrevStatic(  idname , slideinterval ) {

    clearInterval(slideinterval);
    
	var $active = $jq(idname+' li.active');
 
    if ( $active.length == 0 ) $active = $jq(idname+' li:first');
 
    var $prev =  $active.prev().length ? $active.prev() : $jq(idname+' li:last');
 
    $jq(idname+' li').css('opacity','1');
    $jq(idname+' li').css('display','none');
    
    $active.removeClass('active');
 
    $prev.addClass('active').css('display','block');
    
    var triggerid = $prev.attr("id");
    $jq(idname+'triggers .visible').removeClass('visible');
    $jq('#title'+triggerid).addClass('visible');
}


function slideSwitchNext(  idname , clear  ) {

    if(clear) {
      clearInterval(slideinterval);
    }

	var $active = $jq(idname+' li.active');
 
    if ( $active.length == 0 ) $active = $jq(idname+' li:last');
 
    var $next =  $active.next().length ? $active.next() : $jq(idname+' li:first');
 
    $active.addClass('last-active');
 
    $active.css({opacity: 1.0}) .animate({opacity: 0.0}, 1000, function() {  });
 
    $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() {  $active.removeClass('active last-active');   }); 
		
	var triggerid = $next.attr("id");
    $jq(idname+'triggers .visible').removeClass('visible');
    $jq('#title'+triggerid).addClass('visible');
		
}

function form_popup() {
	var box = $jq('#form_popup');
	var boxexpose;
	
	boxexpose = box.expose({
	color: '#0A0E11',
	opacity: 0.8,
	api: true
	});
	
	$jq('#form_popup').css({
	'display': 'block',
	'left': (getWindowSizes().width - 560)/2+'px',
	'top': '100px'
	});
	boxexpose.load();
	$jq('#form_popup .header').bind('click', function(){
	boxexpose.close();
	$jq('#form_popup').css('display', 'none');
	xajax_closePopup();
	});
}

