function ask_first(url, fraga)
{
	var val = '';
	val = confirm(fraga);

	if(val == true)								
		document.location = url;
		
	return;		
}

var foo = null; // object
var foo2 = null; // object
var i = -650;

function doMove(digit, max) 
{			
	if(max == 100) 
	{
		if(i >= max) 
		{
			foo.style.top = '50px';
		} 
		else 
		{
			foo.style.top = parseInt(foo.style.top)+digit+'px';
			setTimeout(function(){doMove(digit,max)},1); // call doMove in 20msec
			i += digit;
		}
	}
	else 
	{
		if(i <= max) 
		{
			foo.style.top = '-650px';
			foo2 = document.getElementById('main_meny_wrapper'); // get the "foo" object	  
			foo2.style.visibility = 'visible';	  
			fadebg(0, 'hidden');
			location.reload(true);
		} 
		else 
		{
			foo.style.top = parseInt(foo.style.top)+digit+'px';
			setTimeout(function(){doMove(digit,max)},1); // call doMove in 20msec
			i += digit;
		}  
	}
}

function init() 
{
	i = -650;
	foo = document.getElementById('admin'); // get the "foo" object
	//foo.style.left = -parseInt(<?=$settings[1]?>)/2+'px';
	foo.style.top = '-650px'; // set its initial position to 0px
	//doMove(15, 100); // start animating
	foo.style.top = '100px'; 	  
	foo2 = document.getElementById('main_meny_wrapper'); // get the "foo" object
	foo2.style.visibility = 'hidden';
	fadebg(80, 'visible');
}

function exit() 
{	  
	//doMove(-15, -650); // start animating 
	foo = document.getElementById('admin'); 
	foo2 = document.getElementById('main_meny_wrapper');
	foo.style.top = '-650px';
	foo2 = document.getElementById('main_meny_wrapper'); // get the "foo" object	  
	foo2.style.visibility = 'visible';	  
	fadebg(0, 'hidden');
	location.reload(true);
	//foo = document.getElementById('admin'); // get the "foo" object
	//foo.style.top = '-650px'; // set its initial position to 0px 				  
}

function resize(rWidth, rHeight) 
{
	foo.style.width = rWidth+'px';
	foo.style.height = rHeight+'px';
	foo.style.left = -parseInt(rWidth)/2+'px';
}

function fadebg(opacity, vis) 
{	
	var opacity = opacity;
	var id = "release_me";
	var object = document.getElementById(id).style; 
	object.visibility = vis;
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")"; 			
}
function loadProduct(titel,text,price,img1,img2,img3) {
	$('#produkt_bild').html("<img id='large_image' src='images/"+img1+"' width='400' height='300' />").hide().fadeIn('slow');
	$('#produkt_titel').html(titel);
	$('#produkt_price').html(price);
	$('#produkt_text').html(text);
	$('#thumb_1').html("<img src='images/th_"+img1+"' width='50' height='50' image_link='"+img1+"'/>");
	$('#thumb_2').html("<img src='images/th_"+img2+"' width='50' height='50' image_link='"+img2+"'/>");
	$('#thumb_3').html("<img src='images/th_"+img3+"' width='50' height='50' image_link='"+img3+"'/>");
	
	$('#thumb_1, #thumb_2, #thumb_3').click(function() {
		$('#produkt_bild').html("<img id='large_image' src='images/"+$("img", this).attr('image_link')+"' width='400' height='300' />").hide().fadeIn('slow');
	});
	
	$('.produkt_thumb').click(function() {
		$('.produkt_thumb').removeClass('thumb_selected');
		$(this).addClass('thumb_selected');
	});
	
	$('.produkt_thumb').removeClass('thumb_selected');
	$('#thumb_1').addClass('thumb_selected');
}
$(document).ready(function(){
	$("ul.dropdown li").dropdown();
});
$.fn.dropdown = function() {
	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible').hide().fadeIn('slow');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});
}
