$(document).ready(function()
{
    $('.thumblink').css({ opacity: 0.0 });
     
    var id = $('.first').attr('id');
    if(id != null)
    {
        var array = id.split('_');
        id = array[1];
        $('#thumb_'+id).addClass('displayBlock');
        $('#thumb_'+id).css({ opacity: 1.0 });
    }       
    $('.thumblink').click(function()
    {
        $('.overlayone').hide();
        $('.overlaylarge').hide();
        $('.overlaytwo').hide();
        var id = $(this).attr('id');
        var array = id.split('_');
        id = array[1];
        if($('#thumb_'+id).hasClass('displayBlock') == false)
        {
            $('.imageBlockLi').hide();
            $('#imageBlock_'+id).fadeIn(900);
            $('.thumblink').removeClass('displayBlock');
            $('.thumblink').css({ opacity: 0.0 });
            $('#thumb_'+id).addClass('displayBlock');
            $('#thumb_'+id).css({ opacity: 1.0 });
        }
        return false;
    });
    
    $('.imageone').mouseover(function()
    {
        $.get('includes/getOverlayText.php?idPortfolio=' + $(this).attr('id')+'&foto=imageone', function(data)
        {
            $('.overlayone').html(data);
            $('.overlayone').show();
        });
    });
    
    $('.imageone').mouseout(function()
    {
       $('.overlayone').hide();
       $('.overlaylarge').hide();
       $('.overlaytwo').hide();
    });
    
    $('.overlayone').mouseover(function()
    {
       $('.overlayone').show();
              $('.overlaylarge').hide();
       $('.overlaytwo').hide();

    });
    
    $('.overlayone').mouseout(function()
    {
       $('.overlayone').hide();
    });
    
        $('.overlaytwo').mouseover(function()
    {
       $('.overlaytwo').show();
       $('.overlaylarge').hide();
       $('.overlayone').hide();
    });
    
    $('.overlaytwo').mouseout(function()
    {
       $('.overlaytwo').hide();
       $('.overlaylarge').hide();
       $('.overlayone').hide();
    });
    
        $('.overlaylarge').mouseover(function()
    {
       $('.overlaylarge').show();
        $('.overlayone').hide();
       $('.overlaytwo').hide();
    });
    
    $('.overlaylarge').mouseout(function()
    {
       $('.overlaylarge').hide();
       $('.overlayone').hide();
       $('.overlaytwo').hide();
    });
        
    $('.imagetwo').mouseover(function()
    {
        $.get('includes/getOverlayText.php?idPortfolio=' + $(this).attr('id')+'&foto=imagetwo', function(data)
        {
            $('.overlaytwo').html(data);
            $('.overlaytwo').show();
        });
    });
    
    $('.imagetwo').mouseout(function()
    {
       $('.overlaytwo').hide();
    });
    
    $('.large').mouseover(function()
    {
        $.get('includes/getOverlayText.php?idPortfolio=' + $(this).attr('id')+'&foto=imageone', function(data)
        {
            $('.overlaylarge').html(data);
            $('.overlaylarge').show();
        });
    });
  
    $('.large').mouseout(function()
    {
       $('.overlaylarge').hide();
    });
    
    $('#imageBlockContainer').mouseout(function()
    {
       $('.overlaylarge').hide();
       $('.overlayone').hide();
       $('.overlaytwo').hide();
    });
    
    $('#submenuContainer').mouseover(function()
    {
       $('.overlaylarge').hide();
       $('.overlayone').hide();
       $('.overlaytwo').hide();
    })
    
    $('.imageone').mouseover(function()
    {
        $('.zoom').css('display', 'block');
    });
    
    $('.imageone').mouseout(function()
    {
        $('.zoom').css('display', 'none');
    });
    
     $('.zoom').mouseover(function()
    {
        $('.zoom').css('display', 'block');
    });
    
    $('.largeImage').mouseover(function()
    {
        $('.zoom3').css('display', 'block');
    });
    
    $('.largeImage').mouseout(function()
    {
        $('.zoom3').css('display', 'none');
    });
    
     $('.zoom3').mouseover(function()
    {
        $('.zoom3').css('display', 'block');
    });
    
     $('.imagetwo').mouseover(function()
    {
        $('.zoom2').css('display', 'block');
    });
    
    $('.imagetwo').mouseout(function()
    {
        $('.zoom2').css('display', 'none');
    });
    
     $('.zoom2').mouseover(function()
    {
        $('.zoom2').css('display', 'block');
    });
      
    $('.thumblink').mouseover(function()
    {
        $(this).css({ opacity: 1.0 });
    });
    
    $('.thumblink').mouseout(function()
    {
        if($(this).hasClass('displayBlock') == false)
        {
            $(this).css({ opacity: 0.0 });
        }
    })
    
    jQuery('#carouselControl').jcarousel({
        scroll: 10
    });
    
	$("a[rel^=lightbox]").colorbox({
	   maxHeight: '90%',
       maxWidth: '90%'
	});
    
    $('.innerfade').innerfade({
		speed: 750,
		timeout: 5000,
		type: 'random'
	});
    
    $(".validateForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
});

function switchImage(image)
{
    if(image != '')
    {
        $(".colorImage").attr('src', image);
    }
}
