/* JavaScript Document
Derya Ege Tekdoner */

//Google Analytics tracking code

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27702234-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
//Google plus1 code  
   (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();

/* changes the colour of h2 --------------------------------------- */
function spectrum(){   
var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
// Personal Pages Text animation in the Index Page
$('h2.title').animate( { color: hue }, 3000);
  spectrum();   
}


/* BEGIN Banner Slider -------------------------------------------- */
//array
var ege_banner = [  'ege_photos/banner/ege_fetus_2002.jpg',
					'ege_photos/banner/ege_balcony_2002.jpg',   
					'ege_photos/banner/ege_livingroom_2003.jpg',  
					'ege_photos/banner/ege_lenger_2004.jpg',  
					'ege_photos/banner/ege_miniaturk_2005.jpg',     
					'ege_photos/banner/ege_antalya_2006.jpg',  
					'ege_photos/banner/ege_moda_2007.jpg',  
					'ege_photos/banner/ege_namikkemal_2008.jpg',  
					'ege_photos/banner/ege_lhf_2009.jpg',     
					'ege_photos/banner/ege_quebec_2010.jpg',
					'ege_photos/banner/ege_thornhill_2011.jpg'
				 ];

var index = 1;

//function for image rotation
	function rotateImage()
	{
	  $('img.ege_banner').fadeOut(0, function()
	  {
		$(this).attr('src', ege_banner[index]);
	 
		$(this).fadeIn(0, function()
		{
		  if (index == ege_banner.length0)
		  {
			index = 0;
		  }
		  else
		  {
			index++;
		  }
	
//this command stops the show at the final slide	
//	     if (index == 10)	  
//		 $('#slideshow').cycle('stop');

		});
	  });

	}

$(document).ready(function(){
//$('#banner').ready(function(){	
  setInterval (rotateImage, 10000);
});



/* END Banner slider -------------------------------------------- */
/* BEGIN title rotator for the banner -------------------------------------------- */
var doAnimate = true;

	function contentRotator(content) {     
	  if (doAnimate) { 
		content.fadeOut(0, function(content) { 
		return function() { 
		/* HIDE ALL ITEMS */
		$("ul#banner_title > li").hide();
		
			   content.fadeIn(0, function() {
				   /* GO BACK TO FIRST ITEM */  
				   if ($(this).attr("id") == $("ul#banner_title > li:last").attr("id")) { 
					setTimeout(function() { 
					contentRotator($("ul#banner_title > li:last")); 
					}, 10000); 
			   }
							
					 else { /* FADE IN NEXT ITEM  */                         
					 setTimeout(function() {
					 contentRotator($(content.next()));
					  }, 10000);                    
					  } 
			   });             
		  }; 
		} 
		(content));     
	  } 
	}

$(document).ready(function() {
 contentRotator($("ul#banner_title > li:first")); 
});

/* END title rotator -------------------------------------------- */


/* BEGIN browser window -------------------------------------------- */
          function BrWindow(theURL,winName,features) {
            window.open(theURL,winName,features);
          }
		  
/* END browser window -------------------------------------------- */


// Floating div-----------------------------------------------------------------------------
function float(){
        floatingMenu.add('float_div', {  
    
                // targetLeft: 0,  
				targetRight: 10,  
				targetTop: 10,  
                // targetBottom: 0,  
      
                // Uncomment one of those if you need centering on  
                // X- or Y- axis.  
                // centerX: true,  
                //centerY: true,  
      
                // Remove this one if you don't want snap effect  
				snap: true		
		});
		document.getElementById('float_div').innerHTML= ("<img src='ege_photos/tr/E-baskurt-05.05.jpg' />");		
}
// END Floating div -----------------------------------------------------------------------------

