
// Email.js version 5
var tld_ = new Array()
tld_[0] = "com";
tld_[1] = "org";
tld_[2] = "net";
tld_[3] = "ws";
tld_[4] = "info";
tld_[10] = "co.uk";
tld_[11] = "org.uk";
tld_[12] = "gov.uk";
tld_[13] = "hr";
var topDom_ = 13;
var m_ = "mailto:";
var a_ = "@";
var d_ = ".";

function mail(name, dom, tl, params, klasa)
{
	var s = e(name,dom,tl);
	document.write('<a class="'+klasa+'" href="'+m_+s+params+'">'+s+'</a>');
}
function mail2(name, dom, tl, params, display, klasa)
{
	document.write('<a class="'+klasa+'" href="'+m_+e(name,dom,tl)+params+'">'+display+'</a>');
}
function e(name, dom, tl)
{
	var s = name+a_;
	if (tl!=-2)
	{
		s+= dom;
		if (tl>=0)
			s+= d_+tld_[tl];
	}
	else
		s+= swapper(dom);
	return s;
}
function swapper(d)
{
	var s = "";
	for (var i=0; i<d.length; i+=2)
		if (i+1==d.length)
			s+= d.charAt(i)
		else
			s+= d.charAt(i+1)+d.charAt(i);
	return s.replace(/\?/g,'.');
}




var ie=document.all
var ns6=document.getElementById&&!document.all
timerID=5;
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}
function enlarge(html,cl,id){




if (ie||ns6){

	
	crossobj=document.getElementById("poruka")
	




x=findPosX(document.getElementById(id));
y=findPosY(document.getElementById(id));

var horzpos=ns6? pageXOffset+x-42 : ietruebody().scrollLeft+x-42
var vertpos=ns6? pageYOffset+y+15 : ietruebody().scrollTop+y+15

crossobj.style.left=horzpos+"px"

crossobj.style.top=vertpos+"px"




if(html!="kal")
{
	crossobj.innerHTML=html;
}
else
	kal(id);

	


crossobj.style.visibility="visible"
crossobj.className=cl;



if(timerID!=5)
				timerID=clearTimeout(timerID);

if(cl=="poruka")
{
			
			timerID=window.setTimeout("closepreview()",2000);
			
}
		
return false
}
else 
return true
}

function closepreview(){


timerID=clearTimeout(timerID);

if(document.getElementById('poruka').style.visibility == 'visible')
	crossobj.style.visibility="hidden"
}







function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}










function otvori_ispis(loc,nas)
{
	
  x = screen.width / 2 - 450;
  y = screen.height / 2 - 400;
  width = 900
  height = 800
  args = "fullscreen=no,menubar=yes,toolbar=yes,width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes,top=" + y +",left=" + x
  window.open("ispis.php?t="+loc+"&nas="+nas,"", args);
}

function otvori_pr(asd)

{

  x = screen.width / 2 - 400;


  y = screen.height / 2 - 300


  width = 800


  height = 600


  temp = "fullscreen=no,menubar=no,width=" + width + ",height=" + height + ",scrollbars=yes,resizable=no,top=" + y +",left=" + x

  window.open(asd,"", temp);

 }




String.prototype.strpad=function(){
return (!isNaN(this) && this.toString().length==1)?"0"+this:this;
}


Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return i;
		}
	}
	return "x";
};



var weekend = [0,6];
var weekendColor = "#e0e0e0";
var fontface = "Verdana";
var fontsize = 8;			

var gNow = new Date();
var ggWinContent;
var ggPosX = -1;
var ggPosY = -1;

Calendar.Months = ["Sijeèanj", "Veljaèa", "Ožujak", "Travanj", "Svibanj", "Lipanj",
"Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"];

// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_month, p_year, p_format) {
	if ((p_month == null) && (p_year == null))	return;

	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}

	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;

