/*********************************************************************
 * The Initial Developer of the content of this file is NETCONOMY.
 * All portions of the code written by NETCONOMY are property of
 * NETCONOMY. All Rights Reserved.
 *
 * NETCONOMY Software & Consulting GmbH
 * Lange Gasse 42 / Koeroesistrasse 38, A-8010 Graz (Austria)
 * FN 204360 f, Landesgericht fuer ZRS Graz
 * Tel: +43 (316) 815 544
 * Fax: +43 (316) 815544-99
 * www.netconomy.net
 *
 * (c) 2009 by NETCONOMY Software & Consulting GmbH
 *********************************************************************/
/*
 * created on 19.11.2009 by cwilhelmer@netconomy.net 
 * 
 * This file contains all JS functionalities which are developed by the NC-Team. 
 * 
 */

function changePagesize(size, params) 
{
location.href ='?pagesize='+size+params;
}

function increaseCounter()
{
	$(".hiddenElement:lt(3)").removeClass("hiddenElement");
	functionxy();
}
function functionxy()
{
	if ($(".hiddenElement").length == 0) {
	      $("#show_more_articles_incart").hide();
		}
}

function showCart()
{
	if ($("#open_shoppingcart_hd tr").length > 2)
	{
	$("#shoppingcart").hover(
			function(){ 
				$("#open_shoppingcart_hd").show();
				$("#shoppingCartArrow").removeClass('arrow_shoppingcart').addClass('arrow_shoppingcart_open');
			}, 
			function(){	
				$("#open_shoppingcart_hd").hide();
				$("#shoppingCartArrow").removeClass('arrow_shoppingcart_open').addClass('arrow_shoppingcart');
			}
		);
	}
}

function setDeliveryAddress(pk)
{
//get current selectedAddressField
hiddenAddressField = document.getElementById('selectedDelivery');

//check if an address is allready selected, if this is the case (uncheck this)
if(hiddenAddressField.value != '')
{  
 oldSelectedButtonField = document.getElementById('delivery_address_button_'+hiddenAddressField.value);
 oldSelectedField = document.getElementById('delivery_address_selected_'+hiddenAddressField.value);
 oldSelectedButtonField.style.display='';
 oldSelectedField.style.display='none';
}

//check the new address Field
selectedAddressButton = document.getElementById('delivery_address_button_'+pk);
selectedField = document.getElementById('delivery_address_selected_'+pk);
selectedAddressButton.style.display='none';
selectedField.style.display='';

//set the address in the new field
hiddenAddressField.value=pk;
}

$(document).ready(function(){
	functionxy();
  });

function createNewDeliveryAddress()
{
   document.getElementById("attributes'newdeliveryAddress'").value="true";
   document.forms['deliveryAddress'].submit();
}

function changeImage()
{
	url = document.activeElement.firstChild.src;
	document.activeElement.firstChild.src=document.getElementById("detailImage").src;
	document.getElementById("detailImage").src=url;
	document.getElementById("detail_zoom").getElementsByTagName("a")[0].href=url;
}

function setImage(pictureUrl,zoomUrl,showOutlineImage,infoText)
{
	document.getElementById("detailImage").src=pictureUrl;
	document.getElementById("detailImageLink").href=zoomUrl;
	document.getElementById("outlinepicture").style.visibility = (showOutlineImage==true)?"visible":"hidden";
	if(infoText){
		$("#zoomImageInfo").css("visibility","visible");
		$("#infoTextBlob").html(infoText);
		$("#detailImageLink").attr("data-infotext",infoText);
	}else{
		$("#zoomImageInfo").css("visibility","hidden");
		$("#infoTextBlob").html("");
		$("#detailImageLink").attr("data-infotext","");
	}
}

function showZoomImageInfoBlob(){
	$("#zoomImageInfo").hover(
		function(){$("#zoomImageInfoBlob").show();}, 
		function(){$("#zoomImageInfoBlob").hide();}
	);
}

function PrintMaskedEmailLink(email, domain, text, title) 
{
  document.write('<a href="&#109;&#097;&#105;&#108;&#116;&#111;&#058;');
  document.write(email + '&#064;' + domain);
  if(title && title.length > 0){
	document.write('" title="' + title);  
  }
  document.write('">');
  if (text && text.length > 0)
  {
    document.write(text);
  }
  else
  {
    document.write(email + '&#64;' + domain);
  }
  document.write('</a>');
}

function escapeYahooTrackingTitle(title)
{
	var forbiddenCharakters = ["<",">","#","&",";",":","?","-","*","~","´","`",")","(","=","%","!","\""];
	for ( var i = 0; i < forbiddenCharakters.length; i++) {
		title = title.replace(forbiddenCharakters[i]," ");
	}
	title = title.replace(/\s+/, " ");
	return title;
}

function showRecaptcha(element, publiccode, options) {
	Recaptcha.destroy();
	Recaptcha.create(publiccode, element, options)
}

function removeRecaptcha(){
	Recaptcha.destroy();
}

function makeCallbackBoxBigger() {
	var open_contact_tel_act = document
			.getElementById("open_contact_tel_act");
	open_contact_tel_act.style.height = "720px";
}

function makeCallbackBoxSmaller() {
	var open_contact_tel_act = document
			.getElementById("open_contact_tel_act");
	open_contact_tel_act.style.height = "665px";
}

