$.noConflict();

(function($) {

	$(document).ready(function(){
		//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit
		if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' || navigator.userAgent.toLowerCase().indexOf('android')>0)
		{
			$("#bottom").css("position", "static");
		};


		// Partner slider
		
		$("#partner .slider").jCarouselLite({
			auto: 2000,
			speed: 1000,
			btnNext: "#partner .prev-button",
			btnPrev: "#partner .next-button",
			visible: 4
		});
		
		
		/*$(".start #banner .csc-textpic-imagewrap").jCarouselLite({
			auto: 2000,
			speed: 1000,
			btnNext: "#partner .prev-button",
			btnPrev: "#partner .next-button",
			visible: 1
		});*/
		
		try{
		$('.start #banner .csc-textpic-imagewrap ul').innerfade({
			animationtype: 'fade',
			speed: 'slow',
			timeout: '4000'
			//type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'),
			//containerheight: Height of the containing element in any css-height-value (Default: 'auto')
			//runningclass: CSS-Class which the container get’s applied (Default: 'innerfade')
		});
		}catch(e){}
		
		//Contact Box
		
		$(function() {
		
			var contactWidth = $('.contactinfos').width() + 60;
			
			$('.contactinfos').css({right: - contactWidth });
			
			$('.conttrigger').mouseenter(function() { 
				$('.contactinfos').stop().animate({
					right: 0
				});
			
			});	
			$('.contactslider').mouseleave(function() { 
				$('.contactinfos').stop().animate({
	    			right: - contactWidth
	    		});
			});
			
		});
		
		
		// Label over form fields
		
		$("#epaper input.powermail_text, #newmembers input.powermail_text, #user, #pass, .forgotfield").each(function (type) {
		
			var pElement = $(this).siblings('label');
		
			if (this.value != '') {
				$(pElement).addClass('has-text');
			}
		
			this.autocomplete="off";
		
		
			$(this).focus(function () {
				$(pElement).addClass("focus");
			});
			$(this).keypress(function () {
				$(pElement).addClass("has-text").removeClass("focus");
			});
			$(this).blur(function () {
				if($(this).val() == "") {
					$(pElement).removeClass("has-text").removeClass("focus");
				}
			});
		});
		
		
		// Accordion
				
		if (document.URL.indexOf('#') > -1 ){
			var rautPos = document.URL.indexOf('#');
			var tagID = document.URL.substr(rautPos + 1);
			
			//$('#'+tagID).next('div').children('.acc-item').css('display','block');
			//$('#'+tagID+" .acc-header").addClass('active');
			
			$('#'+tagID).parent('.acc-item').css('display','block');
			$('#'+tagID).parent().parent().prev('div').children('.csc-header').children('.acc-header').addClass('active');
			
		}
		else {
			$($('.acc-item')[0]).css('display','block');
			$($('.acc-header')[0]).addClass('active');
			
		}
				
		$('.acc-item').parent().prev('.csc-default').children('.csc-header').children('h2').click(function(){
			var accItem = $(this).parent().parent().next('.csc-default').children('.acc-item');
			
			if(accItem.css('display')=='block'){
				$(this).removeClass('active');
				$('.acc-item:visible').slideUp(200);
			}
			else {
				$('h2.active').removeClass('active');
				$(this).addClass('active');
				$('.acc-item:visible').slideUp(200);
				accItem.slideDown(200);
			}
			
		});
		
		
		// Class for tables
		
		if(navigator.appVersion.indexOf('MSIE')>-1){
			$('thead th:last-child,tbody td:last-child').addClass('last');
		}
		
		$('.share a').mouseenter(function(){
			window.setTimeout("newPos()", 20);
		});
		
		
	});
	
	

})(jQuery);

function newPos (){
	var scrollPos = document.documentElement.scrollTop;
	if (!scrollPos)	scrollPos = jQuery('body')[0].scrollTop;
	
	var windowHeight = window.innerHeight;
	var boxHeight = jQuery('#at15s').height();
			
	var newPos = scrollPos+windowHeight-boxHeight-30;
	jQuery('#at15s').css('top',newPos+'px');
}
