// JavaScript Document

// MENUTHINGS
function showTheH(which) {
//    $('close-'+which).hide();
//	animatedcollapse.show('expand-'+which);
//	animatedcollapse.hide('close-'+which);
//    animatedcollapse.show('sec-'+which);
}
function hideTheH(which) {
//    $('expand-'+which).hide();
//	animatedcollapse.hide('expand-'+which);
//	animatedcollapse.show('close-'+which);
//    animatedcollapse.hide('sec-'+which);
}
// END MENUTHINGS

//new submenu

sfHover = function() {
	var sfEls = document.getElementById("subMenu_nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// ende new submenu

jQuery(function($) {
	$.fn.search = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	$("#s").search();
});

function fade(div_id, div_id2, button) {
	$('#'+div_id).fadeOut('slow');
	$('#'+div_id2).fadeIn('slow');
	$('#'+div_id+'_menu').fadeOut('fast');
	$('#'+div_id2+'_menu').fadeIn('fast');
}

/* l300 */
$(document).ready(function(){
/*
	$("#sidebar img").easyTooltip();
	$("#footer-content img").easyTooltip();
	$("#product-footer .content a").easyTooltip();
	$(".title").easyTooltip();
	
	$('.main-image').nivoSlider({
		effect:'fade',
		slices:1,
		animSpeed:300,
		pauseTime:6000,
		directionNav:false, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false //Use thumbnails for Control Nav
	});				
*/
	
	$('.expand-panel').click(function(e){
		e.preventDefault();
		$(this).parent().find('.slide-entry').slideToggle();		
	});
	
	$('.expand-klicker').click(function(e){
		e.preventDefault();
		$(this).parent().find('.slide-entry').slideToggle();		
	});
	
	$(".expand-panel").toggle(function(){
		$(this).parent().find('.expand-klicker').addClass("expanded");
		}, function() {
		$(this).parent().find('.expand-klicker').removeClass("expanded");		
	});

	$(".expand-panel").toggle(function(){
		$(this).parent().find('.close-klicker').addClass("expanded-closed");
		}, function() {
		$(this).parent().find('.close-klicker').removeClass("expanded-closed");		
	});
	
	$(".expand-arrow").toggle(function(){
		$(this).addClass("expanded");
		}, function() {
		$(this).removeClass("expanded");		
	});			

})
/* //l300 */
/* fancy */
$(document).ready(function() {

	/* This is basic - uses default settings */
	/* changed to class from id */
	$("a.single_image").fancybox();
	
	/* Using custom settings */
	
	$("a.iframe").fancybox({
		'hideOnContentClick': false /*true*/
	});

/* own_4_print window */
	$("a.iframe_small").fancybox({
			'hideOnContentClick': false,
			'autoDimensions'	: false,
			'width'         		: 580,
			'height'        		: 300,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'none'
		});
		
	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
/*new 111107*/
	$("a.groupbookarticle").fancybox({
		'hideOnContentClick': false,
			'autoDimensions'	: false,
			'width'         		: 700,
			'height'        		: 350,
			'transitionIn'		: 'fadeIn',
			'transitionOut'		: 'fadeOut'
		});
});



function setTheValue(theValue) {
	var frm = document.getElementById('get_in_touch_form');
	var hiddfield = document.getElementById('sort_to_send');
	hiddfield.setAttribute('value',theValue);
}

function setcontactFormType(theType) {
	var frm = document.getElementById('get_in_touch_form');
	var newhiddfield = document.getElementById('contact_form_type');
	newhiddfield.setAttribute('value',theType);
}

function setSelectedLi(liId){
	var currLiElem  = document.getElementById(liId);
	currLiElem.setAttribute("class","sel");
	currLiElem.setAttribute("className","sel");
}


function hidenshow(which){
	collapseAll();
	var posID = ("positive" + which);
	var negID = ("negative" + which);

	var theValue = which;
	setTheValue(theValue);
	
	if(which){
		LiElem = ("LiElem" + which);
		setSelectedLi(LiElem);
	}

	//if (document.images[negID].style.display)
	//	{
	//	show = (document.images[posID].style.display == 'none') ? 'inline' : 'none';
	//	document.images[posID].style.display = show;
	//	show = (document.images[posID].style.display == 'none') ? 'inline' : 'none';
	//	document.images[negID].style.display = show;
	//	}
		
	if(which == '5') {
		document.getElementById('the_send_form').style.display = 'none';
		document.getElementById('the_on_site_img').style.display = 'block';
	}
	else{
		document.getElementById('the_send_form').style.display = 'block';
		document.getElementById('the_on_site_img').style.display = 'none';
	}
		
	if(which > '3'){
		
		if(document.getElementById('bookingrow').style.display == 'inline') {
			document.getElementById('bookingrow').style.display = 'none';
		}
		else{
			document.getElementById('bookingrow').style.display = 'none';
		}
		
	}
	else{
		
		if(document.getElementById('bookingrow').style.display == 'none') {
			document.getElementById('bookingrow').style.display = 'inline';
		}
		else{
			document.getElementById('bookingrow').style.display = 'inline';
		}
		
	}
	
	setcontactFormType(which)
	

/*
##############################################################
ContactPage: "cntct_bookin" (1), "cntct_debook" (2), "cntct_protect" (3),"cntct_board" (4),"cntct_tip" (5)
##############################################################
*/
	var which_block = new Array("cntct_bookin", "cntct_debook","cntct_protect","cntct_board","cntct_tip");
	sect = (which - 1);
	sect = which_block[sect];

	if (document.layers)
		{
		current = (document.layers[sect].style.display == 'block') ? 'none' : 'block';
		document.layers[sect].style.display = current;
		}
	else if (document.all)
		{
		current = (document.all[sect].style.display == 'block') ? 'none' : 'block';
		document.all[sect].style.display = current;
		}
	else if (document.getElementById)
		{
		vista = (document.getElementById(sect).style.display == 'block') ? 'none' : 'block';
		document.getElementById(sect).style.display = vista;
		}
	//footerPosition();
	}

function collapseAll(){
	var which_block = new Array("cntct_bookin", "cntct_debook","cntct_protect","cntct_board","cntct_tip");
	for (var i=0; i<5; i++){
		var item = which_block[i];
		if (document.getElementById(item)){
			if (document.layers)
				{
				if (document.layers[item].style.display == 'block') { document.layers[item].style.display = 'none'; }
				}
			else if (document.all)
				{
				if (document.all[item].style.display == 'block') { document.all[item].style.display = 'none'; }
				}
			else if (document.getElementById)
				{
				if (document.getElementById(item).style.display == 'block') { document.getElementById(item).style.display = 'none'; }
				}
			}

		j = i + 1;
		var posID = ("positive" + j);
		var negID = ("negative" + j);
		
		var liID = ("LiElem" + j);
		if(document.getElementById(liID))
		{
			var currLiElem  = document.getElementById(liID);
			currLiElem.setAttribute("class","nada");
			currLiElem.setAttribute("className","nada");
		}
				
		if (document.images[negID])
			{
			if (document.images[negID].style.display == 'inline') {
				document.images[posID].style.display = 'inline';
				document.images[negID].style.display = 'none';
				}
			}

		}
	}

// function_for_changing_backgrounds on contactpage

	function change_background(which,what){
		var myBgField = document.getElementById(which);
		myBgField.className= what + '_selected';
	}
	
	function change_background_back(which,what){
		var myBgField = document.getElementById(which);
		myBgField.className= what;
	}

// ende function_for_changing_backgrounds


function close_notif() {
	document.getElementById('user_notification').style.display = "none";
}
function close_pop_notif() {
	document.getElementById('user_pop_notification').style.display = "none";
}

function pop_upp(url,width,height)
{
	newWin = window.open(url, "PopUp",'width='+ width +',height='+ height +',toolbar=0,menubar=0,location=0,scrollbars=1,resizable=1,top=10,left=10');
	newWin.focus();
}

function MM_openBrWindow(theURL,windowName,features) { //v1.2
	window.open(theURL,windowName,features);
}


function makePopUpLink(imgSrc,linktitle)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;
	document.write ("<a href=javascript:pop_upp('"+imgSrc+"','");
	document.write (width+20);
	document.write ("','");
	document.write (height+20);
	document.write ("') title='");
	document.write (linktitle);
	document.write ("'>");
}

//function wait_for_response()
//{
//	//document.getElementById("gonext_button").disabled=true;
//	document.getElementById("gonext_button").style.display='none';
//	document.getElementById("nogo_button").style.display='block';
//}

/*
new to enable/disable buttons // from musicals dev
*/
function go_back_to_link(element_to_disable,element_to_enable)
{
	document.getElementById(element_to_disable).style.display='block';
	document.getElementById(element_to_enable).style.display='none';
}


function wait_for_response(element_to_disable,element_to_enable)
{
	//document.getElementById("gonext_button").disabled=true;
	document.getElementById(element_to_disable).style.display='none';
	document.getElementById(element_to_enable).style.display='block';
	setTimeout(function(){ go_back_to_link(element_to_disable,element_to_enable); }, 30000);
	//splash_come();
//	disable_order_links();
}

function wait_for_order_response(element_to_disable,element_to_enable)
{
	//document.getElementById("gonext_button").disabled=true;
	document.getElementById(element_to_disable).style.display='none';
	document.getElementById(element_to_enable).style.display='block';
}
