function calculatePrice(attributeId, optionId)
{
	var newPrice = parseFloat(productPriceNormal);

	attributeData.each(function(oData, oIndex) {
		if(oData["attribute"] == attributeId)
		{
			attributeData[oIndex]["active"] = false;
		}
	});
	
	attributeData.each(function(oData, oIndex) {
		if(oData["option"] == optionId && oData["attribute"] == attributeId)
		{
			attributeData[oIndex]["active"] = true;
		}
		
		if(attributeData[oIndex]["prefix"] == '+' && attributeData[oIndex]["active"] == true)
		{
			newPrice += parseFloat(attributeData[oIndex]["price"]);
		}
		else if(attributeData[oIndex]["prefix"] == '-' && attributeData[oIndex]["active"] == true)
		{
			newPrice -= parseFloat(attributeData[oIndex]["price"]);
		}
	});
	newPrice = newPrice*$('qty_field').value;
	
	newPrice = Math.round(newPrice*20)/20;
	
	newPrice = newPrice+"";

	if(!newPrice.match(/\./))
		newPrice = newPrice+".00";
	
	if(newPrice.match(/\..$/))
		newPrice = newPrice+"0";
	
	if(newPrice.length > 6)
		newPrice = newPrice.substr(0, newPrice.length-6)+"'"+newPrice.substr(newPrice.length-6, 6);
	
	newPrice = "CHF "+newPrice.substr(0, newPrice.length-3)+","+newPrice.substr(newPrice.length-2, 2);
	
	
	$('priceField').update(newPrice);
}


function showPrice1(form)
{
	var currencysymbol1 = "";
	var currencysymbol2 = "";
	var myTotalPrice = 0;
	var showUP = 0;
	var myMathProblem = "";
	myItemPrice = parseFloat(form.nuPrice1.value);
	
	myDollarSign2 = form.nuPrice1.value.indexOf("EUR",0)
	if ( myDollarSign2 != "-1" )
	{
		currencysymbol1 = "";
		currencysymbol2 = " EUR";
	} else {
		currencysymbol1 = "$";
		currencysymbol2 = "";
	}

	for (var i = 0; i < form.elements.length; i++)
	{
		var e = form.elements[i];
		if ( e.type == 'select-one' )
		{
			showUP = 1;
			Item = e.selectedIndex;
			myPrice = e.options[Item].text;
			myDollarSign = myPrice.indexOf("$",0)
			if ( myDollarSign != "-1" )
			{
				currencysymbol1 = "$";
				currencysymbol2 = "";
				myParSign = myPrice.indexOf(")", myDollarSign);
				myAttributeString = myPrice.substring(myDollarSign+1, myParSign);
				myAttributeString = myAttributeString.replace(/,/,"");
				myAttributePrice = parseFloat(myAttributeString);
				myMathProblem = myPrice.charAt(myDollarSign - 1);
			} else {
				myDollarSign1 = myPrice.indexOf("(",0)
				if ( myDollarSign1 != "-1" )
				{
					currencysymbol1 = "";
					currencysymbol2 = " EUR";
					myParSign = myPrice.indexOf(")", myDollarSign1);
					myAttributeString = myPrice.substring(myDollarSign1+1, myParSign);
					myAttributeString = myAttributeString.replace(/,/,"");
					myAttributePrice = parseFloat(myAttributeString);
					myMathProblem = myPrice.charAt(myDollarSign1 - 1);
				} else {
					myAttributePrice = 0;
				}

			}
			if (myMathProblem == "-")
			{
				myTotalPrice = myTotalPrice - myAttributePrice;
			} else {
				myTotalPrice = myTotalPrice + myAttributePrice;
			}
		}
	}
	if ( showUP )
	{
		myDollarSign3 = form.nuPrice1.value.indexOf(".",0)
		if ( myDollarSign3 != "-1" )
		{
			myTotalPrice = FormatNumber(myTotalPrice + myItemPrice);
		} else {
			myTotalPrice = FormatNumber1(myTotalPrice + myItemPrice);
		}
		document.getElementById("productNEWprice1").innerHTML = currencysymbol1 + myTotalPrice + currencysymbol2;
	}
}

