var t = 0
var Width;
var height;
var title;
var Slika = new Image();
function ShowFullImage(strUrl,width,height,title)
{
	
		
	
	
	Slika.src = strUrl;
	
//	Slika.onLoad = timedCount(Slika,title);
	
	
	
	Slika.alt = title;

	resizeWindow(Slika,Slika.alt,400,400)
	
	
	
	
}



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.gif) 100px 100px 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="image" src="/library/images/zapri.gif"  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)
{
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=no,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 DrawAlert(header)
{
	var d = document
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.body.scrollHeight+'px';
	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	alertObj.style.top = bo()+by()/2-200;
	alertObj.style.left = ((bx()/2) - (250));
	
	msg1 = alertObj.appendChild(d.createElement("p"));
	msg1.id="btnCont";	
	msg1.appendChild(d.createTextNode(header));
	
	mObj.onclick = function() {
		d.getElementsByTagName("body")[0].removeChild(d.getElementById("modalContainer"));
		}
}
function by()
{
var moz=(document.getElementById&&!document.all)?1:0;
return (moz) ? self.innerHeight : document.body.clientHeight;



	
}
function bx()
{
var moz=(document.getElementById&&!document.all)?1:0;
return (moz) ? self.innerWidth : document.body.offsetWidth;

}

function bo()
{
	return (moz) ? window.pageYOffset : document.body.scrollTop;
}

function bt()
{
	with(document.getElementById('alertBox').style)
	{
		
		top = bo()+by()/2-100;
	}
		b = setTimeout('bt()',10);
}


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 PreloadImages()
{

var Images = new Array();
/*
Images[0] = new Image;
Images[0].src = '/library/images/domov_over.gif';

Images[1] = new Image;
Images[1].src = '/library/images/o_podjetju_over.gif';

Images[2] = new Image;
Images[2].src = '/library/images/kontakt_over.gif';

Images[3] = new Image;
Images[3].src = '/library/images/domov_over.gif';


Images[4] = new Image;
Images[4].src = '/library/images/uvodna_stran_over.gif';


Images[5] = new Image;
Images[5].src = '/library/images/o_podjetju_over.gif';


Images[6] = new Image;
Images[6].src = '/library/images/prodajni_program_over.gif';

Images[7] = new Image;
Images[7].src = '/library/images/izposoja_over.gif';


Images[8] = new Image;
Images[8].src = '/library/images/akcijska_ponudba_over.gif';


Images[9] = new Image;
Images[9].src = '/library/images/aktualno_over.gif';

Images[10] = new Image;
Images[10].src = '/library/images/pisite_nam_over.gif';

*/
}
