function f(){

}

function aivao_sendform(){

}

function aivao_rnd(){ return String((new Date()).getTime()).replace(/\D/gi,'') }

function aivao_close_pop(options){
	$(options["box"]).slideUp(500, function(){
		$("#pop").hide();
		$(options["box"]+" > .content").empty();
	});
	
}

//-------------------------------- XXXXXXXXXXXX

function aivao_close_popalert(){
	$("#pop > .alert").hide();

	if($.browser.name == "msie" && $.browser.version < 7){
		$("#pop_register").find("select").each(function(){
			$(this).show();
		});
		$("#pop_register").find("input").each(function(){
			$(this).hide();
			$(this).show();
		});
	}
	$("#pop > .alert > .alerttxt > .feedback").empty();
	var keep = false;
	$("#pop").find("div").each(function(){
		if($(this).is(":visible") && !$(this).is(".pop_bg")){
			keep = true;
		}
	});
	if(!keep){
		$("#pop").hide();
	}
}

//-------------------------------- XXXXXXXXXXXX

function aivao_show_pop(){
	$(".pop_bg").css({ 
		"top" : "0"
	});
	$("#pop").css({ 
		"top" : $(window).scrollTop()+"px"
	});

	$("#pop").show();
}



//-------------------------------- XXXXXXXXXXXX

function aivao_alert(options){
	var h = 152;
	$("#alert .content .ok").hide();
	if(options["okbutton"]){
		$("#alert .content .ok").show();
	}
	$("#alert .content .feedback").html(options["feedback"]);
	var posi =  Math.round(($(window).height()/2)-(h/2));
	if(posi < 10){
		posi = 10;
	}
	$("#alert .content").css({ 
		"top" : posi+"px"
	});
	$("#alert").fadeIn(100);
}


//-------------------------------- XXXXXXXXXXXX

function aivao_close_alert(){
	
	$("#alert").fadeOut(100, function(){
		$("#alert .content .feedback").html("");
	});
	
}

function aivao_close_register_alert(){
	
	$("#pop_register").find(".alert").fadeOut(300, function(){
		
	});
	
}

function my_checkempty(mandatory) {

	for(n=0;n<mandatory.length;n++){
		if($("#"+mandatory[n]).val() == ""){
			return false
		}
	}
	 return true					
}

function aivao_checkmail(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length-1
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	    return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}
	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	 if (str.indexOf(" ")!=-1){
		return false
	 }
	 return true					
}


function aivao_datestring(options){
	var day = String(options["date"].getDate());
	if(day.length < 2){
		day = "0"+day;
	}
	var month = String(options["date"].getMonth()+1);
	if(month.length < 2){
		month = "0"+month;
	}
	str = day+"."+month+"."+options["date"].getFullYear();
	return str;
}
function aivao_timestring(options){
	var hours = String(options["date"].getHours());
	if(hours.length < 2){
		hours = "0"+hours;
	}
	var minutes = String(options["date"].getMinutes());
	if(minutes.length < 2){
		minutes = "0"+minutes;
	}
	var seconds = String(options["date"].getSeconds());
	if(seconds.length < 2){
		seconds = "0"+seconds;
	}
	str = hours+":"+minutes+":"+seconds;
	return str;
}


function aivao_navihover(options){
	//alert(options["folder"]+" "+options["active"]);
	if(options["folder"] != options["active"]){
		if(options["mode"] == "over"){
			$("#navi_li_"+options["folder"]).addClass("on");
			$("#navi_li_"+options["active"]).removeClass("on");
		}
		if(options["mode"] == "out"){
			$("#navi_li_"+options["folder"]).removeClass("on");
			$("#navi_li_"+options["active"]).addClass("on");
		}
	}
}

$(function() {
	$(window).scroll(function () { 	
		$("#alert").css({ 
			"top" : $(window).scrollTop()+"px"
		});
    });

	$("#pop_register .pop_close").click(
		function () {			
			aivao_close_pop({box:"#pop_register"});
		}
	);
	$("#pop .pop_bg").click(
		function () {			
			aivao_close_pop({box:"#pop_register"});
		}
	);

	$("#navi > ul > li > ul.anim").slideDown(600);
	/*
	$("p").sifr({
		build: 436,
    	version: 3,
		font:"sifr_corporate_lightbold",
		path:"/hanbuch/cms/js/jquery/sifr/",
		debug: true
	});
	*/
	
	$("a.link_pdf_list").each(function (){ 
		var link = $(this);
		$.post("/cms/front/ajax/filesize.php", {file:$(this).attr("href")}, function(data) {
			//alert(data["filesize"]);
			link.append(data["filesize"]);
		}, "json");
		
	});
	
	$("a").each(function (){ 
		if($(this).attr("href").indexOf("[") > -1 && $(this).attr("href").indexOf("]") > -1){
			
			var link = $(this);
			
			$.post("/cms/front/ajax/loclinks.php", {href:link.attr("href")}, function(data) {
				//alert(data["href"]);
				link.attr({"href":data["href"]});

			}, "json");
		}
		
	});
	
});
