var $j=jQuery.noConflict();

$j(document).ready(function(){  
							
	// home banner	
	$j(".image-paging").show();
	$j(".image-paging a:first").addClass("active");

	var imageWidth = $j(".window").width();
	var imageSum = $j(".image-reel li").size();
	var imageReelWidth = imageWidth * imageSum;

	$j(".image-reel").css({'width' : imageReelWidth});	
	
	rotate = function(){
    var triggerID = $active.attr("rel") - 1; 
    var image_reelPosition = triggerID * imageWidth; 

    $j(".image-paging a").removeClass('active'); 
    $active.addClass('active'); 

    //Slider Animation
    $j(".image-reel").animate({
        left: -image_reelPosition
    	}, 650 );

	}; 

	//Rotation  and Timing Event
	rotateSwitch = function(){
    play = setInterval(function(){
        $active = $j('.image-paging a.active').next(); 
        if ( $active.length === 0) { 
            $active = $j('.image-paging a:first'); 
        }
        rotate(); //Trigger the paging and slider function
    	}, 8250); //Timer speed in milliseconds (7 seconds)
	};

	rotateSwitch();
	
	//On Hover
	$j(".image-reel a").hover(function() {
    clearInterval(play); //Stop the rotation
	}, function() {
    rotateSwitch(); //Resume rotation timer
	});	

	//On Click
	$j(".image-paging a").click(function() {
    $active = $j(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
	});
							
	// remove broken links
	$j('img').error(function() {
		$j(this).remove();
	});
    
    // external sites in a new window
    $j("a[rel=external]").attr('target', '_blank');		
	
		
	// Select styling
	$j('#selectWhite').sSelect();
	$j('#selectWhite2').sSelect();
	$j('#selectWhite3').sSelect();
	$j('#preferred_contact').sSelect();
	$j('#overall_service').sSelect();

	$j('#selectBlack').sSelect();
	
	// Hover icons
	if(!$j.browser.msie) {
	$j("#shareDelicious a").blend({speed:400});
	$j("#shareFacebook a").blend({speed:400});
	$j("#shareStumble a").blend({speed:400});
	$j("#shareVimeo a").blend({speed:400});
	$j("#shareYouTube a").blend({speed:400});
	$j("#shareThree a").blend({speed:400});
	$j("#fTwitter a").blend({speed:400});
	$j("#fFacebook a").blend({speed:400});
	$j("#fFlickr a").blend({speed:400});
	};
	
	
});




