/*------------------------------------------------------*/
/*  init  */
/*------------------------------------------------------*/
			
	$(document).ready(function(){

		setSelectBoxes();

		if(typeof sIFR == "function"){
			sIFR.replaceElement(named({sSelector:"h2.title",sWmode:"transparent", sFlashSrc:"_swf/danubia.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#515151", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&amp;offsetTop=0"}));
			sIFR.replaceElement(named({sSelector:"h3.sub_title",sWmode:"transparent", sFlashSrc:"_swf/danubia.swf", sColor:"#666666", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#515151", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&amp;offsetTop=0"}));
		}

		slide_shows = new Array();
		slide_delay = 10;
		slide_speed = 1000;
		slide_time = 3500;
		slide_time_slow = 1000;
		
		i = 0;
		$(".block .image").each(function(){

			numChilds = numChildren(this);
			if (numChilds > 1){
			
				slide_show = new Object();
				slide_show.target = this;
				slide_show.my_id = this.id;
				slide_show.current = 0;
				slide_show.num_slides = numChilds;

				if (slide_show.num_slides > 1){
					slide_show.timer = window.setTimeout('start_interVal('+i+')', slide_delay);			
				}else{
					//$("#"+this.id+"_nav").hide();
				}
				slide_shows.push(slide_show);
				i++;
			}

		});

	});
		
	function setQuote(){
		var fo	  = new FlashObject("_swf/quote.swf", "vondst", "240", "170", "7", "#FFFFFF");
		fo.addParam("wmode", "opaque");
		fo.addParam("align", "top");
		fo.addParam("salign", "t");
		fo.write("quote_div");
	}



/*------------------------------------------------------*/
/*  menu */
/*------------------------------------------------------*/

	function showMenu(){
		$("#left").hide();
		$("#menu_over").show();
		$("#hider").show();
		$("#inside_hider").show();
	}

	function hideMenu(){
		$("#left").show();
		$("#hider").hide();
		$("#inside_hider").hide();
		$("#menu_over").hide();
	}

/*------------------------------------------------------*/
/*  search / actueel */
/*------------------------------------------------------*/

	function setSelectBoxes(){


				
		$(".select").click(function(){
			
			showMe = false;
			if ($(this).find(".options").css("display") != "block"){
				showMe = true;
			}
			hideBox();

			if (showMe){
				$(this).find(".options").show();
			}
			
			current_box = this;

			$(this).find(".option").click(function(){
				setSelectValue(current_box,$(this).attr("rel"),$(this).html());				
				hideBox();
				search();
				return false;
			});
			return false;

		});

		$("body").click(function(){
			hideBox();
		});

		$(".select").find(".tag_active").each(function(){
			var parent_box = $(this).parent().parent();
			setSelectValue(parent_box,$(this).attr("rel"),$(this).html());
		})
	}

	function hideBox(){
		$(".options").hide();

	}
	function resetValues(){
		$(".input").val("");
		$(".value").html($(this).attr("rel"));
		$("#query").val($("#query").attr("rel"))	
	}

	function setSelectValue(box,value,label){
		resetValues();
		$(box).find(".input").val(value);
		$(box).find(".value").html(label);		
	}

	function setEmpty(field,default_val){
		if (field.value == default_val){
			field.value = "";
		}
	}

	function setReEmpty(field,default_val){
		if (field.value == ""){
			field.value = default_val;
		}
	}

	function querySearch(){
		$(".input").val("");
		search();
	}

	function search(){
		$("#search_form")[0].submit();
	}


/*------------------------------------*/
/*  slideshow	*/
/*------------------------------------*/

	function numChildren(node){
		if (typeof node != 'undefined') {
		  if (typeof node.children == 'undefined') {
			var num = 0;
			for(elem in node.childNodes){
				if(node.childNodes[elem].nodeType == 1){
					num ++;
				};
			}
			return num;
		  }else{					
			return node.children.length;
		  }
		} 
	}


	function start_interVal(num){				

		SlideshowNext(num);
		slide_shows[num].timer = window.setInterval('SlideshowNext('+num+')', slide_time);
	}

	slideTimes = 0; 
	lastSlideFunction = "";
	function SlideshowNext(show_num){

		if (lastSlideFunction == "user"){
			clearTimeout(slide_shows[show_num].timer);
			slide_shows[show_num].timer = window.setInterval('SlideshowNext('+show_num+')', slide_time);
		}
		
		showInfo = slide_shows[show_num];

		if (showInfo.current >= showInfo.num_slides){
			showInfo.current = 0;
		}	

		tar_id = showInfo.target.id;
				
		
		$("#"+tar_id+" > img").css("z-index",1);				
		$("#"+tar_id+" :eq("+(showInfo.current-1)+")").css("z-index",14);
		if (slideTimes != 0){
			$("#"+tar_id+" :eq("+showInfo.current+")").hide();
		}
		$("#"+tar_id+" :eq("+showInfo.current+")").css("z-index",20);
		$("#"+tar_id+" :eq("+showInfo.current+")").fadeIn(slide_speed);


		//$(".image_num").css("background-color","#999999");
		//$("#image_num_"+showInfo.current).css("background-color","#000000");			

		showInfo.current ++;
		slideTimes ++;
		lastSlideFunction = "auto";
	}

	function slideShowNum(show_num,num){
		
		clearTimeout(slide_shows[show_num].timer);
		slide_shows[show_num].timer = window.setInterval('SlideshowNext('+show_num+')', slide_time_slow);
	
		showInfo = slide_shows[show_num];

		lastCurrent = showInfo.current-1;
		showInfo.current = num;

		tar_id = showInfo.target.id;
		
		$("#"+tar_id+" > img").css("z-index",1);				

		$("#"+tar_id+" :eq("+lastCurrent+")").css("z-index",50);
		$("#"+tar_id+" :eq("+showInfo.current+")").hide();
		$("#"+tar_id+" :eq("+showInfo.current+")").css("z-index",100);
		$("#"+tar_id+" :eq("+showInfo.current+")").fadeIn(slide_speed);


		//$(".image_num").css("background-color","#999999");
		//$("#image_num_"+showInfo.current).css("background-color","#000000");

		showInfo.current ++;
		lastSlideFunction = "user";

	}

