
//content switches

$(document).ready(function(){
	
//automatically triggers on page load
	$('.onoff').click(function(){
		$('.onoff').removeClass('selected');
		$(this).addClass('selected');
		
		var target = $(this).attr('name'); 
		$('.slide').hide();
		$('#'+target).show("slow"); 
	});
		
	
	$('.copy_faq').click(function(){
		$('#faqimagedefault').hide();
	});
	
	$('#partners_container .onoff').click(function(){
		$('#partnerdefault').hide();
	});
	
	$('#newslist .onoff').click(function(){
		$('#newsdefault').hide();
	});
	
});

$('.image_right .onoff').click(function(){
		$('#retaildefault').hide();
	});
	

//content popups

/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/


//0 means disabled; 1 means enabled;
var popupStatus = 0;


function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}


function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//center popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROL EVENTS for popup states
$(document).ready(function(){

	//LOAD POPUP
	//Click the button event
	$(".button").click(function(){
		var target = $(this).attr('name'); 
		$('.infoslide').hide();
		$('#'+target).show();
		
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSE POPUP
	//Click the x event
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
//retail02 animations

    $(document).ready(function() {  
            //move the last list item before the first item. The purpose of this is if the user clicks previous he will be able to see the last item.  
            $('#retailtwo_ul li:first').before($('#retailtwo_ul li:last'));  
      
            //when user clicks the image for sliding right  
            $('#right_scroll img').click(function(){  
      
                //get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '  
                var item_width = $('#retailtwo_ul li').outerWidth() + 10;  
     
               //calculate the new left indent of the unordered list  
               var left_indent = parseInt($('#retailtwo_ul').css('left')) - item_width;  
     
               //make the sliding effect using jquery's anumate function '  
               $('#retailtwo_ul').animate({'left' : left_indent},{queue:false, duration:500},function(){  
     
                   //get the first list item and put it after the last list item (that's how the infinite effects is made) '  
                   $('#retailtwo_ul li:last').after($('#retailtwo_ul li:first'));  
     
                   //and get the left indent to the default -210px  
                   $('#retailtwo_ul').css({'left' : '-210px'});  
               });  
           });  
     
           //when user clicks the image for sliding left  
           $('#left_scroll img').click(function(){  
     
               var item_width = $('#retailtwo_ul li').outerWidth() + 10;  
     
               /* same as for sliding right except that it's current left indent + the item width (for the sliding right it's - item_width) */  
               var left_indent = parseInt($('#retailtwo_ul').css('left')) + item_width;  
     
               $('#retailtwo_ul').animate({'left' : left_indent},{queue:false, duration:500},function(){  
     
               /* when sliding to left we are moving the last item before the first item */  
               $('#retailtwo_ul li:first').before($('#retailtwo_ul li:last'));  
     
               /* and again, when we make that change we are setting the left indent of our unordered list to the default -210px */  
               $('#retailtwo_ul').css({'left' : '-210px'});  
               });  
     
           });  
     });  


