// JavaScript Document

/*************************************************************************/	


/*************************************************************************/	
$(function() {
		$("#emailFormBtn, #fromCloseBtn, #contEmail,#notFoundEmail").click(function() {
			$("#emailForm").slideToggle(1000);
		});
		
		$("#submit, #reset").hover(function () {      
			$(this).toggleClass("highlightBtn");    
		});
		
		$("#emailFormBtn, #fromCloseBtn").hover(function () {      
			$(this).toggleClass("highlight");    
		});

});
		
/*************************************************************************/		
		
$(function() {		
		$("#closeSortYear, #closeSortCountry, #closeSortUni").click(function () {      
			$("#year").hide(100);
			$("#country").hide(100); 
			$("#university").hide(100); 
		});
		
		$("#viewYear").click(function () {      
			$("#year").slideToggle(100);
			$("#country").hide(100); 
			$("#university").hide(100); 
		});		
		
		$("#viewCountry").click(function () {      
			$("#year").hide(100);
			$("#country").slideToggle(100); 
			$("#university").hide(100); 
		});
		
		$("#viewUniversity").click(function () {      
			$("#year").hide(100);
			$("#country").hide(100); 
			$("#university").slideToggle(100); 
		});
					
});

/****************************** PORT IM GALLER *************************************/

$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').fadeIn(2000);
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.fadeOut(1500);
				tabContainers.filter(this.hash).fadeIn(1000);
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
				
			})<!--.filter(':first').click()-->;

});

/****************************** Slider ***********************************/
$(document).ready(function(){
		
	var totWidth=0;
	var positions = new Array();
	
	$('#slides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		
		positions[i]= totWidth;
		totWidth += $(this).width();
		
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		
		if(!$(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
	$('#slides').width(totWidth);

	/* Change the cotnainer div's width to the exact width of all the slides combined */

	$('#sliderMenu ul li a, .slideBack, .slideNext').click(function(e,keepScroll){

			/* On a thumbnail click */

			$('li.menuItem').removeClass('act').addClass('inact');
			$(this).parent().addClass('act');
			
			
			
			var pos = $(this).parent().prevAll('.menuItem').length;
			$('#slides').stop().animate({marginLeft:-positions[pos]+'px'},800);
			
			/* Start the sliding animation */
			
			
			e.preventDefault();
			/* Prevent the default action of the link */
						
			// Stopping the auto-advance if an icon has been clicked:
			if(!keepScroll) clearInterval(itvl);
			
			
	});
	
	
	
	$('#sliderMenu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* On page load, mark the first thumbnail as active */
		
	/* Enabling auto-advance. */
	 
	var current=1;
	function autoAdvance()
	{
		if(current==-1) return true;
		
		$('#sliderMenu ul li a').eq(current%$('#sliderMenu ul li a').length).trigger('click',[true]);	
		// [true] will be passed as the keepScroll parameter of the click function on line 28
		current++;
	}

	// The number of seconds that the slider will auto-advance in:
	
	var changeEvery = 10;

	var itvl = setInterval(function(){autoAdvance()},changeEvery*800);

	/* End of customizations */
});

/*************************************************************************************/


(function($){$.tiny=$.tiny||{};$.tiny.carousel={options:{start:1,display:1,axis:'x',controls:true,pager:false,interval:false,intervaltime:8000,rewind:false,animation:true,duration:800,callback:null}};$.fn.tinycarousel=function(options){var options=$.extend({},$.tiny.carousel.options,options);this.each(function(){$(this).data('tcl',new Carousel($(this),options));});return this;};$.fn.tinycarousel_start=function(){$(this).data('tcl').start();};$.fn.tinycarousel_stop=function(){$(this).data('tcl').stop();};$.fn.tinycarousel_move=function(iNum){$(this).data('tcl').move(iNum-1,true);};function Carousel(root,options){var oSelf=this;var oViewport=$('.viewport:first',root);var oContent=$('.overview:first',root);var oPages=oContent.children();var oBtnNext=$('.next:first',root);var oBtnPrev=$('.prev:first',root);var oPager=$('.pager:first',root);var iPageSize,iSteps,iCurrent,oTimer,bPause,bForward=true,bAxis=options.axis=='x';

function initialize(){iPageSize=bAxis?$(oPages[0]).outerWidth(true):$(oPages[0]).outerHeight(true);var iLeftover=Math.ceil(((bAxis?oViewport.outerWidth():oViewport.outerHeight())/(iPageSize*options.display))-1);iSteps=Math.max(1,Math.ceil(oPages.length/options.display)-iLeftover);iCurrent=Math.min(iSteps,Math.max(1,options.start))-2;oContent.css(bAxis?'width':'height',(iPageSize*oPages.length));oSelf.move(1);setEvents();}
function setEvents(){if(options.controls&&oBtnPrev.length>0&&oBtnNext.length>0){oBtnPrev.click(function(){oSelf.move(-1);return false;});oBtnNext.click(function(){oSelf.move(1);return false;});}if(options.interval){root.hover(oSelf.stop,oSelf.start);}if(options.pager&&oPager.length>0){$('a',oPager).click(setPager);}};

		
function setButtons(){if(options.controls){oBtnPrev.toggleClass('disable',!(iCurrent>0));oBtnNext.toggleClass('disable',!(iCurrent+1<iSteps));}if(options.pager){var oNumbers=$('.pagenum',oPager);oNumbers.removeClass('active');$(oNumbers[iCurrent]).addClass('active');}};

function setPager(oEvent){if($(this).hasClass('pagenum')){oSelf.move(parseInt(this.rel),true);}return false;};

function setTimer(){if(options.interval&&!bPause){clearTimeout(oTimer);oTimer=setTimeout(function(){iCurrent=iCurrent+1==iSteps?-1:iCurrent;bForward=iCurrent+1==iSteps?false:iCurrent==0?true:bForward;oSelf.move(bForward?1:-1);},options.intervaltime);}};

this.stop=function(){clearTimeout(oTimer);bPause=true;};

this.start=function(){bPause=false;setTimer();};




this.move=function(iDirection,bPublic){iCurrent=bPublic?iDirection:iCurrent+=iDirection;if(iCurrent>-1&&iCurrent<iSteps){var oPosition={};oPosition[bAxis?'left':'top']=-(iCurrent*(iPageSize*options.display));oContent.animate(oPosition,{queue:false,duration:options.animation?options.duration:0,complete:function(){if(typeof options.callback=='function')options.callback.call(this,oPages[iCurrent],iCurrent);}});setButtons();setTimer();}};return initialize();};})(jQuery);

/*************************************************************************************/

$(document).ready(function(){				
$('#slider-code').tinycarousel({ pager: true, interval: true });
	
	$('.viewport').mouseenter(function() {
    	$('.next, .prev').fadeTo('fast', 0.5, function() {
		});
		});

	
	$('.viewport').mouseleave(function() {
		$('.next, .prev').fadeTo('fast', 0, function() {
   		});
		});
		
	$('.next, .prev').mouseenter(function() {
		$(this).fadeTo('fast', 1, function() {
   		});
		});
		
	$('.next, .prev').mouseleave(function() {
		$(this).fadeTo('fast', .5, function() {
   		});
		});
});

/**********************************************************************************/

