window.addEvent('domready', function(){
var xmlHttp
	var thetip = new Tips($$('.tips'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 100, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});

    $$('#region').addEvent('change', function(){
        var i;
    	var loc = $('#city');
    	if (loc != null) for (i = loc.options.length; i > 0; i--) loc.options[i] = null;
    	document.getElementById("dcity").innerHTML = "<img src='/js/ajax-loader.gif'></img>";
    	xmlHttp = new function() {
            var xmlHttp=null;
            try { xmlHttp=new XMLHttpRequest(); }
            catch (e) {
             try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
             catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
            }
            return xmlHttp;
        }
    	if (xmlHttp==null) { alert ("Browser does not support HTTP Request");return;}
        	var url="cities.php" + "?region="+this.options[this.selectedIndex].value + "&sid="+Math.random()
        	xmlHttp.onreadystatechange = function (){
             if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
                	document.getElementById("dcity").innerHTML=xmlHttp.responseText
             }
            }
        xmlHttp.open("GET",url,true)
        xmlHttp.send(null)
    });
    if ($$('#results') != undefined) {
       $$('#results a.fbutton').each(function(el) {
		var r = $(el).id.split('-',2);
		$(el).addEvent('click',function(e){
			el = $$('#f'+r[0]+'-'+r[1]);
			var status = el.getStyle('display');										
		    $$('#results div.form').each(function(fo) { fo.setStyle('display', 'none'); });
		    el = $$('#f'+r[0]+'-'+r[1]);
			if ( status == 'none') { el.setStyle('display', 'block');}
			
		    //el.setStyle('width', '100%');
		});
        });
    }	
});

function popup(url, w,h) 
{
	title = 'Modifica CV';
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (url, title, 'toolbar=no, location=false, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 

function popup_print(url, w,h)
{
	title = 'Print';
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (url, title, 'toolbar=no, location=false, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