function Calendar_get_month(monthNo) {
	return Calendar.Months[monthNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return Calendar.DOMonth[monthNo];
	
		return Calendar.lDOMonth[monthNo];
	} else
		return Calendar.DOMonth[monthNo];
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	
	var ret_arr = new Array();
	
	if (incr == -1) {
		
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	
	var ret_arr = new Array();
	
	if (incr == -1) {
		
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	
	vCode += ("<div align=center><TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\" style='font-size:" + fontsize + "pt;'>");
	
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode += (vHeader_Code + vData_Code);
	
	vCode += "</TABLE></div>";
	
	return vCode;
}

Calendar.prototype.show = function() {
	var vCode = "";

	ggWinContent += ("<table width=100% style=\"padding:1px;\" border=0 cellspacing=0 cellpadding=0><tr><td><FONT FACE=\"" + fontface + "\"  style=\"color:#ffffff;font-size:" + fontsize + "pt;\" ><B>");
	ggWinContent += (this.gMonthName + " " + this.gYear);
	ggWinContent += '</B></td><td align=right></td></tr></table>';
	
	var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
	var prevMM = prevMMYYYY[0];
	var prevYYYY = prevMMYYYY[1];

	var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
	var nextMM = nextMMYYYY[0];
	var nextYYYY = nextMMYYYY[1];
	
	ggWinContent += ("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR='ffffff' style='font-size:" + fontsize + "pt;'><TR style='cursor:pointer'><TD style='border:1px outset #fffffF;' ALIGN=center onmouseover=\"this.bgColor='#EE1D23';\" onmouseout=\"this.bgColor='#ffffff';\" onClick=\"Build2(" +
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
		");" +
		"\"><FONT FACE='" + fontface + "' COLOR='" + this.gTextColor + "' style='font-size:6 pt;'><B> << </B></FONT> </TD><TD style='border:1px outset #fffffF;' ALIGN=center onmouseover=\"this.bgColor='#EE1D23';\" onmouseout=\"this.bgColor='#ffffff';\" onClick=\"Build2(" + 
		"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\"><FONT FACE='" + fontface + "' COLOR='" + this.gTextColor + "' style='font-size:6 pt;'><B> < </B></FONT>	</TD><TD style='border:1px outset #fffffF;' ALIGN=center onmouseover=\"this.bgColor='#EE1D23';\" onmouseout=\"this.bgColor='#ffffff';\" onClick=\"Build2(" + 
		"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\"><FONT FACE='" + fontface + "' COLOR='" + this.gTextColor + "' style='font-size: 6 pt;'><B> > </B></FONT></TD><TD style='border:1px outset #fffffF;' ALIGN=center onmouseover=\"this.bgColor='#EE1D23';\" onmouseout=\"this.bgColor='#ffffff';\" onClick=\"Build2(" +
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
		");" + 
		"\"><FONT FACE='" + fontface + "' COLOR='" + this.gTextColor + "' style='font-size:6 pt;'><B> >> </B></FONT></TD></TR></TABLE>");

	
	vCode = this.getMonthlyCalendarCode();
	ggWinContent += vCode;
}


Calendar.prototype.cal_header = function() {
	var vCode = "";
	
	vCode = vCode + "<TR>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Ne</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Po</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Ut</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Sr</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Èe</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=14% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Pe</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH=16% BGCOLOR='"+ this.gHeaderColor + "'><FONT FACE='" + fontface + "' COLOR='" + this.gHeaderColor2 + "'><B>Su</B></FONT></TD>";
	vCode = vCode + "</TR>";
	
	return vCode;
}

Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);

	var vFirstDay=vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";

	
	vCode = vCode + "<TR style='cursor:default'>";
	for (i=0; i<vFirstDay; i++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) +"';\"><FONT FACE='" + fontface + "'> </FONT></TD>";
	}

	// Write rest of the 1st week
	for (j=vFirstDay; j<7; j++) {
		
		hv=days.inArray(vDay.toString().strpad().toString());
			
		if(hv!="x")
			vCode = vCode + "<TD style='cursor:pointer' WIDTH='14%' align=center" + this.write_weekend_string(j) + "   onMouseover=\"this.bgColor='#FFFF00';ttip('<b>"+nass[hv]+"</b><br><br>"+txts[hv] +"','',390);\" onMouseout=\"this.bgColor='"+ this.write_weekend_string2(j) +"';hidettip()\"  onClick=\"window.location='index.php?l=d"+ids[hv]+"'\" ><FONT style='color:#ff0000;' FACE='" + fontface + "' >" + this.format_day(vDay) + "</FONT></TD>";
		else
			vCode = vCode + "<TD WIDTH='14%'  align=center " + this.write_weekend_string(j) + "   onmouseover=\"this.bgColor='#FFFF00';\" onmouseout=\"this.bgColor='"+ this.write_weekend_string2(j) +"';\" ><FONT style='color:#333333;' FACE='" + fontface + "' >" + this.format_day(vDay) + "</FONT></TD>";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>";

	// Write the rest of the weeks
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR style='cursor:pointer'>";

		for (j=0; j<7; j++) {
						
			hv=days.inArray(vDay.toString().strpad().toString());
			
			if(hv!="x")
				vCode = vCode + "<TD WIDTH='14%'  align=center" + this.write_weekend_string(j) + " onMouseover=\"this.bgColor='#FFFF00';ttip('<b>"+nass[hv]+"</b><br><br>"+txts[hv] +"','',390);\" onMouseout=\"this.bgColor='"+ this.write_weekend_string2(j) +"';hidettip()\"  onClick=\"window.location='index.php?l=d"+ids[hv]+"'\" ><FONT style='color:#ff0000;' FACE='" + fontface + "'>" + this.format_day(vDay) + "</FONT></TD>";
			else
				vCode = vCode + "<TD WIDTH='14%' style='cursor:default;' align=center " + this.write_weekend_string(j) + "  onmouseover=\"this.bgColor='#FFFF00';\" onmouseout=\"this.bgColor='"+ this.write_weekend_string2(j) +"';\" ><FONT style='color:#333333;' FACE='" + fontface + "'>" + this.format_day(vDay) + "</FONT></TD>";
			vDay=vDay + 1;

			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}

		if (j == 6)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}
	
	// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	for (m=1; m<(7-j); m++) {
		
			vCode = vCode + "<TD style='cursor:default' WIDTH='14%'" + this.write_weekend_string(j+m) + 
			" ><FONT FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
	}
	
	return vCode;
}

