//=========================================
// browser detection
var ie5   = ( document.getElementById && document.all ); 
var moz   = ( document.getElementById &&! document.all );
var opera    = ( navigator.userAgent.indexOf( 'Opera' ) != -1 );
if ( opera ) ie5 = false;
 
//=========================================

function TitledTextBoxGotFocus(textBox){
	tBox = getObj(textBox);

	if (!isChanged(tBox)){
		setInputValue(tBox, "");
		tBox.setAttribute((ie5 ? "className":"class"), "YPDodajTextBoxManji");
	}
}

function TitledTextBoxLostFocus(textBox){
	tBox = getObj(textBox);
	// alert(isChanged(tBox));
	if (getInputValue(tBox) == ''){
		setInputValue(tBox, getInputDefaultValue(tBox));
		tBox.setAttribute((ie5 ? "className":"class"), "YPDodajTextBoxManji YPDodajBoxTitled");
	}
}

function SlikaUp() {
        ba=arguments.length;
        URL=arguments[0];
        eval("page7 = window.open(URL, '" + 7 + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1');");
}

function PopUp() {
        URL=arguments[0];
        nid=3;
        eval("page" + nid + " = window.open(URL, '" + nid + "', 'toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=2,resizable=1,width=" + 600 + ",height=" + 500 + "');");
}

function PopUpCustom() {
        URL=arguments[0];
        HSIZE=arguments[1];
        VSIZE=arguments[2];
        nid=33;
        eval("page" + nid + " = window.open(URL, '" + nid + "', 'toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=2,resizable=0,width=" + HSIZE + ",height=" + VSIZE + "');");
}

function move_in(slimg, img_name) {
	slimg.src=img_name;
}

function move_out(slimg, img_name) {
	slimg.src=img_name;
}

function DANES_goTo( url ) {
	window.location.href = url;
}



//AJAX-RELATED JS

//displays stream in the ajax div
function ShowAjaxStream(nkat, ntitle) {
	FadeOutAllBlocks();
	setTimeout("xajax_ShowNavigation(" + nkat + ");", 300);
	setTimeout("xajax_ShowStream(" + nkat + ");", 350);
	setTimeout("xajax_ShowRight(" + nkat + ");", 400);
	document.title = ntitle;
}

//displays stream/press in the ajax div
function ShowAjaxPress(nkat, npid, dd, mm, gg, ntitle) {
	FadeOutAllBlocks();
	setTimeout("xajax_ShowNavigation(" + nkat + ");", 300);
	if (npid != 0){
		setTimeout("xajax_ShowStream(" + nkat + ", 3, " + npid + ", " + dd + ", " + mm + ", " + gg + ");", 350);
	} else {
		setTimeout("xajax_ShowStream(" + nkat + ", " + (mm != 0 && dd == 0 ? 2:(mm != 0 && dd != 0 ? 1:6)) + ", 0, " + dd + ", " + mm + ", " + gg + ");", 350);
	}
	setTimeout("xajax_ShowRight(" + nkat + ", 0, " + dd + ", " + mm + ", " + gg + ");", 400);
	document.title = ntitle;
}

//displays article in the ajax div
function ShowAjaxArticle(nkat, npid, ntitle) {
	FadeOutAllBlocks();
	setTimeout("xajax_ShowNavigation(" + nkat + ");", 300);
	setTimeout("xajax_ShowArticle(" + nkat + ", " + npid + ");", 350);
	setTimeout("xajax_ShowRight(" + nkat + ");", 400);
	document.title = ntitle;
}

//displays service in the ajax div
function ShowAjaxService(nkat, nservice, ntitle) {
	FadeOutAllBlocks();
	setTimeout("xajax_ShowNavigation(" + nkat + ");", 300);
	setTimeout("xajax_ShowService(" + nkat + ", " + nservice + ");", 300);
	setTimeout("xajax_ShowRight(" + nkat + ", " + nservice + ");", 300);
	document.title = ntitle;
}

function FadeOutAllBlocks(){
	setTimeout('fader("menuAjaxInner", "out");', 100);
	setTimeout('fader("centerAjaxInner", "out");', 50);
	setTimeout('fader("rightAjaxInner", "out");', 0);
}

//=======================================
// instantiate global variables
var goIn, inUse;
inUse = '';

function fader(objID, dir){
	// FAKE FUNCTION
}

/*
function fader( objID, dir ) {
  var fade_index;

	if ( inUse != '' && inUse != dir ) return;


	if ( ie5 || moz ) {
		inUse = dir;

		if( ie5 ) {
  		fade_index = xajax.$( objID ).filters.alpha.opacity;
		}
		
		if( moz ) {
  		fade_index = xajax.$( objID ).style.MozOpacity * 100;
		}

		fade_index  = dir == 'in' ? fade_index + 15 : fade_index - 15;
		index_limit = dir == 'in' ? 100 : 0;

		if( ie5 ) {
  		xajax.$( objID ).filters.alpha.opacity = fade_index;
		}
		
		if( moz ) {
  		xajax.$( objID ).style.MozOpacity = fade_index / 100; 
		}

		goIn = setTimeout('fader(\'' + objID + '\',\'' + dir + '\')', 0);

		if( ( dir == 'in' && fade_index >= index_limit ) || ( dir == 'out' && fade_index <= index_limit ) ) {
			clearTimeout( goIn );
			inUse = '';

			// Bug fix, somethimes div block doesn't fade in at all
			if( ie5 ) {
	  			setTimeout('xajax.$(\'' + objID + '\').filters.alpha.opacity = 100;', 1000);
			}
			
			if( moz ) {
				setTimeout('xajax.$(\'' + objID + '\').style.MozOpacity = 1;', 1000);
			}
		}
	}
}
*/

