function addProduct(productname){
	outputText = '';
	var sendButton = '<a  href="#" onclick="showContact();return false">send</a>';
	var deleteButton = '<div id="delete-button" onmousedown="deleteProductList()"></div>';
	var introText = contact_tag+"\n";
	if($.cookie('existingList') != null){
		existingList = $.cookie('existingList')+productname+',\n';
		$.cookie('existingList', existingList);
		$('#contact-body').val(existingList);
	}else{
		$.cookie('existingList', introText+','+productname+',\n');
		$('#contact-body').val(introText+productname+',');
	}
	outputArray = $.cookie('existingList').split(",");
	$("#estimate-data-container").css('border-width','1px');
	$('#contact-form-subject').val('Product Query');
	for(i = 0;i < outputArray.length;i++){
		outputText += outputArray[i]+'<br />';
	}
	$("#estimate-data-container").html(outputText+sendButton+deleteButton);
	return false;
}
function showContact(){
	$(".pageCover").show();
	$("#contact-form-container").fadeIn("fast");
	return false;
}
function deleteProductList(){
	$.cookie('existingList',null);
	$("#estimate-data-container").html('');
	$("#estimate-data-container").css('border-width','0px');
	$('#contact-body').val(' ');
	$('#contact-form-subject').val('Webkontakt');
}
ruggedProducts = 5;
tempestAProducts = 9;
tempestBProducts = 5;
sliderProducts = ruggedProducts + tempestAProducts + tempestBProducts;
$(document).ready(function(){
	if($.cookie('existingList') != null){
		$('#contact-body').val($.cookie('existingList'));
	}
	tabCounter = 0;
	$(".button").click(function(){
		if( $(this).hasClass("prev") ){
			tabCounter--;
			if(tabCounter < 0){tabCounter = sliderProducts};		
		}else if( $(this).hasClass("next") ){
			tabCounter++;
			if(tabCounter > sliderProducts){tabCounter = 0};
		}
		if((tabCounter >= 0) && (tabCounter < ruggedProducts)){
			$(".tabs li").removeClass("active");
			$(".0").addClass("active");
		}
		if((tabCounter >= ruggedProducts) && (tabCounter <= (tempestAProducts+ruggedProducts))){
			$(".tabs li").removeClass("active");
			$("."+ruggedProducts).addClass("active");
		}
		if(tabCounter > (tempestAProducts+ruggedProducts)){
			$(".tabs li").removeClass("active");
			$("."+(tempestAProducts+ruggedProducts)).addClass("active");
		}
	});

	        /* btnGo:[".tabs .0",".tabs .1",".tabs .2",".tabs .3",".tabs .4",".tabs .5",".tabs .6",".tabs .7",".tabs .8",".tabs .9",".tabs .10",".tabs .11",".tabs .12",".tabs .13",".tabs .14",".tabs .15",".tabs .16",
	        	".tabs .17",".tabs .18",".tabs .19",".tabs .20",".tabs .21",".tabs .22",".tabs .23",".tabs .24",".tabs .25",".tabs .26",".tabs .27",".tabs .28",".tabs .29",".tabs .30"	        	
	        	]*/
	$(function() {
	    $("#rugged-slider").jCarouselLite({
			speed: 1000,
			circular:true,
	        btnNext: ".next",
	        btnPrev: ".prev",
	        visible: 5,
			btnGo:[".tabs .0",".tabs .1",".tabs .2",".tabs .3",".tabs .4",".tabs .5",".tabs .6",".tabs .7",".tabs .8",".tabs .9",".tabs .10",".tabs .11",".tabs .12",".tabs .13",".tabs .14",".tabs .15",".tabs .16",
	        	".tabs .17",".tabs .18",".tabs .19",".tabs .20",".tabs .21",".tabs .22",".tabs .23",".tabs .24",".tabs .25",".tabs .26",".tabs .27",".tabs .28",".tabs .29",".tabs .30"	        	
	        	]
		});
	});
	$("img").bind("click", function(){
		var thisClass = $(this).attr("class");
		if(thisClass == "product"){
		$(".product-container").show();
		$("#product-data-container").html("<div style='width:00%;text-align:center'><img src='e107_themes/cordsen/images/loader.gif' style='margin-top:50px'></div>");
		$.ajax({
                url: "ajax.php",
                data: "mode=product&productname="+this.alt,
                type: "POST",
                dataType: "html",
                success: function(data) {
                	$("#product-data-container").html(data);
                	$(".pageCover").show();
                }
            });
        }		
	});
	$("a.content,.a.product").bind("click", function(){
		var hrefQueryString = this.href.split("?");
		// var hrefQuery = hrefQueryString[1].match(/[0-9]+/)[0];
		var thisClass = $(this).attr("class");
		var thisHref = $(this).attr("href");
		$.ajax({
                url: this.href,
                data: hrefQueryString,
                type: "POST",
                dataType: "html",
                success: function(data) {
                    	if(thisClass == "content"){
                    	$("#globe-container").html(data);
                    }else if(thisClass == "product"){
                    	$(".pageCover").show();
                    	$(".product-container").show();
                    	$("#globe-container").html(data);
                    }else{
                    	self.location.href = thisHref;
                    }
                }
            });
   		return false;
	});
	
	$(".contact-link").unbind().bind("click", function(){
		$(".pageCover").show();
		$("#contact-body").attr("value","");
		$("#contact-form-container").fadeIn("fast");
		return false;
	});
	$(".close-link").bind("click", function(){
		$(".open-container,.product-container").fadeOut("fast");
		$(".pageCover").hide();
		return false;
	});
	$(".tabs li").click(function(){
		tmpId = this.id;
		tabCounter = tmpId;
		$(".tabs li").each(function (i) {
			if (this.id == tmpId) {
				$(this).addClass("active");
			} else {
				$(this).removeClass("active");
			}
		});
	});	

	$("#back-button").bind("click", function(){
		history.back(1);
		return false;
		});


	$(".language").bind("click", function(){
		var langval = this.id;
		$("#languagefield").attr("value", langval); 
		document.forms["languageform"].sitelanguage.value=langval;
		document.languageform.submit();
		});
	
	$(".product-overview div").hover(function() {
	       $(this).fadeTo("fast",1);
		}, 
	      function () {
        	$(this).fadeTo("fast",.6);
		});
	$('#rugged-slider ul').css('visibility','visible');	 		

});