//Front end Java Script File

jQuery(document).ready(function() 
{
//making li act as anchor tag i.e redirecting when li is clicked
/*jQuery('#portfolioListResultId li').click(function(){
        var detUrl=jQuery(this).find('.projDetail').val();
        jQuery(location).attr('href',detUrl);

    });*/
    
   jQuery('#portfolioListResultId li').click(function(){
        var detUrl=jQuery(this).find('.projDetail').val();
        //alert(detUrl);
        window.location.href = "http://www.oechies.nl/"+detUrl;
        //return false;

    }); 
 //Enable Pretty Photo effect for Images 
		jQuery("a[rel^='prettyPhoto']").prettyPhoto
				({    
					animationSpeed: 'normal', 		/* fast/slow/normal */
					padding: 10, 					/* padding for each side of the picture */
					opacity: 0.85, 					/* Value betwee 0 and 1 */
					showTitle:true, 				/* true/false */
					allowresize: false, 			/* true/false */
					counter_separator_label: ' of ', /* The separator for the gallery counter 1 "of" 2 */
					theme: 'light_rounded' 				/* light_rounded / dark_rounded / light_square / dark_square */
				});
//			
	   
	//Cufon.replace('.menu ul li a',{hover:true}); 
	$('#photos').galleryView({
	panel_width: 608,
	panel_height: 280,
	frame_width:146,
	frame_height:86
	

});

//carousel effect for portfolio projects
jQuery('#carousel').jcarousel({
			horizontal: true,
			scroll: 1,
			auto: false,
            initCallback:enableNext,
            buttonNextCallback:nextButtonDisabled,
            buttonPrevCallback:nextPreviousDisabled
	   	});

	//Front page Carousel - Initial Setup
   	jQuery('div#slideshow-carousel a img').css({'opacity': '1.0'});
   	jQuery('div#slideshow-carousel a img:first').css({'opacity': '1.0'});
   	jQuery('div#slideshow-carousel li a:first').append('<span class="arrow"></span>');


  	//Combine jCarousel with Image Display
    $('div#slideshow-carousel li a').hover(
       	function () {

       		if (!$(this).has('span').length) {
        		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
   	    		$(this).stop(true, true).children('img').css({'opacity': '1.0'});
       		}
       	},
       	function () {

       		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
       		$('div#slideshow-carousel li a').each(function () {

       			if ($(this).has('span').length) $(this).children('img').css({'opacity': '1.0'});

       		});

       	}
	).click(function () {

	      	$('span.arrow').remove();
		$(this).append('<span class="arrow"></span>');
       	$('div#slideshow-main li').removeClass('active');
       	$('div#slideshow-main li.' + $(this).attr('rel')).addClass('active');

       	return false;
	});
function mycarousel_initCallback(carousel) {

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
}

	//giving pagination to carousel effect on project page
  carouselEffect();
});

	//function to disable Next Button if there no more images to show
	function nextButtonDisabled()
	{
	   if(jQuery('.jcarousel-next').attr("disabled")=='true')
	    {
	       jQuery('.jcarousel-next').hide();
	    }
	}
	
	//function to disable Previous Button if there no more images to show
	function nextPreviousDisabled()
	{
	   if(jQuery('.jcarousel-prev').attr("disabled")=='true')
	    {
	       jQuery('.jcarousel-prev').hide();
	    }
	
	}
	
	//function to disable Previous button on Load
	function enableNext(size)
	{
	    jQuery('.jcarousel-prev').hide();
	}
	
	//function to disable  Prev Next buttons if images are less then 3
	function carouselEffect()
	{
	    imgCount=jQuery('#carousel li').size();
	    //alert(imgCount);
	    if(imgCount < 3)
	        {
	            jQuery('.jcarousel-prev').hide();
	            jQuery('.jcarousel-next').hide();
	        }
	    else if(imgCount > 3)
	        {
	            jQuery('.jcarousel-next').show();
	            jQuery('.jcarousel-next').click(function(){
	                 jQuery('.jcarousel-prev').show();
	            });
	
	            jQuery('.jcarousel-prev').click(function(){
	                jQuery('.jcarousel-next').show();
	            });
	        }
	}
	
	
	

        $('#thumbnails').simplethumbs({
        slideshow: '#imageview',
        interval: 4000,
        speed: 800,
        captionOk:true,
        cycle: true,
        hoverPause: true,
        callBefore: function(thumb) {
	        jQuery(".panel-overlay_outer").each(function(){   		
	        		 jQuery(".panel-overlay").css("display", "none");	           
	      	});
      		
        }
        }); 
        //if(jQuery(".thumbs li").size()==1){jQuery(".panel-overlay").slideUp().css("display", "block").slideDown();}
//        jQuery(".thumbs li").hover(function(){
//        	jQuery(this).attr('id');
//       });
//        
		if(jQuery(".thumbs li").size()==1)
		{
		jQuery(".thumbs li a").hover(function(){
			
			jQuery(".panel-overlay").css("display", "block").slideDown();
		},
		function()
		{
			jQuery(".panel-overlay").css("display", "none").slideUp();
		});
		
		jQuery(".panel").hover(function(){
			
			jQuery(".panel-overlay").css("display", "block").slideDown();
		},
		function()
		{
			jQuery(".panel-overlay").css("display", "none").slideUp();
		});
		
//		jQuery(".panel").mouseout(function(){
//			jQuery(".panel-overlay").slideDown().css("display", "none");
//            	
//            });
		}

		//CLick event to link the page onClick of Header Image 
		jQuery('#imageview').live('click',function(){
			var strActiveLi=jQuery('a.active').parents().attr('id');
			 var intActiveLiId=strActiveLi.substring(6);
			 var strHref = jQuery('#description_'+intActiveLiId).find('a').attr('href');
			 //alert(strHref);
			window.location=strHref;
//			jQuery('#imageview').href()=strHref;
//			jQuery('#imageview').click();
		});
        
       //function to link the page onClick of thumnail image
       function thumbLink(id)
	   {
	   		var Frameid= id.substring(6);
           var strLink=jQuery('#description_'+Frameid).find('a').attr('href');//alert(strLink);return false;
           window.location=strLink;
	    }
