var submenuId = 0;

function submenuShow(id){
	
	if(id == null){
		id = submenuId;
	}
	else{
		submenuId = id;
	}
	div = document.getElementById('navTopSub');
	div.style.display='block';
	
	dsm = document.getElementsByTagName('div');
	for(i=0; i<dsm.length; i++){
		if(dsm[i].className == 'sm'+id) dsm[i].style.display='block';
	}
	
}

function submenuHide(id){
	
	if(id == null) id = submenuId;
	div = document.getElementById('navTopSub');
	div.style.display='none';
	
	dsm = document.getElementsByTagName('div');
	for(i=0; i<dsm.length; i++){
		if(dsm[i].className == 'sm'+id) dsm[i].style.display='none';
	}
	
}

function mainImgSwitch(direction) {
	
    var $active = $('#mainImgMiddle img.active');
    var $activeNavi = $('#mainImgNaviBox span.active');

    if ( $active.length == 0 ) $active = $('#mainImgMiddle img:last');
    if ( $activeNavi.length == 0 ) $activeBottom = $('#mainImgNaviBox span:last');

   
    if(direction == null){
		var $next =  $active.next().length ? $active.next() : $('#mainImgMiddle img:first');
		var $nextNavi =  $activeNavi.next().length ? $activeNavi.next() : $('#mainImgNaviBox span:first');
	
	    $active.addClass('last-active');
	    $activeNavi.addClass('last-active');
	
	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
	        });

	    $nextNavi.addClass('active')
	    $activeNavi.removeClass('active last-active');
	    
	        
	}
    else if(direction == 'next'){
    	var $next =  $active.next().length ? $active.next() : $('#mainImgMiddle img:first');
    	var $nextNavi =  $activeNavi.next().length ? $activeNavi.next() : $('#mainImgNaviBox span:first');
    	
	    $active.addClass('last-active');
	    $next.addClass('active');
	    $active.removeClass('active last-active');
	    
	    $activeNavi.addClass('last-active');
	    $nextNavi.addClass('active')
	    $activeNavi.removeClass('active last-active');
    }
    else if(direction == 'prev'){
    	var $next =  $active.prev().length ? $active.prev() : $('#mainImgMiddle img:last');
    	var $nextNavi =  $activeNavi.prev().length ? $activeNavi.prev() : $('#mainImgNaviBox span:last');
	    
	    $active.addClass('last-active');
	    $next.addClass('active');
	    $active.removeClass('active last-active');
	    
	    $activeNavi.addClass('last-active');
	    $nextNavi.addClass('active')
	    $activeNavi.removeClass('active last-active');
    }
}

function mainImgActive(id){
	var $active = $('#mainImgMiddle img.active');
	$active.removeClass('active');
	
	var $current = $('#mainImgMiddle img#mi'+id);
	$current.addClass('active');
	
	naviActive(id);
}

function naviActive(id){
	var $active = $('#mainImgNaviBox span.active');
	$active.removeClass('active');
	
	var $current = $('#mainImgNaviBox span#nv'+id);
	$current.addClass('active');
}

function promoImgSwitchL() {
    var $active = $('#promoLeft a.active');

    if ( $active.length == 0 ) $active = $('#promoLeft a:last');

	var $next =  $active.next().length ? $active.next() : $('#promoLeft a:first');
	
	$active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
        	$active.removeClass('active last-active');
        });
}
function promoImgSwitchR() {
    var $active = $('#promoRight a.active');

    if ( $active.length == 0 ) $active = $('#promoRight a:last');
    
	var $next =  $active.next().length ? $active.next() : $('#promoRight a:first');
	
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
        	$active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "mainImgSwitch()", 8000 );
    setInterval( "promoImgSwitchL()", 7000 );
    setInterval( "promoImgSwitchR()", 6000 );    
    
    var $spanBox = $('#navCity span#selectmiasto');
    var $selectedCity = $('#navCity option[selected="selected"]');
    $spanBox.html($selectedCity.html());
});



$(document).ready(function(){
	// nawigacja
	$(function() {
		$("#navCity").tabs();
	});
	
	// faq
	$(".faq dt a").click(function(event) {
		if($(this).parent("dt").hasClass("active")) {
			$(".faq dt").add(".faq dd").removeClass("active");
		}
		else {
			$(".faq dt").add(".faq dd").removeClass("active");
			$(this).parent("dt").addClass("active");
			$(this).parent("dt").next("dd").addClass("active");
		}
		event.preventDefault();
	});
});


function showKatContent($id) {
	var $content = $('.offerList div#katC'+$id);
	$content.slideToggle(300);	
}


// google maps
function mapLoad(latitude, longitude, zoom, id) {;
	if (GBrowserIsCompatible()) { 
		var map = new GMap2(document.getElementById("contactMap"+id));
		map.setCenter(new GLatLng(latitude, longitude), zoom);
		map.addControl(new GSmallMapControl());
		
		
		var tebicon = new GIcon();
		tebicon.image = host+"/images/gmap_icon.png";
		tebicon.shadow = host+"/images/gmap_icon_shadow.png";
		tebicon.iconSize = new GSize(28,40);
		tebicon.infoWindowAnchor = new GPoint(14,0);
		tebicon.iconAnchor = new GPoint(14,40);
		tebicon.shadowSize = new GSize(37,34);
		
		var point  = new GLatLng(latitude, longitude);
		var marker = new GMarker(point, {icon: tebicon});
		map.addOverlay(marker);
	}
}




// swfobject config
swfobject.embedSWF(host+"/flash/main.swf", "mainFlash", "770", "386", "9.0.0", false, {time: 13000}, {wmode:"transparent"});
swfobject.embedSWF(host+"/flash/mapa.swf", "mapaFlash", "495", "460", "9.0.0", false, false, {wmode:"transparent"});
swfobject.embedSWF(host+"/flash/BOX_LO_250x211.swf", "LO", "250", "211", "9.0.0", false, false, {wmode:"transparent" });
swfobject.embedSWF(host+"/flash/BOX_kursy_250x211.swf", "BOX_KURSY", "250", "211", "9.0.0", false, false, {wmode:"transparent" });
swfobject.embedSWF(host+"/flash/1rata_gratis_24_07.swf", "ratyGratis", "250", "207", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres="+host+"/promocje"});
//swfobject.embedSWF(host+"/flash/blackRibbon.swf", "blackRibbon", "250", "207", "9.0.0", false, false, {wmode:"transparent", FlashVars:""});
swfobject.embedSWF(host+"/flash/1rata_gratis_small_static_24_07.swf", "ratyGratisSmall", "155", "211", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres="+host+"/promocje"});
swfobject.embedSWF(host+"/flash/sm_zapisy_online.swf", "sm1", "200", "62", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres="+host+"/rekrutacja/zapisy_online"});
//swfobject.embedSWF(host+"/flash/sm_biuro_karier.swf", "sm2", "200", "62", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres="+host+"/biuro_karier"});
swfobject.embedSWF(host+"/flash/sm_program_gwarancja.swf", "sm3", "200", "62", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres="+host+"/onas/gwarancja"});
swfobject.embedSWF(host+"/flash/sm_licea.swf", "sm4", "200", "62", "9.0.0", false, false, {wmode:"transparent", FlashVars:"clickTag=http://liceum.teb.pl/oferta/lo_efs"});
swfobject.embedSWF(host+"/flash/sm_ekstranet.swf", "sm5", "200", "62", "9.0.0", false, false, {wmode:"transparent", FlashVars:"adres=http://www.ekstranet.teb.pl"});