Calendar.prototype.format_day = function(vday) {
	var vNowDay = gNow.getDate();
	var vNowMonth = gNow.getMonth();
	var vNowYear = gNow.getFullYear();

	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
		return ("<FONT COLOR=\"BLUE\">" + vday + "</FONT>");
	else
		return (vday);
}

Calendar.prototype.write_weekend_string = function(vday) {
	var i;

	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i])
		{
			
			return (" BGCOLOR='" + weekendColor + "'");
		}
	}
	
	return "";
}

Calendar.prototype.write_weekend_string2 = function(vday) {
	var i;

	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i])
			return (weekendColor);
	}
	
	return "";
}

Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

	switch (this.gFormat) {
		case "MM\/DD\/YYYY" :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
			break;
		case "MM\/DD\/YY" :
			vData = vMonth + "\/" + vDD + "\/" + vY2;
			break;
		case "MM-DD-YYYY" :
			vData = vMonth + "-" + vDD + "-" + vY4;
			break;
		case "YYYY-MM-DD" :
			vData = vY4 + "-" + vMonth + "-" + vDD;
			break;
		case "MM-DD-YY" :
			vData = vMonth + "-" + vDD + "-" + vY2;
			break;
		case "DD\/MON\/YYYY" :
			vData = vDD + "\/" + vMon + "\/" + vY4;
			break;
		case "DD\/MON\/YY" :
			vData = vDD + "\/" + vMon + "\/" + vY2;
			break;
		case "DD-MON-YYYY" :
			vData = vDD + "-" + vMon + "-" + vY4;
			break;
		case "DD-MON-YY" :
			vData = vDD + "-" + vMon + "-" + vY2;
			break;
		case "DD\/MONTH\/YYYY" :
			vData = vDD + "\/" + vFMon + "\/" + vY4;
			break;
		case "DD\/MONTH\/YY" :
			vData = vDD + "\/" + vFMon + "\/" + vY2;
			break;
		case "DD-MONTH-YYYY" :
			vData = vDD + "-" + vFMon + "-" + vY4;
			break;
		case "DD-MONTH-YY" :
			vData = vDD + "-" + vFMon + "-" + vY2;
			break;
		case "DD\/MM\/YYYY" :
			vData = vDD + "\/" + vMonth + "\/" + vY4;
			break;
		case "DD\/MM\/YY" :
			vData = vDD + "\/" + vMonth + "\/" + vY2;
			break;
		case "DD-MM-YYYY" :
			vData = vDD + "-" + vMonth + "-" + vY4;
			break;
		case "DD-MM-YY" :
			vData = vDD + "-" + vMonth + "-" + vY2;
			break;
		default :
			vData = vDD + "." + vMonth + "." + vY4;
	}

	return vData;
}




