jQuery.noConflict();
jQuery(document).ready(function($){
	//$('.wtdirectory_all.wtdirectory_all_detaillink').hide();
	$('.csc-frame.csc-frame-frame2 .wtdirectory_all.wtdirectory_all_list').css({'cursor':'pointer'});
	$('.csc-frame.csc-frame-frame2 .wtdirectory_all.wtdirectory_all_list').click(function(){
		var urlpath = $(this).parent().find('a').attr('href');
		//console.log(urlpath);
		//alert(urlpath);
		window.location.href = '/'+urlpath;
	});	
	$('.home_teasercontainer').prepend('<div class="teaserLeft"></div>').append('<div class="teaserRight"></div>');
	var teaseritemlength = $('.teaseritem').length;
	var teaseritemwidth = teaseritemlength * 820;
	$('.home_teaserbox').wrapInner('<div class="teaseritems"></div>');
	$('.teaseritems').css({'position':'relative','width':teaseritemwidth+'px'});
	$('.teaseritem').first().addClass('active');
	/*$('.home_teasercontainer').append('<div class="teasernaviwrap"></div>');
	for(var i=1;i<=teaseritemlength;i++){
		$('.teasernaviwrap').append('<span class="teasernavi">&nbsp;</a>');
	}
	$('.teasernavi').first().addClass("active");*/
	var activeRight = 1;
	$('.teaserRight').click(function(){ 
		activeRight++;
		if(activeRight<=teaseritemlength){
			$('.teasernavi.active').removeClass("active").next().addClass("active");
		}else{
			activeRight = 1;
			$('.teasernavi.active').removeClass("active");
			$('.teasernavi').first().addClass('active');
		}
		teaserSlider("R",activeRight); 
	});
	
	$('.teaserLeft').click(function(){ 
		activeRight--;
		if(activeRight>=1){
			$('.teasernavi.active').removeClass("active").prev().addClass("active");
		}else{
			activeRight = teaseritemlength;
			$('.teasernavi.active').removeClass("active");
			$('.teasernavi').last().addClass('active');
		}
		teaserSlider("L",activeRight); 
	});
	
	function teaserSlider(direction,teaseractiveID){
		var widthNew = teaseractiveID * 820 - 820;
		if(direction=="L"){
			$('.teaseritems').animate({
    			left: "-"+widthNew
  			}, 2500, function() {
  			});	
		}
		if(direction=="R"){
			$('.teaseritems').animate({
    			left: "-"+widthNew
  			}, 2500, function() {
  			});	
		}
	};
	
	$('.startportal').find(".news-latest-container").each(function(){
		$(this).before('<div class="newsboxsliderup"></div>').after('<div class="newsboxsliderdown"></div>');	
		var htmllatest = $(this).html();
		$(this).html('<div class="newsboxslidercontent">'+htmllatest+'</div>');
	});
	$('.newsboxitem').find(".news-latest-title").each(function(){
		$(this).addClass("clearfix");											   
	});
	$(".newsboxsliderup").click(function(){
		var p = $(this).parent().find('.newsboxslidercontent');
		var position = p.position();
		if(position.top>-528){
			$(this).parent().find('.newsboxslidercontent').animate({
				top: '-=264'
			}, 1000, function() {

			});
		}
	});
	$(".newsboxsliderdown").click(function(){
		var p = $(this).parent().find('.newsboxslidercontent');
		var position = p.position();
		if(position.top<0){
			$(this).parent().find('.newsboxslidercontent').animate({
				top: '+=264'
			}, 1000, function() {

			});
		}
	});
	$(".home_quickbox .csc-menu").before('<div class="quicklinktoggle"></div>')
	$(".quicklinktoggle").click(function(){
		$(".home_quickbox .csc-menu").toggle();
	});
	
	$('.home_quickbox').find('input.powermail_text').each(function(){
		$('.powermail_mandatory').remove();
		//if($(this).hasClass('.powermail_submit')==false){
			$(this).val($(this).parent().find('label').html()+' ...');	
		//}
	});
	
	/* Swap labels of search fields*/
	swap_val = [];
	$(".home_quickbox input").each(function(i) {
		swap_val[i] = $(this).val();
		$(this).focusin(function() {
		  if ($(this).val() == swap_val[i]) {
			$(this).val("");
		  }
		}).focusout(function() {
		  if ($.trim($(this).val()) == "") {
			$(this).val(swap_val[i]);
		  }
		});
	});
	//newsboxsliderdown
	
	
	
	HTTP_GET_VARS = new Array();
	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];
	}
	if(GET('promocode')!="undefined"){
		$('.defaultschmal_content').find("a.mail").each(function(){
			$(this).attr("href",$(this).attr("href")+"?subject="+$(this).attr("title")+" "+GET('promocode'));
			$(this).addClass("promobutton");
		});
	}else{
		var urlpathCampaign = window.location.href.search(/Campaign.+/);
		if(urlpathCampaign>=0){
			$('.defaultschmal_content').find("a.mail").each(function(){
				$(this).attr("href",$(this).attr("href")+"?subject="+$(this).attr("title"));
				$(this).addClass("promobutton");
			});
		}
	}
	
	
});
