// Copyright VIEWSION.net Matthias Weiss
//
// bookmark ---------------------------------------------------------------------
function bookmarkPage(URL,Text,lang){
	if (window.sidebar){
		// firefox
		window.sidebar.addPanel(Text,URL, "");
	}else if(window.opera && window.print){
		// opera
		var elem = document.createElement('a');
		elem.setAttribute('href',URL);
		elem.setAttribute('title',Text);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(document.all){
		// ie
		window.external.AddFavorite(URL,Text);
	}else{
		if(lang){
			alert("Sorry - this feature is not supportet. Please use your browser capabilities.");
		}else{
			alert("Leider wird diese Funktion nicht direkt unterstützt. Benutzen Sie die Möglichkeiten Ihres browsers");
		}
	}
}

// Print ---------------------------------------------------------------------
function printPage(lang) {
	if (window.print){
		window.print();
	}else{
		if(lang){
			alert("Sorry - this feature is not supportet. Please use your browser for printing.");
		}else{
			alert("Leider wird diese Funktion nicht direkt unterstützt. Benutzen Sie die Druckfunktion Ihres Browsers.");
		}
	}
}

// AutoWipe Input ---------------------------------------------------------------------
function clearField(obj,def_str){
	if(obj.value == def_str){
	  obj.value = "";
	}
}
function showDefault(obj,def_str){
	if(obj.value == ""){
	  obj.value = def_str;
	}
}

// Textarea MaxLength ---------------------------------------------------------------------
function checkLen(textarea,maxLen){
	var txt=textarea.value;
	if(txt.length>maxLen){
		alert("Bitte maximal "+maxLen+" Zeichen eingeben!");
		textarea.value=txt.substring(0,maxLen);
	}
}

// Protect E-Mail ---------------------------------------------------------------------


function protMail(addr_str,dom_str,islink){
	if(islink){
	  document.write('<a href=\"mailto:' + addr_str + '@' + dom_str + '\">' + addr_str + '@' + dom_str + '</a>');
	}else{
	  document.write(addr_str + '@' + dom_str);
	}
}





// JQuery #########################################################################


$(function() {
	
	

    // JQuery TOOLS ###############################################################
	// Startseite: Slider
	if($("#start_slider_bg").length){

		
		
		var overlay = $("#start_slider_over").scrollable({ 
			api: true,
			nextPage: false,
			prevPage: false,
			size: 1,
			circular: false,
			vertical: 1,
			clickable: false
		});
		
		
		
		var onLastSlide = false;
		$("#start_slider_bg").scrollable({ 
			circular: false,
			size: 1,
			clickable: false,
			//onSeek : function() { 
				//overlay.seekTo(this.getIndex());
				//function backToBegin(i){
						
						// i.seekTo(0);
						// i.next();
				//}
				//if(this.getIndex() + 1 == this.getSize()){
					
					//alert(1);
					//window.setTimeout(backToBegin,1000,this);
					//this.circular = true;
					//this.getConf().circular = true;
					//alert(this.getConf().circular);
					//this.begin(2000);
				//}
				//alert(this.getIndex());
				
			//}
			onSeek: function(event) {
				overlay.seekTo(this.getIndex());
				if(this.getIndex() == this.getSize()-1){ 
					onLastSlide = true;	
				}
			},
			onBeforeSeek: function(event) {
				if(onLastSlide){ 
					onLastSlide = false;
					this.begin();	
				}							
			}
		});
		
		
		
		$("#start_slider_bg").navigator({
			navi:'#start_slider_nav ul'
		});
		
		$("#start_slider_bg").autoscroll({
			interval: 6500,
		});		
	};
	
	// Startseite: Tabs
	if($("#start_tabs_nav").length){
		$("#start_tabs_nav").tabs("#start_tabs_panes > div", {
			initialIndex : 0	  
						  
		});
	};
	$("body").addClass("body_bg");
	//$("#start_slider_nav > ul > li > a").addClass("first_red");
	
	
	
	
	
	// Slider (Galerie) ###############################################################	
	
	$(".slider .n").tabs(".slider .s > div", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		
		fadeInSpeed: "slow",
		fadeOutSpeed: 0,
	
		// start from the beginning after the last tab
		rotate: true
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({
		interval: 4000,
		autoplay: true,
		clickable: true
		
		});	
	
	var iDiv = $(".slider .s > div > div");
	if(iDiv){
		showiDiv = function(){
			iDiv.fadeIn();	
		}
		$(".slider .s > div > div").hide();
		var t=setTimeout("showiDiv()",500);	
	}	


	
	
	
	// Fancy Box ###############################################################
	if($("a#single_image").length){
		$("a#single_image").fancybox({
			'zoomOpacity' : true,
			'zoomSpeedIn': 400,
			'zoomSpeedOut': 400,
			'overlayOpacity': 0.7,
			'overlayColor': '#000',
			'overlayShow': true
		}); 
	}
	
	if($("a#inline800").length){
		$("a#inline800").fancybox({
			'hideOnContentClick': true,
			'overlayColor': '#000',
			'overlayOpacity': 0.7,
			'frameWidth': 800,
			'frameHeight': 600
		}); 
	}
	
	if($("a.group").length){
		$("a.group").fancybox({
			'zoomOpacity' : true,
			'overlayColor': '#000',
			'overlayOpacity': 0.7,
			'zoomSpeedIn': 400,
			'zoomSpeedOut': 400,
			'overlayShow': true
		}); 
	}
	
	if($("a.lightBox").length){
		$('a').lightBox(); // Select all links in the page
	}
	
	
	
});



