/*slider*/
jQuery.noConflict();
jQuery(document).ready(function() {
	//Set Default State of each portfolio piece
	jQuery(".paging").show();
	jQuery(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = jQuery(".window").width();
	var imageSum = jQuery(".image_reel .container_slider").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	jQuery(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = jQueryactive.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		jQuery(".paging a").removeClass('active'); //Remove all active class
		jQueryactive.addClass('active'); //Add active class (the jQueryactive is declared in the rotateSwitch function)
		
		
		
		
		//Slider Animation
		jQuery(".image_reel").hide();
		jQuery(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
		jQuery(".image_reel").fadeIn('slow', function() {
      	});
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			jQueryactive = jQuery('.paging a.active').next();
			if ( jQueryactive.length === 0) { //If paging reaches the end...
				jQueryactive = jQuery('.paging a:first'); //go back to first
			}
			//rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	jQuery(".image_reel .container_slider").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	jQuery(".paging a").click(function() {	
		jQueryactive = jQuery(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		
		jQuery("body").removeClass("background_1");
		jQuery("body").removeClass("background_2");
		jQuery("body").removeClass("background_3");
		jQuery("body").removeClass("background_4");
		
		var count = parseInt(jQuery(this).index());
		jQuery("body").addClass("background_" + count);
		
		return false; //Prevent browser jump to link anchor
	});	
	
	
	// Function tabs
    jQuery(".general_tabs").each(function(){
        var parent = jQuery(this);
        var links = parent.find(".tabs li");
        links.bind('click', function(){
            var link = jQuery(this);
            links.removeClass('active');
            jQuery(this).addClass("active");
            jQuery(".tab_content").hide();
            var next = jQuery(jQuery(this).find("a").attr("href"));
            next.fadeIn();
            return false;
        }).filter(':first').trigger('click');
    });

	jQuery("a.jQueryBookmark").click(function(e){
		e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
	 
		if (window.sidebar) { // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
		} else if( window.external || document.all) { // For IE Favorite
			window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
		} else if(window.opera) { // For Opera Browsers
			jQuery("a.jQueryBookmark").attr("href",bookmarkUrl);
			jQuery("a.jQueryBookmark").attr("title",bookmarkTitle);
			jQuery("a.jQueryBookmark").attr("rel","sidebar");
		} else { // for other browsers which does not support
			 alert('Your browser does not support this bookmark action');
			 return false;
		}
	});    
	
});




















