// JavaScript Document

// when input is focused remove default text
function formtext(form_element, default_value)
{
	$(form_element).focus(function(){
		if(this.value == default_value) {
			this.value = '';
		}
	});
	
	$(form_element).blur(function(){
		if(this.value == '') {
			this.value = default_value;
		}
	});		
}

// JQuery functions for hiding and showing the modal box
// if IE then do not fade

anim_speed = "normal";

(function($){
	$.fn.prozomixHide = function() {
		return this.each(function() {
			if($.browser.msie) {
				$(this).hide();
			} else {
				$(this).fadeOut(anim_speed);
			}
		});
	};
})(jQuery);

(function($){
	$.fn.prozomixShow = function() {
		return this.each(function() {
			if($.browser.msie) {
				$(this).show();
			} else {
				$(this).fadeIn(anim_speed);
			}
		});
	};
})(jQuery);


if(!("console" in window) || !("firebug" in console)) {
	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
	window.console = {};
	for (var i = 0; i <names.length; ++i)
		window.console[names[i]] = function() {};
}


$(document).ready(function(){
	
	if($('#products-spiel-inner').length > 0) {
		flash_height = $('#products-list').height() + 20;
		var so = new SWFObject("media/home-flash.swf", "products-spiel-flash", "388", flash_height, "8");
   	so.write("products-spiel-inner");
	}
									
	//$('img[@src$=.png], div.details_col').ifixpng();

	$("a.viewalignment").click(function(event){
		event.preventDefault();
		target = $(this).parent().parent().parent().children(".details_col");
		$(".modal").not(target).prozomixHide();
		target.prozomixShow();
	});
	
	$("a.viewsequence").click(function(event){
		event.preventDefault();
		target = $(this).parent().parent().children(".sequence_col");
		$(".modal").not(target).prozomixHide();
		target.prozomixShow();
	});

	$("a.closesequence, a.closealignment").click(function(event){
		event.preventDefault();
		$(this).parent().parent().parent().prozomixHide();
	});

	$("select.currencyswitch").change(function(event){
		this.form.submit();
	});

	//$(".searchby_input").attr("disabled", true);
	$("select#searchby").change(function(event){
		$(".searchby_input").hide();
		$(".searchby_input").attr("disabled", true);
		$("#searchby_"+this.value).attr("disabled", false);
		$("#searchby_"+this.value).show();
	});
	
	// Set default input values
	formtext("#sitesearch", "Search entire site...");
	formtext("#contact_name", "Name");
	formtext("#contact_email", "Email");
	formtext("#contact_message", "Your message");
	formtext("#newsletter_email", "Your email address");
	
	$('#news-archive-list').accordion({ autoHeight: false, header: '.news-archive-year', navigation: true });


	newsyear = $(document).getUrlParam("year");
	if(newsyear) {
		$('#news-archive-list').accordion("activate", '#'+newsyear);
	}

	$.localScroll({
		duration: 666,
		onBefore: function(event, target){
			$(".target").removeClass("target");
			$(target).addClass("target");
		}
	});
	
	$(".zebrastripe >:even").addClass("even");
	$(".zebrastripe >:odd").addClass("odd");

});