var addthis_config = {
	services_compact: 'facebook, studivz, twitter,  meinvz, myspace, mailto',
        services_exclude: 'print',
        ui_click: 'true'

}
var addthis_share =
{
   	title: 'Operation Übernahme',
	description: 'Operation Übernahme',

	templates: {
                   twitter: 'Operation Übernahme #igm #igmetall #jugend'
               }
}

var HTTP_GET_VARS=new Array();
var strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
    {
    gArr=strGET.split('&');
    for(i=0;i<gArr.length;++i)
        {
        v='';vArr=gArr[i].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }
 
function GET(v)
{
	if(!HTTP_GET_VARS[v]){return 'undefined';}
	return HTTP_GET_VARS[v];
}


function updatevideotext(id) {
    var content = $('#text_'+id).html();
    $('#text_container').html(content);
    
    var objs = $('#carousel li');
    for(i=0; i<objs.length; i++)
    {
	    if($(objs[i]).attr('id')!='video_elem_'+id)
	    {
		    var str = $(objs[i]).html();
		$(objs[i]).html('');
		$(objs[i]).html(str);
	    }
    }
    
    
};
function mycarousel_initCallback(carousel) {
	//alert();
	/*$(window).load(function () {
		//alert(jQuery.jcarousel.intval(GET('idx')));
            if(GET('idx')!='undefined') {
                carousel.scroll(jQuery.jcarousel.intval(GET('idx')));
            }
        });*/
    $('.jcarousel-control a').bind('click', function() {
        carousel.scroll($.jcarousel.intval($(this).attr('rel')));
        return false;
    });
    
    $('.jcarousel-play a').bind('click', function() {
        if($(this).hasClass('play')){
            $(this).removeClass('play');
            carousel.next();
            carousel.startAuto();
        }
        else {
            $(this).addClass('play');
            carousel.pauseAuto();
        }
        return false;
    });

    $('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = $.jcarousel.intval(this.options[this.selectedIndex].value);
	
        return false;
    });

    $('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    $('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
    
    
};

function gallery_initCallback(carousel) {
    $( '#c_' + $(carousel.container).attr('id') + ' a').bind('click', function() {
	    //alert($(this).attr('rel'));
        carousel.scroll($.jcarousel.intval($(this).attr('rel')));
        return false;
    });
    
};

function gallery_setupCallback(carousel) {
    var w = $( '#' + $(carousel.container).attr('id') + ' .jcarousel-clip-horizontal').width();
    //$( '#' + $(carousel.container).attr('id') + ' .jcarousel-clip-horizontal').width(w+1);
    
    $( '#' + $(carousel.container).attr('id') + ' img').each(function()
    {
	    var i_w = 1 * $(this).attr('width');
	    $(this).attr('width', i_w-1);
    });
  
};

$(window).load(function () {
            if(window.location.hash) {
                var hash = window.location.hash.slice(1); 
                carousel.scroll(jQuery.jcarousel.intval(hash));
            }
        });
function update_carousel_navi(carousel) {
	$('.jcarousel-control a').removeClass('active');
	$('.jcarousel-control #c_'+carousel.first).addClass('active');
};

function update_carousel_navi2(carousel, li, i, state) {
	//$('.jcarousel-control a').removeClass('active');
	//$('.jcarousel-control #c_'+carousel.first).addClass('active');
	//alert($(li).attr('id'));
	$('.jcarousel-control a').removeClass('active');
	$('.jcarousel-control #c_'+$(li).attr('id')).addClass('active');
};

// Ride the carousel...
$(document).ready(function() {
    
    $.each($('#main h1'), function(){
        var h1_line = '<img class="h1_line" src="tl_files/layout/imgs/bg_h_line.png" width="WIDTH" height="5" />';
        $(this).append(h1_line.replace('WIDTH',$(this).innerWidth()));
    });
    
    var start_idx = 1;
    if(GET('idx')!='undefined')
    {
	    start_idx = jQuery.jcarousel.intval(GET('idx'));
    }
    $("#carousel").jcarousel({
        scroll: 1,
	start: start_idx,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
    
    $("#c_carousel").jcarousel({
        scroll: 1
    });
    
    $("#slider_carousel").jcarousel({
        scroll: 1,
        auto: 8,
        //wrap: 'last',
	wrap: 'circular',
	//wrapPrev: '';
        initCallback: mycarousel_initCallback,
        itemFirstInCallback: update_carousel_navi,
	itemVisibleInCallback: update_carousel_navi2,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
    
    $('#ctrl_1').focus(function(){
        if($(this).attr('value')=="Suchbegriff") $(this).attr('value','');
    });
    $('#ctrl_1').focusout(function(){
        if($(this).attr('value')=="") $(this).attr('value','Suchbegriff');
    });
    
    $('#ctrl_email_26').focus(function(){
        if($(this).attr('value')=="E-Mail-Adresse") $(this).attr('value','');
	$(this).addClass('active');
    });
    $('#ctrl_email_26').focusout(function(){
        if($(this).attr('value')=="") { $(this).attr('value','E-Mail-Adresse'); $(this).removeClass('active'); }
    });
    
    $('#listenansicht .entry p a').addClass('button');
    
    if(GET('idx')!='undefined')
    {
	    //alert(GET('idx'));
	    //$("#carousel").jcarousel('scroll',GET('idx'));
	    //$("#c_carousel").jcarousel('scroll',GET('idx'));
	    updatevideotext(GET('idx'));
    }
    
});







