
/**
 * geachem.js => some javascript stuff
 * @site geachem d.o.o.
 * @author Sasa Zivkovic
 */

// client's side clock functionality
function js_clock()
{
  var months=new Array();
	months=["Januar","Februar","Mart","April","Maj","Juni","Juli","Avgust","Septembar","Oktobar","Novembar","Decembar"];
  var daysofweek=new Array();
	daysofweek=["Nedelja","Ponedeljak","Utorak","Sreda","Četvrtak","Petak","Subota"];
  var localTime=new Date();
  var ms=localTime.getTime();
  var time=new Date(ms);
  var day=time.getDate();
	if(day<10) day="0"+day;
  var month=time.getMonth()+1;
	var month_name=months[time.getMonth()];
	var dayofweek_name=daysofweek[time.getDay()];
	if(month<10) month="0"+month;
  var year=time.getFullYear();
  var hour=time.getHours();
  var minute=time.getMinutes();
  var second=time.getSeconds();
	var temp="&nbsp;&nbsp;&nbsp;";
	temp+=dayofweek_name;
	temp+="&nbsp;"+day+"&nbsp;";
	temp+=month_name;
	temp+="&nbsp;"+year+"&nbsp;&nbsp;/&nbsp;&nbsp;";
  temp+=((hour<10)?"0":"")+hour;
  temp+=((minute<10)?":0":":")+minute;
  temp+=((second<10)?":0":":")+second;
	document.getElementById("jstime").innerHTML="<font color='#000000'>"+temp+"</font>";
	setTimeout("js_clock()",1000);
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function getCookie( check_name )
{
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function setCookie(name,value,expires,path,domain,secure)
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function deleteCookie( name, path, domain ) 
{
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function gotoFastLink()
{
	url=document.getElementById("fastLinks").value;
	if(url)
		location.replace(url);
	else
		alert("Fastlink ne postoji !!!");
}

function preloadImgs()
{
	var d=document,a=arguments;
	if(!d.FP_imgs) d.FP_imgs=new Array();
	for(var i=0; i<a.length; i++)
	{
		d.FP_imgs[i]=new Image;
		d.FP_imgs[i].src=a[i];
	}
}

/*

// this should go to bdoy onload=""

preloadImgs(
'images/blue_box.jpg',
'images/privreda/00i.gif','images/privreda/01i.gif','images/privreda/02i.gif','images/privreda/03i.gif',
'images/privreda/04i.gif','images/privreda/05i.gif','images/privreda/06i.gif','images/privreda/07i.gif',
'images/privreda/00a.gif','images/privreda/01a.gif','images/privreda/02a.gif','images/privreda/03a.gif',
'images/privreda/04a.gif','images/privreda/05a.gif','images/privreda/06a.gif','images/privreda/07a.gif',
'images/anigif/0.gif','images/anigif/1.gif','images/anigif/2.gif','images/anigif/3.gif',
'images/anigif/4.gif','images/anigif/5.gif','images/anigif/6.gif','images/anigif/7.gif');
*/
