/****************************************************
* Author: Eric King
* Url: http://redrival.com/eak/index.shtml
* This script is free to use as long as this info is left in
* Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
* Example of Use: 
 /// <A HREF="javascript:ScaleWindowToImageSize('img/auto-resizable-pop-up/lg-1.gif')" BORDER="0"><IMG SRC="/img/1.gif" BORDER="0" /></A>
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}

function ScaleWindowToImageSize(img)
{
  foto1= new Image();
  foto1.src=(img);
  Controller(img);
}
function Controller(img)
{
  if((foto1.width!=0)&&(foto1.height!=0))
  {
    viewFoto(img);
  }
  else
  {
    funzione="Controller('"+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);
}


/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
* Example of use: 
 /// <a href="#" class="hintanchor" onMouseover="showhint('Please choose a username. Should consist of alphanumeric characters only.', this, event, '150px')">[?]</a>
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox



/*******************************************
* 
* SHOW/HIDE DIV
* Example of Use: 
//  <a href="#" OnClick="toggleDiv('DivNotificationOptions')">Show/Hide the Div</a>
//  <div id="DivToShowOrHide" style="display: none;">stuff to show/hide</div>
********************************************/
function toggleDiv(divID) {
	if (document.getElementById(divID).style.display == 'none')
		document.getElementById(divID).style.display = 'block';
	else
		document.getElementById(divID).style.display = 'none';
}







/***********************************************************************************************************
* SLIDE OUT MENU - Right Side
* PLEASE NOTE: this uses the Scriptaculous JavaScript Code Library
*
* Example of Use:
    <table border="1">
	    <tr>
		    <td width="100%">content</td>
		    <td>
			    <div id="menu" style="width: 200px; height: 300px; background-color: red;">
			    this is the right column
			    </div>
		    </td>
		    <td><a href="#" onclick="toggleElement('menu');">toggle</a></td>
	    </tr>
    </table>
************************************************************************************************************/
function toggleElement(el) {
	if ($(el).style.display == 'none')
		Effect.BlindLeft(el);
	else
		Effect.BlindRight(el);
}




/***********************************************************************************************************
* SLIDE OUT MENU - Left Side

* (C) www.dhtmlgoodies.com, October 2005
*
* Version 1.2: Updated, November 12th. 2005
*
* This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
*
* Terms of use:
* You are free to use this script as long as the copyright message is kept intact. However, you may not
* redistribute, sell or repost it without our permission.
* Thank you!
* www.dhtmlgoodies.com
* Alf Magne Kalleland
*
* Example of Use:
// <div id="dhtmlgoodies_leftPanel">
// 	<a class="closeLink" href="#" onclick="initSlideLeftPanel();return false">Close</a>
// 	<div id="leftPanelContent">
// 	<!-- This is the content -->
// 	     text and stuff goes in here!
// 	<!-- End content -->
// 	</div>
//  </div>
// 
//  <a href="#" onclick="initSlideLeftPanel();return false">Show help panel</a>
************************************************************************************************************/		
var panelWidth = 150;	// Width of help panel	
var slideSpeed = 50;		// Higher = quicker slide
var slideTimer = 1;	// Lower = quicker slide
var slideActive = true;	// Slide active ?
var initBodyMargin = 0;	// Left or top margin of your <body> tag (left if panel is at the left, top if panel is on the top)
var pushMainContentOnSlide = true;	// Push your main content to the right when sliding
var panelPosition = 0; 	// 0 = left , 1 = top

