function SetInnerHTML(id, value)
{
	document.getElementById(id).innerHTML = value;
}

function Select(id)
{
	
	document.getElementById(id).checked="checked"
	
}

function SetClassName(id, value)
{
	
	document.getElementById(id).className=value;
//	alert('a'+id+'a')

//alert(document.getElementById(id).className)
}

function isEmpty(besedilo, msg)

{

	if (besedilo.value.length == 0)

	{

		alert(msg)

		//besedilo.focus()

		return false

	} 

	return true

}
function isNumber(besedilo, msg)

{

	if (isNaN(besedilo.value))

	{

		alert(msg)

		//besedilo.focus()

		return false

	} 

	return true

}



function isEmail(besedilo, msg)

{

	if (besedilo.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)

		return true;

	else

	{

		alert(msg);

		//besedilo.focus();

		return false;

	}

}



function isSelected(radio, msg)

{

  blnOK = false

  for (var intIndex = 0; intIndex < radio.length; intIndex++)

  {

    if (radio[intIndex].checked)

    {

      blnOK = true

    }

  }

  if (blnOK)

  {

    return true

  }

  else

  {

    alert(msg)

    return false

  }

}



function isEqual(prvobesedilo, drugobesedilo, msg)

{

	if (prvobesedilo.value == drugobesedilo.value)

	{

		alert(msg)

		prvobesedilo.focus()

		return false

	} 

	return true

}



function isTwoInputsEmpty(prvobesedilo, drugobesedilo, msg)

{

	if (prvobesedilo.value.length == 0 && drugobesedilo.value.length == 0)

	{

		alert(msg)

		prvobesedilo.focus()

		return false

	} 

	return true

}



function isTwoInputsFull(prvobesedilo, drugobesedilo, msg)

{

	if (prvobesedilo.value.length != 0 && drugobesedilo.value.length != 0)

	{

		alert(msg)

		prvobesedilo.focus()

		return false

	} 

	return true

}

function isComboEmpty(besedilo, selected, msg)

{

	if (besedilo.selectedIndex == selected)

	{

		alert(msg)

		//besedilo.focus()

		return false

	}

	else

	{

		return true

	}

}


var t = 0
var Width;
var height;
var title;
var Slika = new Image();
function ShowFullImage(strUrl,width,height,title)
{
	Slika.src = strUrl;	
	var aLink = document.createElement('a');
	aLink.href = strUrl;
	aLink.rel='lightbox';
	//aLink.onClick = function(){}
	//aLink.title = title;
	aLink.innerHTML = '<img src="'+strUrl+'">'

	myLightbox.start(aLink); 
	
	
}



function resizeWindow(Slika, title,width,height)
{



var ScreenH = screen.height;
var ScreenW = screen.width;
//document.write(Slika);

	
	if(window.innerWidth)
	{
	LeftPosition =(window.innerWidth-width)/4;
	TopPosition =((window.innerHeight-height)/4)-50;
	}
	else
	{
	LeftPosition =(parseInt(window.screen.width)-	width)/4;
	TopPosition=((parseInt(window.screen.height)-height)/4)-50;
	}


	attr = 'resizable=no,scrollbars=no,width=' + width + ',height=' +
	height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
	TopPosition + '';
	popWin=window.open('#', 'new_window', attr);
	popWin.document.write('<html><head><title>Slika</title></head>');
	popWin.document.write('<body id="body" style="margin:0px; padding:0px; background:#ffffff URL(/library/images/loading_popUp.gif) '+width/2+'px '+height/2+'px no-repeat;" >');
	popWin.document.write('<table id="mainTbl" style="visibility: hidden"><tr><td valign="center" align="center" ><img id="Slikca" src="'+Slika.src+'" title="'+Slika.alt+'" alt="'+title+'" onClick="self.close();"></td></tr>');
	popWin.document.write('<tr><td height="20" align="right"><input style="border:none;" type="button"  value="Zapri"  onClick="self.close();" name="close" value="Zapri okno" ></td></tr></table>');

	popWin.document.writeln('<script>');
	popWin.document.writeln('function ResizeMe()');
	popWin.document.writeln('{');
	popWin.document.write('var ScreenH = document.height;');
	popWin.document.write('var ScreenW = document.width;');	
	
	
	
	
	popWin.document.writeln('var Width = document.getElementById(\'Slikca\').width;');
	popWin.document.writeln('var Height = document.getElementById(\'Slikca\').height;');

//	popWin.document.writeln('window.moveTo(ScreenW/2-(Width+50)/2, ScreenH/2-(Height+105)/2)');
	popWin.document.write('if(document.getElementById(\'Slikca\').complete)');
	popWin.document.write('{ clearTimeout(t); ');
	popWin.document.writeln('window.resizeTo(Width +20 ,Height + 120);');
	popWin.document.write('document.getElementById(\'mainTbl\').style.visibility=\'visible\';');	
	popWin.document.write('document.getElementById(\'body\').style.background=\'none\';');	

popWin.document.write('}');

	popWin.document.write('else');
	popWin.document.write('{ t=setTimeout(\"ResizeMe()\",300); }');	

	popWin.document.write('');	

	popWin.document.writeln('}');

	popWin.document.write('');
	popWin.document.write('');
	popWin.document.write('');
	popWin.document.write('');
	popWin.document.write('');

//	popWin.document.write('');*/

	popWin.document.writeln('t=setTimeout(\"ResizeMe()\",300);');
	popWin.document.writeln('</script>');
popWin.document.writeln('</body></html>');
	
	

}