function Build(p_item, p_month, p_year, p_format) {
	
	
	gCal = new Calendar(p_item, p_month, p_year, p_format);

	// Customize your Calendar here..
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="#000000";
	gCal.gHeaderColor="#cc0000";
	gCal.gHeaderColor2="white";


	// initialize the content string
	ggWinContent = "";

	
		gCal.show();
		

	poc='<table  border="0" style="border:1px solid #333333;padding:1px" bgcolor="cc0000" cellspacing="0" cellpadding="0"><tr><td>';
	end='</td></tr></table>';
	
	ggWinContent=poc+ggWinContent+end;
	document.getElementById("overDiv").innerHTML=ggWinContent;

	
}
















function conv(num)
{

	num=strip(num,'.');
	rExp = /,/g;
	num=num.replace(rExp,'.');
	
	if(parseFloat(num))
		num=parseFloat(num).toFixed(14)
		
	return num;
	
}

function deconv(dnum)
{

	dnum=String(dnum);
	rExp = /,/g;
	dnum=dnum.replace(rExp,'#');
	rExp = /\./g;
	dnum=dnum.replace(rExp,',');
	rExp = /#/g;
	dnum=dnum.replace(rExp,'.');
	return dnum;

}




   // CONSTANTS
  var separator = ",";  // use comma as 000's separator
  var decpoint = ".";  // use period as decimal point
  var percent = "%";
  var currency = "$";  // use dollar sign for currency


function formatNumber(number, format, print) {  // use: formatNumber(number, "format")
    
	if (print) document.write("formatNumber(" + number + ", \"" + format + "\")<br>");

	number=conv(number);
	
	
	


    if (number - 0 != number) return null;  // if number is NaN return null
    var useSeparator = format.indexOf(separator) != -1;  // use separators in number
    var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
    var useCurrency = format.indexOf(currency) != -1;  // use currency format
    var isNegative = (number < 0);
    number = Math.abs (number);
    if (usePercent) number *= 100;
    format = strip(format, separator + percent + currency);  // remove key characters
    number = "" + number;  // convert number input to string

     // split input value into LHS and RHS using decpoint as divider
    var dec = number.indexOf(decpoint) != -1;
    var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
    var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";

     // split format string into LHS and RHS using decpoint as divider
    dec = format.indexOf(decpoint) != -1;
    var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
    var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";

     // adjust decimal places by cropping or adding zeros to LHS of number
    if (srightEnd.length < nrightEnd.length) {
      var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
      nrightEnd = nrightEnd.substring(0, srightEnd.length);
      if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up

 // patch provided by Patti Marcoux 1999/08/06
      while (srightEnd.length > nrightEnd.length) {
        nrightEnd = "0" + nrightEnd;
      }

      if (srightEnd.length < nrightEnd.length) {
        nrightEnd = nrightEnd.substring(1);
        nleftEnd = (nleftEnd - 0) + 1;
      }
    } else {
      for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
        if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero to RHS of number
        else break;
      }
    }

     // adjust leading zeros
    sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
    while (sleftEnd.length > nleftEnd.length) {
      nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
    }

    if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
    var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  // combine parts
    output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
    if (isNegative) {
      // patch suggested by Tom Denn 25/4/2001
      output = (useCurrency) ? "(" + output + ")" : "-" + output;
    }
    
	
	
	output=deconv(output);
	
	return output;
	
  }

  function strip(input, chars) {  // strip all characters in 'chars' from input
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++)
      if (chars.indexOf(input.charAt(i)) == -1)
        output += input.charAt(i);
    return output;
  }

  function separate(input, separator) {  // format input using 'separator' to mark 000's
    input = "" + input;
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++) {
      if (i != 0 && (input.length - i) % 3 == 0) output += separator;
      output += input.charAt(i);
    }
    return output;
  }

  