/*	Don't change these values */
var slideLeftPanelObj=false;
var slideInProgress = false;	
var startScrollPos = false;
var panelVisible = false;
function initSlideLeftPanel(expandOnly)
{
	if(slideInProgress)return;
	if(!slideLeftPanelObj){
		if(document.getElementById('dhtmlgoodies_leftPanel')){	// Object exists in HTML code?
			slideLeftPanelObj = document.getElementById('dhtmlgoodies_leftPanel');
			if(panelPosition == 1)slideLeftPanelObj.style.width = '100%';
		}
		else{	// Object doesn't exist -> Create <div> dynamically
			slideLeftPanelObj = document.createElement('DIV');
			slideLeftPanelObj.id = 'dhtmlgoodies_leftPanel';
			slideLeftPanelObj.style.display='none';
			document.body.appendChild(slideLeftPanelObj);
		}
		
		if(panelPosition == 1){
			slideLeftPanelObj.style.top = "-" + panelWidth + 'px';
			slideLeftPanelObj.style.left = '0px';	
			slideLeftPanelObj.style.height = panelWidth + 'px';			
		}
		else{
			slideLeftPanelObj.style.left = "-" + panelWidth + 'px';
			slideLeftPanelObj.style.top = '0px';
			slideLeftPanelObj.style.width = panelWidth + 'px';
		}
		

		if(!document.all || navigator.userAgent.indexOf('Opera')>=0)slideLeftPanelObj.style.position = 'fixed';;
	}	
	
	if(panelPosition == 0){
		if(document.documentElement.clientHeight){
			slideLeftPanelObj.style.height = document.documentElement.clientHeight + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.height = document.body.clientHeight + 'px';
		}
		var leftPos = slideLeftPanelObj.style.left.replace(/[^0-9\-]/g,'')/1;
	}else{
		if(document.documentElement.clientWidth){
			slideLeftPanelObj.style.width = document.documentElement.clientWidth + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.width = document.body.clientWidth + 'px';
		}
		var leftPos = slideLeftPanelObj.style.top.replace(/[^0-9\-]/g,'')/1;			
		
		
	}
	slideLeftPanelObj.style.display='block';
	
	if(panelPosition==1)
		startScrollPos = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	else
		startScrollPos = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
	if(leftPos<(0+startScrollPos)){
		if(slideActive){
			slideLeftPanel(slideSpeed);	
		
		}else{
			document.body.style.marginLeft = panelWidth + 'px';
			slideLeftPanelObj.style.left = '0px';
		}
	}else{
		if(expandOnly)return;
		if(slideActive){		
			slideLeftPanel(slideSpeed*-1);
		}else{
			if(panelPosition == 0){
				if(pushMainContentOnSlide)document.body.style.marginLeft =  initBodyMargin + 'px';
				slideLeftPanelObj.style.left = (panelWidth*-1) + 'px';	
			}else{
				if(pushMainContentOnSlide)document.body.style.marginTop =  initBodyMargin + 'px';
				slideLeftPanelObj.style.top = (panelWidth*-1) + 'px';						
			}			
		}
	}	
	
	if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0){
		window.onscroll = repositionHelpDiv;
	
		repositionHelpDiv();
	}
	window.onresize = resizeLeftPanel;
	
}

function resizeLeftPanel()
{
	if(panelPosition == 0){
		if(document.documentElement.clientHeight){
			slideLeftPanelObj.style.height = document.documentElement.clientHeight + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.height = document.body.clientHeight + 'px';
		}		
	}else{
		if(document.documentElement.clientWidth){
			slideLeftPanelObj.style.width = document.documentElement.clientWidth + 'px';
		}else if(document.body.clientWidth){
			slideLeftPanelObj.style.width = document.body.clientWidth + 'px';
		}	
	}
}

