var nowactive=nowactive_a=nowactive_s=nowactive_n=nowactive_c='';
var old=old_a=old_s=old_n='';

function toggle_check(choise, cat){
	if(cat=='a'){
		document.contestForm.v_a.value=choise;
		old_a=nowactive_a;
		nowactive_a = choise;
		nowactive = nowactive_a;
		old = old_a;
	}
	if(cat=='s'){
		document.contestForm.v_s.value=choise;
		old_s=nowactive_s;
		nowactive_s = choise;
		nowactive = nowactive_s;
		old = old_s;
	}
	if(cat=='n'){
		document.contestForm.v_n.value=choise;
		old_n=nowactive_n;
		nowactive_n = choise;
		nowactive = nowactive_n;
		old = old_n;
	}

	if (old && old!=nowactive){
		document.getElementById(old).className='checkbx';
	}
}

function flipoff(itm, cat){
	if(cat=='a'){
		nowactive = nowactive_a;
	}
	if(cat=='s'){
		nowactive = nowactive_s;
	}
	if(cat=='n'){
		nowactive = nowactive_n;
	}
	if(cat=='country'){
		nowactive = nowactive_c;
	}	

	if (nowactive!=itm){
		document.getElementById(itm).className='checkbx';
	}
}
function flipon(itm){
	document.getElementById(itm).className='checkbx_check';
}
function swapshops(nr, shoplist, country){
	old = nowactive_c;
	nowactive_c = country;

	if (old && old!=nowactive_c){
		document.getElementById(old).className='checkbx';
	}
	
	for(i=0; i<=nr; i++){
	document.getElementById('shops'+i).style.display='none';	
	}
	
	document.getElementById(shoplist).style.display='block';

}

function check_email(email){
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	if (emailfilter.test(email)==false){
		alert('Please fill in a valid emailaddress.');
		return false;
	}else{
		return true;
	}
}

$(document).ready(function(){
	var tel=0;
	function footer_ani(){
		if(tel<7) tel++; else tel=1;
		$('.books').animate({left:'-=260px'}, {queue:false, duration: 500, easing: 'easeOutExpo', complete: callback});
		
		
		function callback(){
			var cur_id = $('.books div:first').attr('id');
			$('.books div:first').attr('id','old').clone(true).attr('id',cur_id).appendTo('.books');
			$('.books div#old').remove();
			$('.books').css('left',0);
		};
	}
	
	setInterval(footer_ani, 5000);
	
	$('#collections, .collections_menu').hover(function(){ $('.collections_menu').css('display','block'); $('li#collections a img').css('margin-top','-57px'); },function(){ $('.collections_menu').css('display','none'); $('li#collections a img').css('margin-top','0px'); });
	
	jQuery(function(){jQuery(document).pngFix();});
	
	$('.book_small .top_bg a, .footer_book .top_bg a').hover(function(){
		$(this).stop().animate({ backgroundColor: "#FFF" },{queue:false, duration:150});
		//$(this).stop().animate({ paddingLeft: "+=10px" },{queue:false, duration:150});
	}, function(){
		$(this).stop().css('backgroundColor','transparent');
		//$(this).stop().animate({ backgroundColor: "inherit" },{queue:false, duration:300});
		//$(this).stop().animate({ paddingLeft: "-=10px" },{queue:false, duration:300});
	})
	
	$('#book_slide').cycle({
        fx:     'fade',
        speed:  500,
        timeout: 5000,
        pager:  '#nav',
		slideExpr: 'img'
    });

	
	$('.load_img').hover(function(){
		
		var image = $(this).attr('href');
		if(image!=$('#img_box').attr("src")){
		$('#img_box').hide();
		$('#img_box').attr("src", image).load(function(){ 
			$(this).fadeIn('fast'); 
		})
		
		}
		return false;		
	});
	
	$('.load_img').click(function(){
		return false;		
	});

	var ani1=0;
	var ani2=0;
	speed=25;
	a=0;
	function up_right(){
		a+=65;
		if (jQuery.browser.msie && jQuery.browser.version==6) {
			if(a<=195) $("#pcr .curl span").css("margin-top","-"+a+"px"); else clearInterval(ani3);
		}else{
			if(a<=195) $("#pcr .curl img").css("margin-top","-"+a+"px"); else clearInterval(ani3);
		}
	}
	function down_right(){
		a+=65;
		if (jQuery.browser.msie && jQuery.browser.version==6) {
			if(a<910) $("#pcr .curl span").css("margin-top","-"+a+"px"); else clearInterval(ani4);
		}else{
			if(a<910) $("#pcr .curl img").css("margin-top","-"+a+"px"); else clearInterval(ani4);
		}
	}
	
	$("#pcr .curl").hover(
	  function () {
		a=0;
		clearInterval(ani2);
		ani1 = setInterval(up_right,speed);
	  },
	  function () {
		a=195;
		clearInterval(ani1);
		ani2 = setInterval(down_right,speed);
	  }
	)
	
	var ani3=0;
	var ani4=0;
	speed=25;
	a=0;
	function up_left(){
		a+=65;
		if (jQuery.browser.msie && jQuery.browser.version==6) {
			if(a<=195) $("#pcl .curl span").css("margin-top","-"+a+"px"); else clearInterval(ani3);
		}else{
			if(a<=195) $("#pcl .curl img").css("margin-top","-"+a+"px"); else clearInterval(ani3);
		}
	}
	function down_left(){
		a+=65;
		if (jQuery.browser.msie && jQuery.browser.version==6) {
			if(a<910) $("#pcl .curl span").css("margin-top","-"+a+"px"); else clearInterval(ani4);
		}else{
			if(a<910) $("#pcl .curl img").css("margin-top","-"+a+"px"); else clearInterval(ani4);
		}
	}
	
	$("#pcl .curl").hover(
	  function () {
		a=0;
		clearInterval(ani4);
		ani3 = setInterval(up_left,speed);
	  },
	  function () {
		a=195;
		clearInterval(ani3);
		ani4 = setInterval(down_left,speed);
	  }
	)
	
})