function pretrazi()
{
	if(document.getElementById("search").value!="")
		document.getElementById("pretraga").submit();



}

function otvori(id)
{
  x = screen.width / 2 - 300;
  y = screen.height / 2 - 260
  width = 600
  height = 520
  args = "fullscreen=no,menubar=no,width=" + width + ",height=" + height + ",scrollbars=yes,resizable=no,top=" + y +",left=" + x
  window.open("detalji.php?id="+id,"", args);
}


function over(id)
{
	document.getElementById(id).style.backgroundColor='#F6F6F6';
	


}

function off(id)
{
	document.getElementById(id).style.backgroundColor='';
	


}

function null_on(id)
{
	
	
		tmp="0";
	
	if(document.getElementById(id).value=="")
		document.getElementById(id).value=tmp;
}




function IsNum_kol(evt)
{
 var e = evt? evt : window.event; 



if (e.keyCode) { code = e.keyCode; } 
else if (typeof(e.which)!= 'undefined') { code = e.which; } 
  

	

if ((code > 47 && code < 58) || code==8 || code==46 || code==9 || code==37 || code==39)
	temp = code
else
	return false;
}



function over_on(objName,clName)
{
	var obj = findObj(objName);
	
	eval("obj"+'.className=clName');
}
function over_off(objName,clName)
{
	
		var obj = findObj(objName);
		eval("obj"+'.className=clName');
	
}
function findObj(objName, d) { 
	var x;  
	if(!x && document.getElementById) x=document.getElementById(objName); return x;
}



function meni(id)
{
	if(document.getElementById("pod"+id))
	{
	
		if(document.getElementById("pod"+id).style.display=="none")
		{
			document.getElementById("pod"+id).style.display="block";
			temp=readCookie("izbornici");
		
			if(!temp)
				temp="";
			createCookie("izbornici",temp+'izb'+id,"");
			
			
		}
		else
		{
			document.getElementById("pod"+id).style.display="none";	
			temp=readCookie("izbornici");
			if(!temp)
				temp="";
	
			var re = new RegExp("izb" + id,"g");
	
			
			temp=temp.replace(re,"");
			
			createCookie("izbornici",temp,"");
			
		}
	} else
	{
		window.location='index.php?l=s'+id
	
	}


}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}




function dodaj_artikal(id,cijena)
{
	art_ids=readCookie("art_ids");
	if(!art_ids)
		art_ids="";
		
		
	art_ids_ar=art_ids.split("|##|")
		
	
	dod=0;
	
	for(i=0;i<art_ids_ar.length;i++)
	{
		
		if(art_ids_ar[i].indexOf(id+"|#|")!=-1)
		{
			
			art_id=art_ids_ar[i].split("|#|")
			
			art_id[2]=parseInt(art_id[2])+1;
			
			art_ids_ar[i]=art_id.join("|#|");
			
			art_ids=art_ids_ar.join("|##|");
					
			dod=1;
		
		}
		
	
	}
	
	if(dod==0)
	{
		if(art_ids_ar[0]=="")
			art_ids_ar[0]=id+"|#|"+cijena+"|#|1";
		else
			art_ids_ar.push(id+"|#|"+cijena+"|#|1");
		art_ids=art_ids_ar.join("|##|");
	
	}
	
		
		
		
	createCookie("art_ids",art_ids,"");
	
	set_kosarica();
}




