var theTarget = "";
var theHref = location.href;
var x = theHref.lastIndexOf("/");
var but = new Array;
var zmap = 0;
var theLanguages = new Array("lv","en");

for(i = 0; i < 5; i++)
	{
	but[i*3] = new Image;
	but[i*3].src = "images/buttons/" + lang + "/" + (i+1) + "1.gif";
	but[1+(i*3)] = new Image;
	but[1+(i*3)].src = "images/buttons/" + lang + "/" + (i+1) + "2.gif";
	but[2+(i*3)] = new Image;
	but[2+(i*3)].src = "images/buttons/" + lang + "/" + (i+1) + "3.gif";
	}

function hiBut(b,c)
	{
	theBut = new Image;
	theBut.src = but[3*(b-1)+c].src;
	document.images["b"+b].src = theBut.src
	}

function hiLite(a,d)
	{
	myBut = new Image;
	myBut.src = "images/buttons/" + lang + "/" + a + (d+1) + ".gif";
	document.images["a"+a].src = myBut.src
	}

function switchLanguage()
	{
	//alert("This language isn't available yet!");
	document.location = theTarget;
	}

function displayTarget(myTarget)
	{
	if (myTarget == 9)
		{
		theTarget = "";
		}
	else
		{
		theTarget = theHref.substring(0,(x-2)) + theLanguages[myTarget] + theHref.substring(x,theHref.length);
		}
		
	window.defaultStatus = theTarget;
	}

function zoomMap()
	{
	zmap = (zmap - 1) * -1;
	theMap = new Image;
	theMap.src = "images/main/lkc_karte" + zmap + ".gif";
	document.images["mp"].src = theMap.src;
	}

function aboutPic(e)
	{
	thePic = new Image;
	thePic.src = "images/main/lkc_about" + e + ".jpg";
	document.images["about"].src = thePic.src;
	}


//Sample scripts for order form

function setLabel(id, newTxt)
	{
	var elem;
	if( document.getElementById  && (elem=document.getElementById(id)) )
		{
		if( !elem.firstChild )
			{
			elem.appendChild( document.createTextNode( newTxt ) );
			}
		else
			{
			elem.firstChild.data = newTxt;
			}
		}
	return false; 
	}

var orderFormName = "orderform";

function setType(thisElement, newType)
	{
	if (!newType)
		{
		return -1;
		}
	if (newType == "")
		{
		return -1;
		}
	eval("document." + orderFormName + "." + thisElement + ".type = newType;");
	return true;
	}

function changeOption(selectName,optionNum,optionText)
	{
	optionNum = optionNum - 1;
	if (optionText == "")
		{
		eval("document." + orderFormName + "." + selectName + ".remove(" + optionNum + ");");
		}
	else
		{
		eval("document." + orderFormName + "." + selectName + ".options[" + optionNum + "] = new Option('"+ optionText +"'," + (optionNum+1) + ");");
		}
	eval("document." + orderFormName + "." + selectName + ".selectedIndex = 0;");
	return true;
	}

function changeShipmentOptions()
	{
	//orderform.adresvalsts
	document.orderform.piegVeids.options.length = 0;
	document.orderform.apmaxVeids.options.length = 0;
		
	if (document.orderform.adresvalsts.selectedIndex == 0)
		{
		changeOption('piegVeids',1,'Pa pastu');
		changeOption('piegVeids',2,'LKC birojā, Dzirnavu ielā 135 (bez maksas)');
		
		if (document.orderform.uznnostext.type == 'text')
			{
			changeOption('piegVeids',3,'Bezmaksas piegāde Rīgā (min. pasūtījums LVL 50)');
			}

		changeOption('apmaxVeids',1,'Pēcapmaksa pastā');
		changeOption('apmaxVeids',2,'Pārskaitījums uz banku');
		}
	else
		{
		changeOption('piegVeids',1,'Piegāde uz ārzemēm pēc savstarpējas vienošanās');	
		changeOption('apmaxVeids',1,'Pārskaitījums uz banku');
		}
	}

function changePaymentOptions()
	{
	//orderform.piegVeids
	if (document.orderform.adresvalsts.selectedIndex == 0)
		{
		document.orderform.apmaxVeids.options.length = 0;

		if (document.orderform.piegVeids.selectedIndex == 0)
			{
			changeOption('apmaxVeids',1,'Pēcmaksa pastā');
			changeOption('apmaxVeids',2,'Pārskaitījums uz banku');
			
			setLabel('demo1', '7,08'); setLabel('demo1', '10,15');
			setLabel('demo3', '3741,85'); setLabel('demo4', '5345,50');
			setLabel('demo5', '570,79'); setLabel('demo6', '815,42');
			setLabel('demo7', '3171,06'); setLabel('demo8', '4530,08');
			}
		else
			{
			setLabel('demo1', '0,00'); setLabel('demo2', '0,00');
			setLabel('demo3', '3200,85'); setLabel('demo4', '5125,50');
			setLabel('demo5', '523,16'); setLabel('demo6', '806,38');
			setLabel('demo7', '2975,82'); setLabel('demo8', '4418,08');			
			}

		if (document.orderform.piegVeids.selectedIndex == 1)
			{
			changeOption('apmaxVeids',1,'Skaidrā naudā');
			changeOption('apmaxVeids',2,'Pārskaitījums uz banku');
			}

		if (document.orderform.piegVeids.selectedIndex == 2)
			{
			changeOption('apmaxVeids',1,'Pārskaitījums uz banku');
			changeOption('apmaxVeids',2,'Skaidrā naudā, saņemot preci');
			}			
		}
	}


function updateBasket()
	{
	x = "Māla podiņa nosaukums: Pasūtījumam pievienoti " + document.basket_form.skaits.value + ". gab.";
	setLabel('pasinfo', x);
	}

//Scripts by Silvestrs Usins, (C) 2007-8
