// ========= Return element id =============================
function getEl(sId) {
  return (document.all? document.all(sId): (document.getElementById? document.getElementById(sId): null));
}


// ========= Language =============================


sfHover = function() {
	var sfEls = document.getElementById("language").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className = GetRegExp( this.className );
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function GetRegExp( sVar )
{
	return (sVar.replace(new RegExp(" sfhover\\b"), ""))
}




function zoomPic( sPicName ) {
	var winURL 			= 'pic.asp?s=' + sPicName
  var winIme 			= 'Pic'
  var winAtributi 	=
    'width=520'+ 
    ',height=400'+ 
    ',toolbar=no'     +
    ',location=no'    +
    ',directories=no' +
    ',status=no'      +
    ',menubar=no'     +
    ',scrollbars=yes' +
    ',resizable=no'  ;

  var win = eval("window.open(winURL, winIme, winAtributi)");
	win.focus();
}


function printCard( nID ) {
	var winURL 			= 'detail_print.asp?qIID=' + nID
  var winIme 			= 'Naucat'
  var winAtributi 	=
    'width=680'+ 
    ',height=450'+ 
    ',toolbar=no'     +
    ',location=no'    +
    ',directories=no' +
    ',status=no'      +
    ',menubar=no'     +
    ',scrollbars=yes' +
    ',resizable=no'  ;

  var win = eval("window.open(winURL, winIme, winAtributi)");
	win.focus();
}



// ========= Refresh prozor za fotke ========================
// ==========================================================
   function refresh()
   {
     var picWidth 		= getEl( 'bigPic' ).width;
     var picHeight 		= getEl( 'bigPic' ).height;
		 if ( navigator.appName == 'Netscape' ) {
	   	 self.resizeTo( picWidth+66, picHeight+102 );
	   }
	   else {
	    	self.resizeTo( picWidth+76, picHeight+100 );
	   }
   }	
	 
	


function makePriceList( btnRadio ) {
 niz = eval( btnRadio );
 document.fRegister.f_advertisingPrice.options.length = 0;
 if (btnRadio != "") {
 	if ( (btnRadio == "privateFree")||(btnRadio == "privatePay") ) 
	{
		document.fRegister.f_dealerCompany.disabled = true;
		getEl('registerTitle').className	= 'yellow';
		getEl('dealerCompany').className	= 'disabled';
	}
	else {
		document.fRegister.f_dealerCompany.disabled = false;
		getEl('registerTitle').className	= 'green';
		getEl('dealerCompany').className	= 'default';
	}
  for (count=0; count< niz.length; count++) {
    option = new Option(niz[count].sVar , niz[count].sValue);
    document.fRegister.f_advertisingPrice.options[count] = option;
  }
 } else {
    document.fRegister.f_advertisingPrice.options[0] = Option('-------------------------------', '');
 }
}	 

function setLoadPriceList() {
	for ( i=0; i<3; i++ ) 
	{
		if ( document.fRegister.f_advertisingType[ i ].checked ) {
			makePriceList( document.fRegister.f_advertisingType[ i ].value )
		}
	}
}	 


function fillCategoriesForGroups( _groups ) {
	if (_groups != "") {
		niz = eval( 'group' + _groups );
		document.fFullSearch.fCategory.options.length = 0;
	 	for (count=0; count< niz.length; count++) {
	   	option = new Option(niz[count].sVar , niz[count].sValue);
	   	document.fFullSearch.fCategory.options[count] = option;
	 	}
	}
	fillCategoriesForBrands( _groups );
}	 

function fillCategoriesForBrands( _groups ) {
	if (_groups != "") {
		niz = eval( 'brand' + _groups );
		document.fFullSearch.fBrandID.options.length = 0;
	 	for (count=0; count< niz.length; count++) {
	   	option = new Option(niz[count].sVar , niz[count].sValue);
	   	document.fFullSearch.fBrandID.options[count] = option;
	 	}
	}
}	


function goToPage( nID ) {
	if ( nID ) {
		document.fSearchResults.nPage.value = nID;
		document.fSearchResults.submit();
	}
}	

// =============== Default functions ========================
// ==========================================================

function top() {
  window.scrollTo(0, 0);
}


function back() {
  history.back();
} 



// AJAX functions
// ========= Add to stats

function sendBanner( nID ) 
{
	  if( window.XMLHttpRequest ) { http_request = new XMLHttpRequest(); }
	  else if( window.ActiveXObject ) { http_request = new ActiveXObject( 'Microsoft.XMLHTTP' ); }
	  http_request.open( 'get', 'http://naucat.dobbin.local/app_add_stats.asp?id='+ nID, true );
	  http_request.send( null );
}