
// fine gestione del menu laterale servizi

//configure the two variables below to match yoursite's own info
var bookmarkurl="http://www.masterin.it"
var bookmarktitle="MasterIN.it - Il sito dedicato alla formazione post-laurea"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


// rev03.29.1999 -- DO NOT MODIFY! -- Begin date display function with y2k compatibility

var pong;

function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}




// ---- fine gestione tasto destro 


function SendStr(str,pag) {

	document.frmStrRicerca.action = pag + "?" + str
	document.frmStrRicerca.target = "_self"
	document.frmStrRicerca.submit()
}

function apripop(str) {
        searchWin = window.open(str,'apripop','scrollbars=yes,resizable=yes,width=400,height=650,status=yes,location=no,toolbar=no');
        searchWin.focus()
	}

function apripop2(str) {
	searchWin = window.open(str,'apripop2','scrollbars=yes,resizable=yes,width=610,height=600,status=yes,location=no,toolbar=no');
	searchWin.focus()
}

function apripop3(str) {
	searchWin = window.open(str,'apripop3','scrollbars=yes,resizable=yes,width=610,height=600,status=yes,location=no,toolbar=no');
	searchWin.focus()
}


/***********************************************
* Cool DHTML tooltip script II-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"><'+'/div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="../arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight || 2 > 1){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

/***********************************************
* Cool DHTML tooltip script II-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function mylist_tip( nid ) {
	
	image_elements = $("#img_" +  nid)
	image_src = image_elements.attr( "src")
	
	if (image_src == "../img/img2007/ico-mylist-off.gif" ){
		ddrivetip('<b>Rimuovi dalla lista alla lista</b>',180)
	} else {
		ddrivetip('<b>Aggiungi alla lista</b>',180)
	}	
	

}



function updatecokieslist( name , value ) {
	
	var cookieslist_temp = new Array()
	
	additem = true
	for (var item in cookieslist) {
		
		if ( cookieslist[item] != value ) {
				
				if ( !isNaN( cookieslist[item] ) ) {
					//alert( "ciclo " + cookieslist[item])
					cookieslist_temp.push( cookieslist[item] )	
					}
					

			} else {
				additem = false
			}

	}
	//alert("temp: " + cookieslist_temp)
	
	if (additem) {
		cookieslist_temp.push(value)		
		
		//alert("trasfer : " + value )
		//alert(  $("#wrapper_"+value).html() )
		//$("#wrapper_"+value).TransferTo({to: "itemcount", className: 'transfer', duration: 500});
		//	TransferTo({to:'menulist',className:'bordato', duration: 400});
		
	}
	
	cookieslist = cookieslist_temp 
	
	if (cookieslist.length == 0 && additem) {
		cookieslist.push( value )
	}

	nitem = cookieslist.length

	
	
	//alert( "scrivo: " + cookieslist)
	$.cookie( name , cookieslist , { expires: 30, path: '/' } ); 
	
}
	
	var cookiesname = "masterin_mialista"
	var cookiesvalue = $.cookie(cookiesname)	
	var cookieslist = new Array()
	var nitem = 0

window.onload = function(){

   $(".loading").hide();
   
   //$("#btn_cercamaster").show().click( box_slidedown )
   //$("#btn_ScuoleGrowStart").show().click( function() { GrowStart('popup_scuole');  return false; } )
   
   //$("#btn_RegioCheckConfirm").click( function() { CheckConfirm('elenco_regioni','regione','popup_regio');  return false; } )
   //$("#btn_MacroCheckConfirm").click( function() { CheckConfirm('elenco_categorie','categoria','popup_macro');  return false; } )
   
   tb_init("#btn_RegioOpen,#btn_CatOpen");//pass where to apply thickbox
   

   $("#regione").focus( function(){ $("#btn_RegioOpen").click() })
   $("#categoria").focus( function(){ $("#btn_CatOpen").click() })
   
	
   $(".mylist" ).click(function() { 

		id_elements = this.id
		id_elements = parseInt(id_elements.replace("id_",""));
		//alert("cookies: " + id_elements );
		
		image_elements = $("#img_" + id_elements)
		image_src = image_elements.attr( "src")
		
		if (image_src == "../img/img2007/ico-mylist-off.gif" ){
			image_elements.attr( "src","../img/img2007/ico-mylist-on.gif" )
		} else {
			image_elements.attr( "src","../img/img2007/ico-mylist-off.gif" )
		}
		
		/*
		if ( image_elements.src("background-color") == "transparent" ) {
		
		} else {
		
		}
		*/
		
		updatecokieslist( cookiesname , id_elements ); 
		
		$("#mylist").html("La Mia Lista (" + nitem + ")" )
		
		if ( nitem == 0 ) {
			$("#mylist").removeClass("active")
		}else {
			$("#mylist").removeClass("active")
			$("#mylist").addClass("active")
		
			$("#mylist_wrapper").animate({opacity: 'hide'}, "fast");
			$("#mylist_wrapper").animate({opacity: 'show'}, "fast");
			$("#mylist_wrapper").animate({opacity: 'hide'}, "fast");
			$("#mylist_wrapper").animate({opacity: 'show'}, "fast");
			$("#mylist_wrapper").animate({opacity: 'hide'}, "fast");
			$("#mylist_wrapper").animate({opacity: 'show'}, "fast");			
		}
		

		
		
		
		//alert( cookiesvalue );		
		
		return false;
		
   });
   

   // gestione generica tooltips 
   $("div#box_cercamaster input[@title]").hover( function () { ddrivetip(this.getAttribute("title"),150) } , hideddrivetip )	
   
   $(".btn_GrowDown").click( function() { $(".scroll").css("overflow","hidden"); GrowDown() ;return false; } )

   if ( location.pathname.indexOf("ricerca_avanzata.asp") > 0  ||  location.pathname.indexOf("home.asp") > 0  ) { $("div#box_cercamaster").show() }
   
   $("#box_search_submit").hover(
	function(){ $(this).css("background-position","top"); },
	function(){ $(this).css("background-position","bottom"); }
   );
   
  $("td.cella_sfondo").hover(
   function(){ this.className='cella_sfondoover'; },
   function(){ this.className='cella_sfondo'}
   );
  
  
  $("#select_network").change( function() { 
   window.open( this.value )  ; 
   //document.location.href = this.value  
   } )
   
 };


