
var check_auth = "/index.php?eID=shop_ajax_basket&a=3";
var shop_search_clear = "index.php?eID=shop_search_clear";
//var shop_search_clear = "/";

jQuery.noConflict();
jQuery(document).ready(function(){

	
	
//	jQuery("#item-115 a").click(function() {
	jQuery("#item-115 a").click(function() {

//		alert('#');
//		jQuery.get(shop_search_clear);
		jQuery.get('index.php?eID=shop_search_clear&rand='+Math.ceil(10000*Math.random()),
//				'',
				function(data){
//			   alert("Data Loaded: " + data);
			 });
//		window.location.href='http://fleye.dk/';
//		jQuery(this).attr("href")+'?search_clear=1'; 
//		return false;		
//		var NewLink= $(this).attr("link");
//		window.location.href = NewLink;		
		
	});	

	
	initLoginForm();
	if(screen.width < 1280) {
		small_logo();
		jQuery("#block-middle").css("top", "70px");
		jQuery("#block-bottom").css("top", "480px");
		jQuery("#deco-bg-image").css("min-height", "580px");
		// TODO: Don't work in IE6
		//jQuery("#deco-bg-image").css("height", "expression( (documentElement.clientHeight||document.body.clientHeight) < 580 ? '580px' : '' )");
		jQuery("#transparent-1").css("min-height", "580px");
		// TODO: Don't work in IE6
		//jQuery("#transparent-1").css("height", "expression( (documentElement.clientHeight||document.body.clientHeight) < 580 ? '580px' : '' )");
	}

	jQuery("#deco-bg-image img").css("width", screen.width);
});

function small_logo()
{
	var logo_link;
	if(jQuery("#header").is("div")) {
		jQuery("#header").css("top", "5px");
	}
	logo_link = jQuery("#logo").html();
	jQuery("#logo").after("<div id='logo-small'></div>");
	jQuery("#logo").remove();
	jQuery("#logo-small").html(logo_link);
}

function initLoginForm()
{
  jQuery('#item-74 a').attr('href', 'javascript:;');
  jQuery('#item-172 a').attr('href', 'javascript:;');
  
	jQuery('#item-74 a').click(function() {
		jQuery('#shop_loginForm').show();
	});
	jQuery('#shop_loginForm div.shop_popupClose a').click(function() {
		jQuery('#shop_loginForm').hide();
	});
	jQuery('#item-172 a').click(function() {
	   jQuery('#logoutForm').submit();
  });
	
	loginButton = jQuery('#shop_loginButton')
	if(loginButton.length > 0) {
		loginButton.click(function() {
			username = jQuery('#shop_loginForm #user').val();
			password = jQuery('#shop_loginForm #pass').val();
  		jQuery('#shop_loginForm .shop_response').hide();
			jQuery.post(check_auth, {'username':username, 'password':password}, function(data) {
				if(data == 1) {
					jQuery("#shop_loginForm form").submit();
				}
				else {
					jQuery('#shop_loginForm .shop_response').show();
				}
			})
		});
	}	
}