function document_write(text)
{
	document.write(text);
}

function restore_flashes() {
	var $objects_to_redraw = $j('object').parent().not('.no-redraw');
	$objects_to_redraw.each(function(){
		//alert("test");
		this.innerHTML = this.innerHTML;
	});
}

$j(function(){
	setTimeout(restore_flashes, 200);
});


function window_height () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}


$j(document).ready(function()
{
	setTimeout(place, 200);
});

function place_home_button_on_bottom()
{
	//alert($j("#white_bg").height());
	$j("#home_button").css({"top":"auto","bottom":"0"});	
	
	home_y = $j("#white_bg").height()+135;
	
	//alert($j("#white_bg").height());
	//alert($j("#home_button")[0].offsetTop);
	
	if ($j("#bottom_navi").length)
		home_y += 20;
		
	if (typeof($j("#home_button")[0]) == "undefined")
		return;
	
	if (home_y > $j("#home_button")[0].offsetTop)
	{
		$j("#home_button").css("top",home_y);
	}
	else
	{
		$j("#home_button").css({"top":"auto","bottom":"0"});	
	}

}

function place()
{

	
	
	if($j("#divContentWithBorder").length)
	{
		//alert("test");
		//alert($j("#divContentWithBorder")[0].offsetHeight);
	}
	
	if ($j("#InlineSlots2").length && typeof($j("#InlineSlots2")[0].className) != "undefined")
	{

		//place_home_button_on_bottom();
		$j(window).bind("resize",place_home_button_on_bottom);
		return;
	}
	
	if (typeof($j("#white_bg")[0]) != "undefined") 
	{
		//bg_height = $j("#white_bg")[0].offsetTop+$j("#white_bg").height();
		
		var max_y = 0;
		
		var items = $j(".BlockContainer").add("#divContentWithBorder");
		
		items.each(function()
		{
			new_height = this.offsetHeight+this.offsetTop-$j("#white_bg")[0].offsetTop;
			
			my_max_y = this.offsetHeight + this.offsetTop;
			
			if (this.id == "InlineSlots2")
			{
				//alert("test");
				
				my_max_y -= 8;
			}
			
			if (max_y < my_max_y)
			{
				//alert(this.id);
				max_y = my_max_y
			}
	
		});
		
		if ($j("#divContentWithBorder").length && $j("#divContentWithBorder").height() > max_y)
		{
			max_y = $j("#divContentWithBorder").height()+$j("#divContentWithBorder")[0].offsetTop+8;
		}
			
		
		max_y -= $j("#white_bg")[0].offsetTop;
		//alert($j("#white_bg")[0].offsetTop);
		
		//max_y -= 17;
		max_y += 8;
		
		
		if ($j('#IdbIframe').length)
		{
			max_y -= 8;
		}
		
		//alert($j(".GroupSmalls").length);
		
		if ($j(".GroupSmalls").length)
		{
			max_y +=4;
		}
		// Technologie->wenn Groupsmalls mehrzeilig ist
		//if($j(".GroupSmalls").length>0)
		//	max_y += $j(".GroupSmalls")[0].offsetHeight-120;
		
		//alert(max_y);
		if (max_y && $j("#white_bg").height() < max_y)
			$j("#white_bg").css("height",max_y);
	}
	//place_home_button();
	
	//$j(window).bind("resize",place_home_button);
}



function open_dealer_locator(language,cline,mode)
{
	var my_url = "http://dealerlocator.fischersports.com/start.php";
	//alert("test");
	
	if (language)
		my_url += "?language="+language;
		
	if (cline)
		my_url += "&cline=1";
		
	switch (mode)
	{
		case "alpine":
			my_url +="&alpine=1";
			break;
		case "nordic":
			my_url +="&nordic=1";
			break;
	}
	
	my_window = window.open(my_url,"my_window","Status=0,toolbar=0,scrollbars=0,location=0,menubar=0,resizable=yes");
	my_window.focus();
}


function open_video(video)
{
	width = 620;
	height = 412;

	var show = function(hash) {
		hash.w.fadeIn('slow', function() {
			//alert('test');
		});
	}
	
	var hide = function(hash) {
		$('#videoContainer').remove();
		$('#videoPopup').remove();
		hash.w.fadeOut('slow');
		hash.o.fadeOut('slow', function(){hash.o.remove();});
	};
	
	if (!$('#videoPopup').length)
	{
	
		var top = getScrollXY()+60;
					
		$('body').prepend('<div id=\"videoPopup\" style=\"margin-top: '+top+'px; margin-left: -'+(width/2)+'px;\"><div id=\"videoContainer\" style=\"padding: 0px; margin: 0px; background-color: black;\"></div><a class=\"jqmClose\"> </a></div>');
	}
	
	var randomNumber = (Math.round(Math.random()*1000000000));
	
	var so = new SWFObject('<?=$swf?>"&randNumber='+randomNumber, 'video_'+randomNumber, (width-2), height, '9.0', '#FFFFFF');
	so.addParam('wmode', 'transparent');
	so.addParam('scale','default');
	so.addParam('allowFullScreen', 'true');
	so.addParam('video_skin_autoHide', 'false');
	
	so.addVariable('video_source','/flash/videos/'+video);
	
		so.addVariable('video_width',(width));
	so.addVariable('video_height',(height-4));
	
	so.write('videoContainer');
	
	$('#videoPopup').jqm({onShow: show, onHide: hide}).jqmShow();

}

function as_debug(item)
{
	//alert(item);
	if ($.browser.mozilla)
	{
		console.log(item);
	}
}