function textCounter(field, countfield, maxlimit) {
/*
* The input parameters are: the field name;
* field that holds the number of characters remaining;
* the max. numb. of characters.
*/ 
if (field.value.length > maxlimit) // if the current length is more than allowed
field.value =field.value.substring(0, maxlimit); // don't allow further input
else
countfield.innerHTML = maxlimit - field.value.length;} // set the display field to remaining number

function imagePreview(src, w, h){
	if ( parent.pero ) { pero.close(); }
	pero=window.open( '', '', 'width='+(w+0)+', height='+(h+0)+', top=100,left=300,scrollbars=no,status=no,toolbar=no,menubar=no,location=no');
	pero.document.write('<head><title>Image Preview</title></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">');
	pero.document.write("<a href='javascript:window.close()'><img border=0 src='"+src+"' alt='close'></a></body>")
	pero.focus();
	return false;
}

function help(url) {
	var noviProzor = popup(url,'Pomoc',900,700,150,300);
	noviProzor.focus();
	return false;
}

function popup(url,title,width,height,top,left) {
	var noviProzor = window.open(url,title,'height='+height+',width='+width+',top='+top+',left='+left+',menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,modal=yes');
	//noviProzor.focus();
	return noviProzor;
}

function modalWin(url,title,width,height){
	popup(url,title,width,height,200,350);	
	return false;
}


function modalWinReturn(elementId,value){
	window.opener.document.getElementById(elementId).value = value;
	window.close(); 
	return false;
}

//function which sets the home page to City24
function setHome(message) {

    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage("http://www.city24.hr/");

    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                    alert(message);
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', "http://www.city24.hr/");
    }
}
