var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;		

if (document.getElementById) {
	isID = 1; isDHTML = 1; 
} else {
	if (document.all) {
		isAll = 1; isDHTML = 1;
	} else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			isLayers = 1; isDHTML = 1;
		}
	}
}

function findDOM(obj,frame_n,withStyle) {
	 if (frame_n) {
		var f=eval(frame_n);
	} else {
		var f=this;
	}
	if (withStyle == 1) {
		if (isID) { 
			return (f.document.getElementById(obj).style) ; 
		} else { 
			if (isAll) { 
				return (f.document.all[obj].style); 
			} else {
				if (isLayers) { 
					return (f.document.layers[obj]); 
				}
			}
		}
	} else {
		if (isID) { 
			return (f.document.getElementById(obj)) ; 
		} else { 
			if (isAll) { 
				return (f.document.all[obj]); 
			} else {
				if (isLayers) { 
					return (f.document.layers[obj]); 
				}
			}
		}
	}
}	

function change_layer(frame_n,obj,tekst) {
	if (findDOM(obj,frame_n,0)) {
		if (frame_n) {
			var f=eval(frame_n);
		} else {
			var f=this;
		}
		if(isLayers) {
			with (f.document[obj].document) {
		    	open ();
		        write (tekst);
		        close ();
			}
		} else if (isAll) {
			f.document.all(obj).innerHTML = tekst;
		} else {
		 	f.document.getElementById(obj).innerHTML = tekst;
		}		
	}
}

function move_change_layer(frame_n,obj,e,tekst) {
	var tempX = 0;
	var tempY = 0;	
	var objHolder = obj;
	obj = findDOM (obj);
	if (obj==null) return;
	if (document.all) {
	  tempX = event.clientX + document.body.scrollLeft;
	  tempY = event.clientY + document.body.scrollTop;
	} else {
	  tempX = e.pageX;
	  tempY = e.pageY;
	}
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}
	obj.style.top  = (tempY -8) + 'px';
	obj.style.left = (tempX -100)  + 'px';
	
	change_layer(frame_n,objHolder,tekst);
	//displayObject( objHolder, true );
}

function get_stylesheet(n) {
	for (i=0; i<document.styleSheets.length; i++) {
		if (document.styleSheets[i].id==n) { //if style sheet is titled n
			return document.styleSheets[i] //return the style sheet we're looking for
		}
	}
}

function get_css_object(s,n) {
	var mysheet=get_stylesheet(n);
	if (mysheet) {
		var myrules=mysheet.cssRules ? mysheet.cssRules: mysheet.rules
		for (i=0; i<myrules.length; i++){
			if(myrules[i].selectorText.toLowerCase()==s){ //find s rule
				return myrules[i];
				break;
			}
		}
	} 
}


function Over(element, cls) { 
	element.className=cls;		  
}
  
function Out(element, cls) {
	element.className=cls;					
}
		
function swapLayer(showlayer,hiddenlayer) {
	showLayer(showlayer);
	hideLayer(hiddenlayer);
}

function showLayer(id) {
	itm = getItem(id);	
	if(!itm) return false;	
    itm.style.display = '';	
	return false;
}

function hideLayer(id) {    
	itm = getItem(id);
	if(!itm) return false;
    itm.style.display = 'none';
	return false;
}

function LayerOnOff(id) {   
	itm = getItem(id);
	if(!itm) return false;
    if (itm.style.display == 'none') {
		itm.style.display = '';
	} else {
		itm.style.display = 'none';
	}
	return false;
}
	
	
function getItem(id) {
	var itm = false;
	if(document.getElementById)
	    itm = document.getElementById(id);
	else if(document.all)
	    itm = document.all[id];
	else if(document.layers)
	    itm = document.layers[id];
	
	return itm;
}

function over_effect(e,nclass){
	if (document.all)
		source4=event.srcElement
	else if (document.getElementById)
		source4=e.target
	
	if (source4.className=="menuitems" || source4.className=="menuitems_over") {
		//source4.className=nclass
	} else {
		while (source4.tagName!="DIV") {
			source4=document.getElementById? source4.parentNode : source4.parentElement
			if (source4.className=="menuitems" || source4.className=="menuitems_over") {
				source4.className=nclass
			}
		}
	}
}

function popup(url,w,h,scroll,name,loc)
{
	if (!name){
		var now = new Date();
   		name = now.getTime();
	}
	myleft=(screen.width)?(screen.width-w)/2:100;
	mytop=(screen.height)?(screen.height-h)/2:100;
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=" + scroll + ",location= " + loc +",directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	return window.open(url,name,settings);	
}


function viewPhoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}	


var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all

function enlarge(which,e){
	if (ie||ns6){
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		crossobj.innerHTML='<img src="'+which+'" border=0>'
		crossobj.style.visibility="visible"
		return false
	}
	
	else if (document.layers){
		document.showimage.document.write('<img src="'+which+'" border=0>')
		document.showimage.document.close()
		return false
	}

	else
		return true
}
function closepreview(){
	crossobj.style.visibility="hidden"
}

/***********************************************
* 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="http://www.boys4u.nl/js/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){
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

