function initBack() {
	$("#back").click(function() {
		history.back();
		return false;
	});
}

function sHover(hover_id){
	$(hover_id).hover(
	function() {
		$(this).addClass('hover');
	},
	function() {
		$(this).removeClass('hover');
	}	
	);
}

function initPrint() {
	$(".a_print").click(function() {
		window.print();
		return false;
	});
}

function initInputLabelFromLabel(input_id,label_id) {
	var text = $(label_id).text(); 
	$(input_id).val(text);
	$(input_id).focus( function() {
		if ($(this).val() == text) {
			$(this).val("");
		}
	} );
	  $(input_id).blur( function() {
		if ($(this).val() == '') {
			$(this).val(text);
		}
	} );
}

function initInputLabelFromInput(input_id) {
	var text = $(input_id).val(); 
	$(input_id).val(text);
	$(input_id).focus( function() {
		if ($(this).val() == text) {
			$(this).val("");
		}
	} );
	  $(input_id).blur( function() {
		if ($(this).val() == '') {
			$(this).val(text);
		}
	} );
}


function valid_mail(co) { return (/^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(co)); }

function sFaq() {

	$('.list-art.faq li').each(function(Inf,val){
		var _this = $(this);
		_this.click(
		function(event){
			event.preventDefault();
			if(_this.hasClass('active')){
				_this.removeClass('active').find('div').slideUp('slow');
				
			}
			else {
				 $('.list-art.faq li.active').removeClass('active').find('div').slideUp('slow');
				 _this.addClass('active').find('div').slideDown('slow');
				}
				
		}
		);
	});
	
}

function loadPic(el) {
	if(el.length==0) return false;
	var i = $('img',el);
	var n = el.next('a');
	if(n.length==0) n = el.parent().next().find('a:first');
	i.fadeTo(200,1,function(){loadPic(n)});
	}
	

function reSi() {
	var originalFontSize = $('.content-l .edytor').css('font-size');
	$(".size .c1").click(function(){
		$('.content-l .edytor').css('font-size', originalFontSize);
		return false;
	});
	// Increase Font Size
	$(".size .c2").click(function(){
		var currentFontSize = $('.content-l .edytor').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 1.2;
		$('.content-l .edytor').css('font-size', newFontSize);
		return false;
	});
	// Decrease Font Size
	$(".size .c3").click(function(){
		var currentFontSize = $('.content-l .edytor').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 1.5;
		$('.content-l .edytor').css('font-size', newFontSize);
		return false;
	});

	
}

function sList() {
	$('.list-answer li').each(function(i,e){
		var w = $(this).find('.bar span').width();
		$(this).find('.bar span').css('width',0);
		$(this).find('.bar span').animate({
			width: w
				
	},2000);
		
	}
			
	
	);
	
}


function tab() {
				$("#prev").css("display", nextPage==0?'none':'block' );
       $("#next").css("display", nextPage==maxPage?'none':'block' );
		if(actPage == null) $(".gal li:eq("+nextPage+")").fadeIn(1000);
		else {
		$(".gal li:eq("+actPage+")").fadeOut(1000,function(){
			$(".gal li:eq("+nextPage+")").fadeIn(1000);
			});
      }
	 actPage = nextPage;
    } 
		function tab1() {
			$("#prev1").css("display", nextPage1==0?'none':'block' );
       $("#next1").css("display", nextPage1==maxPage1?'none':'block' );
		if(actPage1 == null) $(".gal1 li:eq("+nextPage1+")").fadeIn(1000);
		else {
		$(".gal1 li:eq("+actPage1+")").fadeOut(1000,function(){
			$(".gal1 li:eq("+nextPage1+")").fadeIn(1000);
			});
      }
	 actPage1 = nextPage1;
    }

		
		function swapImages(){
		      var _active = $('.img-r img.active');
		      var _activeA = $('.img-r ul li.active');
		      var _nextA = (_activeA.next('li').length > 0) ? _activeA.next('li') : $('.img-r ul li:first');
		      var _next = (_active.next().length > 0) ? _active.next() : $('.img-r img:first');
		     
		      _active.fadeTo('500','0',function(){
		      _active.removeClass('active');
		      _activeA.removeClass('active');
		      _nextA.addClass('active');
		      _next.fadeTo('1500','1').addClass('active');
		      });
		    }			
var _imgswapint = null;		
function sRotate() {
	var _imgt = $('.img-r img');
	var _imga = $('.img-r ul li');
	_imgt.css("opacity","0");
	_imgt.eq(0).fadeTo('1500','1').addClass('active');
	_imga.eq(0).addClass('active');
	_imgswapint = setInterval('swapImages()', 5000);
	_imga.click(
			function(event){
			if (_imgswapint != null){clearInterval(_imgswapint); _imgswapint = null;}	
			event.preventDefault();
			_imga.removeClass('active');
			$(this).addClass('active');
			_imgt.removeClass('active').fadeTo('500','0');
			 var index = _imga.index(this);
			 _imgt.eq(index).fadeTo('1500','1').addClass('active');
			}	
		);
	$('.img-r').mouseleave(function(){if (_imgswapint == null){_imgswapint = setInterval('swapImages()', 5000);}});
	}

var carousel = null;

function initSIFR() {
var rockwell = {
  src: 'swf/sifr.swf'
  ,ratios: [6,1.41,9,1.35,15,1.29,21,1.25,22,1.22,27,1.24,29,1.21,34,1.22,41,1.21,45,1.2,46,1.21,59,1.2,68,1.19,69,1.2,96,1.19,97,1.18,102,1.19,103,1.18,107,1.19,108,1.18,112,1.19,114,1.18,116,1.19,120,1.18,121,1.19,1.18]
};

sIFR.useStyleCheck = true;
sIFR.activate(rockwell);


sIFR.replace(rockwell, {
  selector: '.h_title'
  ,css: {
	  '.sIFR-root' : { 'color': '#F352A5'}
	  }
  ,selectable: false
  ,wmode: 'transparent'
});
}
initSIFR();



function initialize() {
	//initInputLabelFromLabel("#search","#search_l");
	initInputLabelFromLabel("#search","#search_l");
	initInputLabelFromLabel("#newslet","#newslet_l");
	swapImages();
	initBack();
	loadPic($('.gallery li:first a:first'));
	sRotate();
	$('.list-rom').jcarousel({scroll:1, initCallback: function(jc, state) {
		if (state == 'init') {
			carousel = jc;
		}
	}}); 
	 sFaq();
	 reSi();
	 sList();
	sHover(".jcarousel-next");
	sHover(".jcarousel-prev");
	sHover(".jcarousel-prev")
	sHover(".list li");;
	sHover(".list-rom li");
	sHover(".btn input");
	sHover(".sub-err");
	sHover(".nav-footer li");
	initPrint();
	 actPage = null;
          nextPage = '0';
          maxPage = $(".gal1 li").length-1;
          tab();
          
          $("#prev").click(function(){
               nextPage=(actPage<=1?0:actPage-1);
               tab();
               });
          $("#next").click(function(){
               nextPage=(actPage>=maxPage?maxPage:parseInt(actPage)+1);
               tab();
               });
							 
							 actPage1 = null;
          nextPage1 = '0';
          maxPage1 = $(".gal1 li").length-1;
          tab1();
         
          $("#prev1").click(function(){
               nextPage1=(actPage1<=1?0:actPage1-1);
               tab1();
               });
          $("#next1").click(function(){
               nextPage1=(actPage1>=maxPage1?maxPage1:parseInt(actPage1)+1);
               tab1();
               });
}
$(document).ready(initialize);