function set_kosarica()
{

	document.getElementById("kosarica_bg").src="pics/kosarica_red.gif";


	setTimeout('document.getElementById("kosarica_bg").src="pics/kosarica.gif"',300)	
	setTimeout('document.getElementById("kosarica_bg").src="pics/kosarica_red.gif"',500)
	setTimeout('document.getElementById("kosarica_bg").src="pics/kosarica.gif"',700)
	
	art_ids=readCookie("art_ids");
	
	if(!art_ids)
		art_ids="";
		
	art_ids_ar=art_ids.split("|##|")
		
	iznos=0;
	kol=0;
	
	if(art_ids_ar[0]!="")
	{
	
		for(i=0;i<art_ids_ar.length;i++)
		{
			
			
				art_id=art_ids_ar[i].split("|#|")
				
				
				
				
				iznos=parseFloat(parseFloat(iznos).toFixed(2))+(parseFloat(parseFloat(art_id[1]).toFixed(4))*1.22*parseInt(parseFloat(art_id[2]).toFixed(2)));
				kol=parseInt(kol)+parseInt(art_id[2]);			
						
		
		}
	
	}
	
	iznos=iznos.toFixed(2);
	
	document.getElementById("iznos_art").innerHTML=formatNumber(deconv(iznos), "#,.00");
	document.getElementById("broj_art").innerHTML=kol;

	createCookie("iznos_art",iznos,"");
	
	createCookie("broj_art",kol,"");
	


}


function obrisi_artikal(i)
{


	art_ids=readCookie("art_ids");
	
	
		
	art_ids_ar=art_ids.split("|##|")
		
	
	art_ids_ar.splice(i,1);		
			
			
	art_ids=art_ids_ar.join("|##|");
					
	createCookie("art_ids",art_ids,"");
	
	set_kosarica();
	
	window.location='index.php?l=k';		
		
	
}

function izracunaj_kosaricu(j,kol)
{

	art_ids=readCookie("art_ids");
	
	if(!art_ids)
		art_ids="";
		
	art_ids_ar=art_ids.split("|##|")
		
	art_id=art_ids_ar[j].split("|#|")
			
			art_id[2]=kol;
			
			art_ids_ar[j]=art_id.join("|#|");
			
			art_ids=art_ids_ar.join("|##|");
			
			
	createCookie("art_ids",art_ids,"");
	
	set_kosarica();	
	
	iznos=0;
	iznosi=0;
	
	if(art_ids_ar[0]!="")
	{
	
		for(i=0;i<art_ids_ar.length;i++)
		{
			
			
				art_id=art_ids_ar[i].split("|#|")
				
				
				
				
				iznos=parseFloat(parseFloat(iznos).toFixed(4))+(parseFloat(parseFloat(art_id[1]).toFixed(4))*parseInt(parseFloat(art_id[2]).toFixed(2)));
				
				if(i==j)
				{
					iznosi=(parseFloat(parseFloat(art_id[1]).toFixed(2))*parseInt(parseFloat(art_id[2]).toFixed(2)));

					iznosi=iznosi.toFixed(2);
					document.getElementById("iznos"+i).innerHTML=formatNumber(deconv(iznosi), "#,.00")+"&nbsp;kn&nbsp;&nbsp;";
				}
				
				
					
		
		}
		
	
	}
	
	iznos=iznos.toFixed(4);
	pdv=parseFloat(iznos)*0.22;
	tot=parseFloat(iznos)*1.22;
	
	pdv=pdv.toFixed(2);
	tot=tot.toFixed(2);
	
	document.getElementById("tot_ukupno").innerHTML=formatNumber(deconv(iznos), "#,.00")+"&nbsp;kn";	
	document.getElementById("tot_pdv").innerHTML=formatNumber(deconv(pdv), "#,.00")+"&nbsp;kn";
	document.getElementById("tot_sveukupno").innerHTML=formatNumber(deconv(tot), "#,.00")+"&nbsp;kn";
	document.getElementById("total").value=tot;


}


function kolicina(j, kol)
{

	tmp=parseInt(document.getElementById('kolicina'+j).value);
	tmp=tmp+parseInt(kol);
	if(tmp<0)
		tmp=0;
	document.getElementById('kolicina'+j).value=tmp;
	izracunaj_kosaricu(j,tmp)


}


function CheckIsIE()
{
if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true;}
else { return false; }
}


function printframe()
{

if (CheckIsIE() == true)
{
document.engine.focus();
document.engine.print();
}
else
{
window.frames['engine'].focus();
window.frames['engine'].print();
}

} 








