// JavaScript Document

	
$(document).ready(function(){
	
	$("#content_column_1 div.pflichtfeld").each(function(){
	
		if (!$(this).find("input").is(":checked"))
			$(this).css("background-color", "#FAAB01");
		else
			$(this).css("background-color",  "none");
		
	});
	
	$("#content_column_1 div.pflichtfeld").click(function(){		
		if ($(this).find("input").is(":checked"))
			$(this).css("background-color",  "white");
		else
			$(this).css("background-color", "#FAAB01");	
	});
	
});

//	--	Bildergallery
function show_div_bilder(nr)
{
	if(document.getElementById('bilder_'+ nr).style.display == 'block')
	{
		jQuery("#bilder_"+ nr).hide("slow");
		document.getElementById('btn_bild_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
		document.getElementById('btn_technik_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
		return true;
	}
	
	jQuery("#technische_details_"+ nr).hide("slow", function(){
		jQuery("#bilder_"+ nr).show("slow");
		document.getElementById('btn_bild_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
		document.getElementById('btn_technik_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_header_boxen.jpg) repeat-x";		
	});
	return true;
}

//	--	Technik
function hide_div_bilder(nr)
{
	if(document.getElementById('technische_details_'+ nr).style.display == 'block')
	{
		jQuery("#technische_details_"+ nr).hide("slow");
		document.getElementById('btn_technik_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
		document.getElementById('btn_bild_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
		return true;
	}
	jQuery("#bilder_"+ nr).hide("slow", function(){
		jQuery("#technische_details_"+ nr).show("slow");
		document.getElementById('btn_bild_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_header_boxen.jpg) repeat-x";
		document.getElementById('btn_technik_'+ nr).style.background = "url(/images/boxen_backgrounds/bg_boxen_schaltflaechen.jpg) repeat-x";
	});
	
	return true;
}

function hide_and_show_level_2(divid)
{

   var status = document.getElementById(divid);
   //alert(status);
   if(status.style.display=="block") 
   {
    document.getElementById(divid).style.display='none';
   }
   else 
   {
     document.getElementById(divid).style.display='block';
   }

   /*
   document.getElementById(divid).style.display = status;
   */
}
function abweichende_lieferanschrift(divid) 
 {
   var status = document.getElementById(divid);
   //alert(status);
   if(status.style.display=="block") 
   {
    document.getElementById(divid).style.display='none';
   }
   else 
   {
     document.getElementById(divid).style.display='block';
   }
 }

function displayRow()
{
	var row = document.getElementById("angaben_firma");
	if (row.style.display == '')
	{
		row.style.display = 'none';
	}
	else row.style.display = '';
}

function ajax_load(div)
{
	height = jQuery('#'+div).height() / 2;
	width = jQuery('#'+div).width() / 2;
	
	if (height > 60)
		height = 0;
	else
		height -= 10;

	if (width > 140)
		width = 0;
	else
		width = width - 64;
	
	jQuery("#"+div).html('<img src="http://www.mobook.de/images/verfuegbarkeit/loader.gif" style="margin-left: '+ width +'px; margin-top: '+ height +'px; display: inline;" />');
}

function verfuegbarkeit_load_result(divid, adressdaten)
{
	jQuery.post('/verfuegbarkeit_ergebnis.html',  adressdaten, function(data){
		jQuery('#'+ divid).html(data);
	});
}

function do_vf(divid, formid, onsite, iframe)
{
	data = jQuery("#"+ formid).serialize();
	
	if (onsite)
		data = data + '&onsite=1';
		
	if (iframe)
		data = data + '&iframe=1';	
		
	ajax_load(divid); 
	verfuegbarkeit_load_result(divid, data);
}

//	--	Tarif Info Boxen
jQuery(function() {
	jQuery('.mb').live('click', function(e) {
		e.preventDefault();
		var $this = jQuery(this);
		var horizontalPadding = 30;
		var verticalPadding = 30;
		
		var iFd = jQuery('<iframe frameborder="0" id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
			title: ($this.attr('alt')) ? $this.attr('alt') : 'Information',
			autoOpen: true,
			width: 605,
			height: 500,
			modal: true,
			resizable: true,
			//autoResize: true,
			hide: 'highlight',
			show: 'highlight',
			overlay: {
				opacity: 0.5,
				background: "black"
			},
			open: function(){
				$(".ui-widget-overlay").live("click", function(){
					iFd.dialog("close");
				});
			}
		}).width(610 - horizontalPadding).height(500 - verticalPadding);	        
	});
});