function getCookie(name)
{  
	var dc = document.cookie;  
	var prefix = name + "=";  
	var begin = dc.indexOf("; " + prefix);  
	if (begin == -1)
	{    
		begin = dc.indexOf(prefix);
		if (begin != 0)
			return null;
	}
	else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);  
	if (end == -1)
		end = dc.length;  
	return unescape(dc.substring(begin + prefix.length, end));
} 

function setCookie (name, value)
{  
	var curCookie = name + "=" + escape(value)+"; path=/";  
	document.cookie = curCookie;  
}

if(getCookie('XTCJS') == null)
{
	var arr = new Array('');
	setCookie('XTCJS', arr.toJSON());
}

var last_tab = 'tab_desc';
var last_box = 'box_desc';

function changeTab(tab_id, box_id)
{
	if(last_tab != false)
	{
		$(last_tab).removeClassName('checkoutTabCurrent');
		$(last_tab).addClassName('checkoutTab');
		$(last_box).removeClassName('tabbox');
		$(last_box).addClassName('tabboxNoDisplay');
	}
	$(tab_id).removeClassName('checkoutTab');
	$(tab_id).addClassName('checkoutTabCurrent');
	$(box_id).removeClassName('tabboxNoDisplay');
	$(box_id).addClassName('tabbox');
	last_tab = tab_id;
	last_box = box_id;
	setTabCookie(product_id, tab_id, box_id);
	//alert(getCookie('XTCJS').evalJSON().inspect());
	return false;
}

function getTabCookieValue(pid)
{
	var infoArr = getCookie('XTCJS').evalJSON();
	var result = null;
	infoArr.each(function (s, index) { if(s[0] == pid) result = index; });
	if(result == null)
		return null;
	
	return infoArr[result];
}

function getTabCookie(pid)
{
	var infoArr = getCookie('XTCJS').evalJSON();
	var result = null;
	infoArr.each(function (s, index) { if(s[0] == pid) result = index; });
	return result;
}

function setTabCookie(pid, tab_id, tab_box)
{
	var infoArr = getCookie('XTCJS').evalJSON();
	var i = getTabCookie(pid);
	if(i == null)
		i = infoArr.length; 
	
	infoArr[i] = new Array(); 
	infoArr[i][0] = pid; 
	infoArr[i][1] = tab_id; 
	infoArr[i][2] = tab_box; 
	
	setCookie('XTCJS', infoArr.toJSON());
}

function infowindow(id)
{
	$(id).toggle();
}

boxlist = new Array();
var index = 0;
function infowindow_p(id_box, id_link)
{
	boxlist[index] = new Array();
	boxlist[index][0] = id_link;
	boxlist[index][1] = id_box;
	index++;
	$(id_link).observe('mouseover', toogleBox);	
}

function toogleBox(e)
{
	var element = Event.element(e);
	var id_box = searchForLinkId(element.id);
	$(id_box).setStyle({left: (Event.pointerX(e)+3)+'px', top: Event.pointerY(e)+'px'});
	$(id_box).show();
}

function searchForLinkId(id_link)
{
	for(var i = 0; i < index; i++)
	{
		if(boxlist[i][0] == id_link)
			return boxlist[i][1];
	}
	return false;
}


function checkStandart(element, value)
{
	if(value == element.value)
	{
		element.value = '';
	}
}

var selected;
var submitter = null;

function submitFunction() {
    submitter = 1;
}
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}  
var win_width = 150;
var win_height = 150;
function popupWindowImage(url, win_width, win_height) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+win_width+',height='+win_height+',screenX=100,screenY=100,top=100,left=100')
}  


function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.getElementById('payment'[0])) {
    document.getElementById('payment'[buttonSelect]).checked=true;
  } else {
    //document.getElementById('payment'[selected]).checked=true;
  }
}


function selectRowEffectPrototype(object, buttonSelect, radioId) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

document.getElementById(radioId).setAttribute('checked', 'checked', 0);
  

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.getElementById('payment'[0])) {
    document.getElementById('payment'[buttonSelect]).checked=true;
  } else {
    //document.getElementById('payment'[selected]).checked=true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function popupImageWindow(url) {
  window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

