$(window).load(function() { // When load with window function works in chrome

    $(".sponsors .carousel_s").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		visible: 4,
		auto: 2000,
		speed: 1000
		
    });

	if($(".team-schedule-container").length) {	
		$(".team-schedule-container .carousel-teamS").jCarouselLite({
        	btnNext: ".next_",
        	btnPrev: ".prev_",
			visible: 6,
			circular: false,
			start: startAt
    	});
	}
	

	// set opacity to nill on page load
	$("#menu ul li span").css("opacity","0");
	// on mouse over
	$("#menu ul li span").hover(function () {
		// animate opacity to full
		$(this).stop().animate({
			opacity: 1
		}, "slow");
	},function () { // on mouse out
		// animate opacity to nill
		$(this).stop().animate({
			opacity: 0
		}, "slow");
	});

	if($("#relPhotos").length) { $(".relatedPhotos ul li a").fancybox(); }
	//$(".popUp a").fancybox();
});

// hide floating ad
function hide() {                                                
		$('#floatingAdbox').hide(); 
}

function cmd_schedule_change (legId){

    //var assoc_div_name='scheduleDiv';
    //gets the return of the form. if has an error then show the form
	$('#currentT_txt').hide();
	$('#loadingSchedule').show();
    url=WEBROOT+'competitions/ajaxschedule/'+legId+'/1';
    $.post(url,function(data){
		$('#scheduleDiv').html(data);
	/*	$('#currentT_txt').show();
		$('#loadingSchedule').hide();*/ 
    });
    //new Ajax.Updater(assoc_div_name, url,{method: 'post', parameters: pars});
}

function cmd_youth_schedule_change (legId,divIdWithoutHash,competitionType){
    //var assoc_div_name='scheduleDiv';
    //gets the return of the form. if has an error then show the form
	//$('#loadingSchedule').show();
	
	//$('#k20LegName').html("Φόρτωση...");
    
    $('#'+divIdWithoutHash).find('.legName').html("Φόρτωση...");
    url=WEBROOT+'competitions/ajaxScheduleYouth/'+legId+'/'+competitionType;
    $.post(url,function(data){
		$('#'+divIdWithoutHash).parent().html(data);
		$("a.iframe").fancybox({ 
			'frameWidth': 630,
			'frameHeight': 570
		});
    });

    //new Ajax.Updater(assoc_div_name, url,{method: 'post', parameters: pars});

}


function cmd_vote_click () {

    var formName='formVote';
    var pars = $("#formVote").serialize();
    var assoc_div_name='voteDiv';
    //gets the return of the form. if has an error then show the form
    //pars = "";

    url=WEBROOT+'/polls/vote';

    $.post(url,pars,function(data){

        $("#voteDiv").html(data);

    })

    //new Ajax.Updater(assoc_div_name, url,{method: 'post', parameters: pars});
}



