﻿jQuery(document).ready( function() {	
	
	Cufon.replace('#headerMenu a, .myriadprosemibold, #contentLeft h1, #contentRight h2, #contentRight h1' , { fontFamily: 'myriadpro', hover: true } );
	

	////////////////////////   Recent Works Slider ///
	
	var mainProductGroupsLeftNav = jQuery("#mainProductGroupsLeftNav");
	var mainProductGroupsContent = jQuery("#mainProductGroupsContent");
	var mainProductGroupsRightNav = jQuery("#mainProductGroupsRightNav");
	var mainProductGroupsRightNav2 = jQuery("#mainProductGroupsRightNav2");
	var mainslidernumber = jQuery("#mainProductGroupsContent").children().size();
	if ( mainslidernumber % 2 == 1 )
	{
		mainslidernumber+=1;
	}
		
	var mainslidercounter = 0;
	
	mainProductGroupsLeftNav.click( function() {
		
		mainslidercounter--;
		if ( mainslidercounter < 0 )
		{
			mainslidercounter = 0;
		}
		mainslideranimator();
		
	});
	
	mainProductGroupsRightNav.click( function() {
		
		mainslidercounter++;
		if ( mainslidercounter > (mainslidernumber / 2) - 1 )
		{
			mainslidercounter = 0;
		}
		mainslideranimator();
		
	});
	
	
	mainProductGroupsRightNav2.click( function() {
		
		mainslidercounter++;
		if ( mainslidercounter > (mainslidernumber / 2) - 1 )
		{
			mainslidercounter = 0;
		}
		mainslideranimator();
		
	});
		
	function mainslideranimator() 
	{
		mainProductGroupsContent.animate({
			marginLeft: ( 0 - (252 * mainslidercounter) )						  
		},500)
	}
	



	var fancyBoxImage = jQuery("a[rel=zoom]");
	
	if ( fancyBoxImage.length > 0 )
	{
		fancyBoxImage.fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over"> ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	}
	
	fancyBoxImage = jQuery("a.zoom");
	
	if ( fancyBoxImage.length > 0 )
	{
		fancyBoxImage.fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over"> ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	}
	
	fancyBoxImage = jQuery("a[rel=yorum]");
	
	if ( fancyBoxImage.length > 0 )
	{
		fancyBoxImage.fancybox({
			'titlePosition'		: 'inside',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: '800px',
			'height'			: '600px',
			'autoScale'     	: true

		});		
	}
		
	
	jQuery(jQuery(".galleryTd a")[0]).unwrap().unwrap();
	
	jQuery(".galleryTd a").each( function() {
		
		jQuery(this).unwrap().unwrap();
		
	});
	
	jQuery(jQuery(".galleryTd a")[0]).wrap("<div>");
	jQuery(jQuery(".galleryTd a")[1]).appendTo(jQuery(jQuery(".galleryTd a")[1]).prev());
	jQuery(jQuery(".galleryTd a")[1]).after("<div class='saver hiddenText' />");
	
	jQuery(jQuery(".galleryTd a")[2]).wrap("<div>");
	jQuery(jQuery(".galleryTd a")[3]).appendTo(jQuery(jQuery(".galleryTd a")[3]).prev());
	jQuery(jQuery(".galleryTd a")[3]).after("<div class='saver hiddenText' />");
	
	jQuery(jQuery(".galleryTd a")[4]).wrap("<div>");
	jQuery(jQuery(".galleryTd a")[5]).appendTo(jQuery(jQuery(".galleryTd a")[5]).prev());
	jQuery(jQuery(".galleryTd a")[5]).after("<div class='saver hiddenText' />");
	
	var announcementContent = jQuery(".mainAnnouncementsListItem");
	var announcementContentSize = announcementContent.size() - 1;
	var announcementContentIndex = 0;
	var announcementContentTimeout;
	
	announcementContent.each( function() {
		
		jQuery(this).css("opacity","0");
		
	});
	
	function announcementContentChanger(announcementContentIndex2)
	{
		
		clearTimeout(announcementContentTimeout);
		
		announcementContent.css("display","block");
		
		announcementContent.animate({
				
			opacity: 0
				
		},500);
		
		jQuery(announcementContent[announcementContentIndex2]).animate({
				
			opacity: 1
				
		},500);
		
		setTimeout( function() {

			announcementContent.css("display","none");
			jQuery(announcementContent[announcementContentIndex2]).css("display","block");

		},580 );
		
		announcementContentIndex = announcementContentIndex2 + 1
		
		if ( announcementContentIndex > announcementContentSize )
		{
			announcementContentIndex = 0;
		}
		
		announcementContentTimeout = setTimeout( function() {
			
			announcementContentChanger(announcementContentIndex);
			
		},5000);
		
	}
	
	announcementContentChanger(0);
	
});
