var browser;

// make thos lovely corners
function beautify_corners()
{

	if ($.browser.msie)
	{
		$(".corners").each(function () {
	    
			var color_border = $(this).css("border-left-color");  
			var color_background = $(this).css("background-color");
			//$(this).wrapInner("<div style='background-color:" + color_background + ";' class='corner_content'></div>");
			$(this).wrap("<div style='background-color:" + color_border + ";padding:1px;' class='corner_border'></div>");
			
			$(this).corner("round 5px");
		});
	
		$(".corner_border").corner("round 5px");
		$(".corner_content").corner("round 4px");
	}
	else
	{
		$(".corners").corner("round 5px");
	}	

	$(".round").corner("round 5px");

}


$(document).ready(function()
{

// submit form after change
	$("form.direct").change( function() 
	{
		$("form.direct").submit();
	});
	
// showing up cart
	$(".cart > .details").css({display:"none"});
	
	$(".cart").hover(function(){
		$(".cart > .details").slideDown("fast");
	}, function(){
		$(".cart > .details").slideUp("fast");
	});

	beautify_corners();
	
	$("div").each(function () {
	//	$(this).css({"border":"1px red solid"});  
	});

// gallery
	$("a[@rel*=gallery]").lightBox();

	
});



// show and hide tabs
function box_tabs(tabs, activate)
{
	$('div.product_info').hide();
	
	$("ul." + tabs + " > li > a").removeClass('active');
	$("a." + activate).addClass('active');
	$('div#' + activate).fadeIn();
}






function change_teaser(title, image)
{
	if (image) $(".teaser > .media").css("background-image","url('" + image + "')");
	$(".teaser > .media > .title").text(title);
}

function toggle(childid)
{
	var status = $(childid).css("display");
	if (status == "none")
	{
		$(childid).slideDown("fast");
	}
	else
	{
		$(childid).slideUp("fast");	
	}
} 

function load(position, loc)
{
		 $.post(loc,
	       	{
				"request":"xmlhttp"			
			},
	       function(data)
	       {
	       	$(position).hide();
	       	$(position).html(data);
			$(position).fadeIn("slow");
	       });
}

function product_sample()
{
	if ($(".popup_product_sample").css("display") == "block")
	{
		$('.popup_product_sample').hide();
		$('.box_outer').css({visibility:"visible"});
	}
	else
	{
		load('#load_product_sample', $('.product_sample').attr('href')); 
		$('.popup_product_sample').fadeIn('fast');
	
		jQuery.each(jQuery.browser, function(i) {
		  if($.browser.msie){
		     $('.box_outer').css({visibility:"hidden"});
		  }
		});

	}

}

function product_sample_form()
{
	var loc = "?module=product_sample&action=send";
	
	var input_name = $("#sample_name").val();
	var input_email = $("#sample_email").val();
	var input_streetname = $("#sample_streetname").val();
	var input_zipcode = $("#sample_zipcode").val();
	var input_city = $("#sample_city").val();
	var input_country = $("#sample_country").val();
	var input_telephone = $("#sample_telephone").val();
	var input_product_id = $("#sample_product_id").val();
	
	$.post(loc, {
		"request":"xmlhttp"
		, "name":input_name
		, "email":input_email
		, "streetname":input_streetname
		, "zipcode":input_zipcode
		, "city":input_city
		, "country":input_country
		, "telephone":input_telephone
		, "product_id":input_product_id
	}, function(data) 
	{
		$("#product_sample").html(data);
	});
}

function options_designs(id)
{
	//disable other options
	$(".option_design").val("");
	$(".option_design").css({borderColor:"#FFFFFF"});
	
	// enable new option
	$("#attribute_order_" + id).val("1");
	$("#attribute_show_" + id).css({borderColor:"#c3c3c3"});	
}

function attribute_order(attribute_id, option_id)
{
	//disable other options
	$(".attribute_" + attribute_id).val("");

	// enable new option
	$("#attribute_order_" + option_id).val("1");	
}



function magic_checkers(attribute_id, option_id)
{
	cur_status = $("input#attribute_option_" + option_id).attr("checked");

	//disable other options
	$("input.attribute_" + attribute_id).attr("checked","");
	
	if (cur_status == true)
	{
		// enable new option
		$("input#attribute_option_" + option_id).attr("checked", "checked");
		$("input#attribute_" + attribute_id + "_price").val($("input#attribute_option_" + option_id + "_price").val());
	}
	else
	{
		$("input#attribute_" + attribute_id + "_price").val(0);	
	}
}