function slideLeftPanel(slideSpeed){
	slideInProgress =true;
	var scrollValue = 0;
	if(panelPosition==1)
		var leftPos = slideLeftPanelObj.style.top.replace(/[^0-9\-]/g,'')/1;
	else
		var leftPos = slideLeftPanelObj.style.left.replace(/[^0-9\-]/g,'')/1;
		
	leftPos+=slideSpeed;
	okToSlide = true;
	if(slideSpeed<0){
		if(leftPos < ((panelWidth*-1) + startScrollPos)){
			leftPos = (panelWidth*-1) + startScrollPos;	
			okToSlide=false;
		}
	}
	if(slideSpeed>0){
		if(leftPos > (0 + startScrollPos)){
			leftPos = 0 + startScrollPos;
			okToSlide = false;
		}			
	}
	
	
	if(panelPosition==0){
		slideLeftPanelObj.style.left = leftPos + startScrollPos + 'px';
		if(pushMainContentOnSlide)document.body.style.marginLeft = leftPos - startScrollPos + panelWidth + 'px';
	}else{
		slideLeftPanelObj.style.top = leftPos + 'px';
		if(pushMainContentOnSlide)document.body.style.marginTop = leftPos - startScrollPos + panelWidth + 'px';			
		
	}
	if(okToSlide)setTimeout('slideLeftPanel(' + slideSpeed + ')',slideTimer); else {
		slideInProgress = false;
		if(slideSpeed>0)panelVisible=true; else panelVisible = false;
	}
	
}


function repositionHelpDiv()
{
	if(panelPosition==0){
		var maxValue = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		slideLeftPanelObj.style.top = maxValue;
	}else{
		var maxValue = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
		slideLeftPanelObj.style.left = maxValue;	
		var maxTop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(!slideInProgress)slideLeftPanelObj.style.top = (maxTop - (panelVisible?0:panelWidth)) + 'px'; 		
	}
}

function cancelEvent()
{
	return false;
}
function keyboardShowLeftPanel()
{
		initSlideLeftPanel();
		return false;	

}

function leftPanelKeyboardEvent(e)
{
	if(document.all)return;
	
	if(e.keyCode==112){
		initSlideLeftPanel();
		return false;
	}		
}

function setLeftPanelContent(text)
{
	document.getElementById('leftPanelContent').innerHTML = text;
	initSlideLeftPanel(true);
	
}
if(!document.all)document.documentElement.onkeypress = leftPanelKeyboardEvent;
document.documentElement.onhelp  = keyboardShowLeftPanel;




/********************************************************************************
* Local Time script- © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
* Example of Use:
  <body onload="goforit()">
  <span id="clock"></span>
**********************************************************************************/

var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate()
{
    var mydate=new Date()
    var year=mydate.getYear()

    if (year < 1000)
        year+=1900

    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()

    if (daym<10)
        daym="0"+daym

    var hours=mydate.getHours()
    var minutes=mydate.getMinutes()
    var seconds=mydate.getSeconds()
    var dn="AM"

    if (hours>=12)
        dn="PM"

    if (hours>12)
    {
        hours=hours-12
    }

    if (hours==0)
        hours=12
      
    if (minutes<=9)
        minutes="0"+minutes

    if (seconds<=9)
        seconds="0"+seconds

    //change font size here
    var cdate=dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn

    if (document.all)
    {
        document.all.clock.innerHTML=cdate
    }
    else if (document.getElementById)
    {
        document.getElementById("clock").innerHTML=cdate
    }
    else
    {
        document.write(cdate)
    }
}

if (!document.all&&!document.getElementById)
{
    getthedate()
}

function goforit()
{
    if (document.all||document.getElementById)
    {
        setInterval("getthedate()",1000)
    }
}




/******************************************************************************
* Clear out the default text in a Textbox and add it back if the user
* clicked into the box then out of it but didn't type anything
*
*
* Example of use:
  <asp:TextBox ID="TextBox1" Text="Default Text" onclick="clickclear(this, 'Default Text')" onblur="clickrecall(this,'Default Text')"></asp:TextBox>
*******************************************************************************/
function clickclear(thisfield, defaulttext) 
{
    if (thisfield.value == defaulttext) 
    {
        thisfield.value = "";
    }
}

function clickrecall(thisfield, defaulttext) 
{
    if (thisfield.value == "") 
    {
        thisfield.value = defaulttext;
    }
}