function ShowPopUp(url,title, width, height,scrollBars)
{
var ScreenH = screen.height;
var ScreenW = screen.width;
//document.write(Slika);

	
	if(window.innerWidth)
	{
	LeftPosition =(window.innerWidth-width)/2;
	TopPosition =((window.innerHeight-height)/4)-50;
	}
	else
	{
	LeftPosition =(parseInt(window.screen.width)-	width)/2;
	TopPosition=((parseInt(window.screen.height)-height)/2)-50;
	}


	attr = 'resizable=no,scrollbars='+scrollBars+',width=' + width + ',height=' +
	height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
	TopPosition + '';
	popWin=window.open(url, 'new_window', attr);
	popWin.focus();
	
}


//naročanje Ajax //



function AddToCart(ProductId) 
{
	
	if(window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		request = new ActiveXObject("Msxml2.XMLHTTP")
	}
	
	sendRequest('AddToCart.asp?ProductId='+ProductId+'&dodaj=true');
}


function sendRequest(url)
{
	//alert(Vrstica);
	request.onreadystatechange = onResponse;
	request.open("GET", url, true);
	request.send(null);
}

function checkReadyState(obj)
{
	
	
	//if(obj.readyState == 0) { document.getElementById(Koda).innerHTML = "Pošiljam zahtevek..."; } //Sending Request...
	//	if(obj.readyState == 1) { document.getElementById(Koda).innerHTML = "Nalagam odgovor..."; }  //Loading Response...
	//	if(obj.readyState == 2) { document.getElementById(Koda).innerHTML = "Odgovor naložen..."; }  //Response Loaded...
	//	if(obj.readyState == 3) { document.getElementById(Koda).innerHTML = "Pripravljen..."; } //Response Ready...
	if(obj.readyState == 4)
	{
		if(obj.status == 200)
		{
			return true;
		}
		else if(obj.status == 404)
		{
			// Add a custom message or redirect the user to another page
	//			document.getElementById(Koda).innerHTML = "Ne najdem datoteke";  //File not found
		}
		else
		{
				alert("Težava z branjem XML datoteke");  //There was a problem retrieving the XML.
		}
	}
}

function onResponse() 
{
		
	if(checkReadyState(request))
	{
		
		//alert(request.responseText);
		
		var response = request.responseXML.documentElement;
		var header = response.getElementsByTagName('header')[0].firstChild.data;
		//var description = response.getElementsByTagName('description')[0].firstChild.data;
		//var description = response.getElementsByTagName('description')[0].firstChild.data;
		//var sourceUrl = response.getElementsByTagName('sourceUrl')[0].firstChild.data;
		//
	//	document.getElementById(Koda).innerHTML = "<b>" + header + "</b>" + " ";// + description ;
		document.getElementById('Total').innerHTML = response.getElementsByTagName('description')[0].firstChild.data;
		//alert(header)
		DrawAlert(header);
	}
}
var moz=(document.getElementById&&!document.all)?1:0;


function CheckInput(element)
{
	
	//alert(element.type)
	if(element.type != undefined || element.type != null)
	{
		if(element.type == "text")
			ShowTextAlert(element);		
		if(element.type == "radio")
			ShowRadioAlert(element);
		if(element.type == "checkbox")
			ShowCheckBoxAlert(element);

		if(element.type == "textarea")
			ShowTextAlert(element);

	}
	
}

function ShowTextAlert(element)
{
	
	if(element.attributes.getNamedItem('AlertText') != undefined!= undefined)
			alert(element.attributes.getNamedItem('AlertText') .value);
	else
			alert('Izpolnite polje!');
	element.focus();
	
	
}

function ShowRadioAlert(element)
{
	
	
}
function ShowCheckBoxAlert(element)
{
	
	
}



function SetFlash(Id,Url, Width, Height)
{
	var so = new SWFObject(Url, "sendmovie", Width, Height, "6", "#ffffff");
	so.addParam("wmode","transparent");
	so.write(Id);	
	
	return 0;
	
}

/* formatiranje ?tevilk v znesek */

