function f(){
	
}


function my_checkempty(mandatory) {

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

function my_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_stepimage(options){
	//alert($("#content").find(".images").find(".slide").length);
	var n = 1;
	var l = $("#content").find(".images").find(".slide").length;
	var next = 0;
	$("#content").find(".images").find(".slide").each(function (){ 
		if($(this).is(":visible")){
			if(options["mode"] == "ff"){
				if(n<l){
					next = n;
				}
				else{
					next = 0;
				}
			}
			else{
				if(n == 1){
					next = l-1;
				}
				else{
					next = n-2;
				}
			}
		}
		n++;
	});
	aivao_changeimage({num:next});
}
function aivao_changeimage(options){
	$("#content").find(".images").find(".slide").hide();
	$("#content").find(".images").find(".slide_"+options["num"]).show();
	
	$("#content").find(".images").find(".slide_navi").find("a").removeClass("on");
	$("#content").find(".images").find(".slide_navi").find("a.a_"+options["num"]).addClass("on");
}

function aivao_changemode(options){
	$("#content").find(".mode").hide();
	$("#content").find("."+options["mode"]).show();
	$("#content").find(".nav").find("a").removeClass("on");
	$("#content").find(".nav").find("a.nav_"+options["mode"]).addClass("on");
	if(options["mode"] == "images"){
		aivao_changeimage({num:0});
	}
}

function aivao_catch_a(options){
	$("a").click(function(e){
		if($.trim($(this).attr("href")) == "#"){
		 	e.preventDefault();
		}
	});
}

var aivao_bgimgs_allowed = true;
function aivao_bgimgs(){
	var num = $(".bgimg").length;
	//alert(num);
	
	if(num > 1){
		var outnum = -1;
		var innum = -1;
		var n = 0;
		$(".bgimg").each(function(){
			if($(this).is(".bgimg_on")){
				outnum = n;
				if(n<(num-1)){
					innum = n+1;
				}
				else{
					innum = 0;
				}
			}
			n++;
		});
		n=0;
		$(".bgimg").each(function(){
			if(n==outnum){
				$(this).fadeOut(10000, function(){
					$(this).removeClass("bgimg_on");
					
				});
			}
			else if(n==innum){
				$(this).fadeIn(10000, function(){
					$(this).addClass("bgimg_on");
					aivao_startbgimgs();
				});
			}
			n++;
		});
	}
}
function aivao_startbgimgs(){
	if(aivao_bgimgs_allowed){
		var t;
		clearTimeout(t);
		t = setTimeout("aivao_bgimgs()",500);
	}
}
function aivao_stopbgimgs(){
	aivao_bgimgs_allowed = false;
}
function aivao_allowbgimgs(){
	if(!aivao_bgimgs_allowed){
		aivao_bgimgs_allowed = true;
		aivao_startbgimgs();
	}
}

$(function() {	
	$(".bgimg_on").show();
	aivao_startbgimgs();
	aivao_catch_a({});
	$(".nav_video").click(function (){ 
		aivao_stopbgimgs();
	});
	$(".nav_images, .nav_text").click(function (){ 
		aivao_allowbgimgs();
	});
	$("#navi").find("td").each(function (){ 
		$(this).hoverIntent({    
			 sensitivity: 3,
			 interval: 1,  
			 over: function(){
				$(this).find("a.sub").addClass("show");
			},
			 timeout: 50,   
			 out: function(){
				$(this).find("a.sub").removeClass("show");
			}
		});
	});
	
	
});