function FormatMoney(input, decimal)
{
  var strMoney, strMoneyPare, strFormattedMoney, strMoneyDiv, strMoneyMod, strSto,intMoneyLength,strInteger;
	var Money,i,j,k;
	//alert(input.value)
	if(isNaN(input) || input =='' || input == undefined)
		input = 0;
	
	Money = input;

	intMoneyLength = Money.length;
  	strInteger = new String("");
  for (intIndex=0; intIndex<intMoneyLength; intIndex++)
  {
   
   if (Money.substring(intIndex,intIndex+1) == ",") Money = Money.replace(/,/,".");

  }
	
	Money = parseFloat(Money);
//alert(Money);
	
//alert(Money)	;
	Mio=Money/1000000;
	Mio = parseInt(Mio);
	Money = Money -Mio*1000000;
	Tisoc = parseInt(Money /1000);
	Money = Money -Tisoc*1000;
	Sto = parseInt(Money);
	Money-=Sto;
	Money*=100;
	Money=Math.round(Money);
	//Sto =Sto.slice(1,5)

strFormattedMoney = Mio+'+'+Tisoc+'+'+Sto;


if(Mio>0)
{
	
	if(Tisoc<100) 
	{
		strFormattedMoney = Mio+'.0'+Tisoc;
		if(Tisoc<10)
		{
			 strFormattedMoney = Mio+'.00'+Tisoc;
			 if(Tisoc == 0) strFormattedMoney = Mio+'.000';
		}
	}
	else strFormattedMoney = Mio+'.'+Tisoc;
	//alert(Sto);
	
	if (Sto < 100)
	{
		strSto = '.0'+Sto;
		if (Sto < 10) strSto = '.00'+Sto;
		{
			if(Sto < 1) strSto = '.000';
		}
	}
	else strSto = '.'+Sto
	strFormattedMoney += strSto;
}
if(Mio<1)
{
	if(Tisoc == 0) strFormattedMoney ='';
	else strFormattedMoney = Tisoc;

	if (Sto < 100 &&Tisoc >0)
	{
		strSto = '.0'+Sto;
		if (Sto < 10) strSto = '.00'+Sto;
		{
			if(Sto < 1) strSto = '.000';
		}
	}
	else
	{ 
	if (Tisoc == 0) strSto = Sto;
	else strSto = '.'+Sto;
	
	}
	strFormattedMoney += strSto;

}

if (decimal!=false){
if (Money ==0) strFormattedMoney = strFormattedMoney+',00';
else if (Money <10) strFormattedMoney = strFormattedMoney+',0'+Money;
else 
  strFormattedMoney = strFormattedMoney+','+Money;

}
  return  strFormattedMoney;
  
}

function MoneyToFloat(input)
{
 var strMoney, intMoneyLength, intIndex, strInteger;

	if(input==0) return input;



  strMoney = new String(input);

  

 // strMoney = strMoney.replace(/./,"a")

  

  //Money = parseFloat(Money);

//	alert(strMoney)

  

  

  

  intIndex = 0;

 // while (strMoney.substring(intIndex, intIndex+1) == '0') {intIndex++};



  intMoneyLength = strMoney.length;

  strMoney = strMoney.substring(intIndex, intMoneyLength);



  strInteger = new String("");

  for (intIndex=0; intIndex<intMoneyLength; intIndex++)

  {

    if (strMoney.substring(intIndex,intIndex+1) == ".") {continue};

//    if (strMoney.substring(intIndex,intIndex+1) == ",") {break};

    strInteger += strMoney.substring(intIndex,intIndex+1);

  }





//alert(strInteger);

	strMoney = strInteger.replace(/,/,".")









 /* if (strInteger.length == 0) {return 0};

  if (isNaN(strInteger))

  {

    return 0;

  }

  else

  {

    return parseInt(strInteger);

  }*/	



	return parseFloat(strMoney);



}

function ShowLoading()
{

	arrayPageSize =  getPageSize();
	hideSelectBoxes();
	hideFlash();
	var d = document
//	var msg = d.createElement("span")
//	msg.innerHTML = header;
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	mObj.style.display = 'none';
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = arrayPageSize[1] +'px';//  + getPageScroll()[1] + 'px' //+ getPageScroll()[1];
	alertObj =  d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	alertObj.id = "LoadingBox";
	alertObj.style.top = arrayPageSize[3] /2 - 20 + getPageScroll()[1]  + 'px';

	alertObj.style.left = ((bx()/2) - (50))+'px';//bt();		
	msg1 = alertObj.appendChild(d.createElement("p"));
	//msg1.src='/library/images/loading.gif';
	msg1.innerHTML ='<img align="center" vspace="10" hspace="10" src="/library/images/loading_image.gif">';
	msg1.style.textAlign='center';	
		
	
	new Effect.Appear('modalContainer', { duration: overlayDuration, from: 0.0, to: 0.6 });	

}
