  /* check date */
  var minYear=1900;
  var maxYear=2100;
  /*********************************************/


  /* variables used to set output for calendar */
  var nsCalendarOutputFormId;
  var nsCalendarOutputDayId;
  var nsCalendarOutputMonthId;
  var nsCalendarOutputYearId;
  /*********************************************/

  var _currentGalleryHrefId = -1;

  function showRegion( seo )
  {
    window.location = seo;
  }
  
  /*
  function showRegion( idregion )
  {
    window.location = './aspx/Region.aspx?region=' + idregion;
  }
  */

  function InStr(String1, String2)
{
    var a = 0;
    
    if (String1 == null || String2 == null)
        return (false);
    
    String1 = String1.toLowerCase();
    String2 = String2.toLowerCase();
    
    a = String1.indexOf(String2);
    if (a == -1)
        return 0;
    else
        return a + 1;
}

  function selectRegion( ddlId )
  {
    var v = document.getElementById( ddlId ).value;
    
    if ( v != "__none")
      showRegion( v );
  }
  
  function openInfo( code )
  {
    var scrollbar = 'no';
    switch( code )
    {
      case 'SISTEMAZIONE':
      var width = '445';
      var height = '190';
      break;
      
      case 'OFFERTE':
      var width = '660';
      var height = '560';
      scrollbar = 'yes';
      break;
      
      case 'LOC1':
      case 'LOC2':
      case 'LOC3':
      case 'CATSARDEGNA':
      case 'CATMAREITALIA':
      var width = '300';
      var height = '490';
      break;

      case 'ACI':
      var width = '320';
      var height = '560';
      break;

      default:  //promotion
      var width = '290';
      var height = '200';
      break;
    }

    var page ='/vsuploads/html/info_' + code.toLowerCase() + '.html';
    
    //alert(page);
    popup=window.open( page,'','toolbar=no,scrollbars=' + scrollbar + ',location=no,directories=no,width=' + width + ',height=' + height ); 
    popup.focus();
  }
  
  function openSendToFriends()
  {
    var scrollbar = 'no';      
    var width = '500';
    var height = '550';      
    var popup;
    var page ='../aspx/SendToFriends.aspx';
    
    
    popup = window.open( page,'','toolbar=no,scrollbars=' + scrollbar + ',location=no,directories=no,width=' + width + ',height=' + height ); 
    popup.focus();
  }
  
  function switchAxiomaLeftInfo()
  {
 		axioma = document.getElementById( 'axiomaResearchDiv' );
 		searchImage = document.getElementById( 'imgSearch' );
 		lefInfo = document.getElementById( 'divColumn1Top' );
 		if ( axioma.style.display == 'none' )
 		{
 			axioma.style.display = 'block';
 			//searchImage.src = '../images/closesearch.gif';
 			lefInfo.style.display = 'none';
 		}
 		else
 		{
 			axioma.style.display = 'none';
 			//searchImage.src = '../images/opensearch.gif';
 			lefInfo.style.display = 'block';
 		}
  }

 	function submitAxioma( tipoAccesso, axiomaCode, idDocument, errorMessage )
 	{
 	  if ( errorMessage == null )
 	    errorMessage = "Invalid date";
 	  
 	  //Set axioma accessn type
 	  document.getElementById('p_pagina').value  = tipoAccesso;
 	  
 	  if ( (axiomaCode != null) && (document.getElementById('p_servizio') != null) )
 	  {
 	    document.getElementById('p_servizio').value  = axiomaCode;
 	  }
 	  if ( idDocument != null )
 	  {
 	    document.getElementById('axioma_dd').value   = document.getElementById( 'dd_'   + idDocument ).value;
 	    document.getElementById('axioma_mm').value   = document.getElementById( 'mm_'   + idDocument ).value;
 	    document.getElementById('axioma_yyyy').value = document.getElementById( 'yyyy_' + idDocument ).value;
 	  }
 	  
 	  var dd    = document.getElementById('axioma_dd')!= null ? document.getElementById('axioma_dd').value : '';
 	  var mm    = document.getElementById('axioma_mm')!= null ? document.getElementById('axioma_mm').value : '';
 	  var yyyy  = document.getElementById('axioma_yyyy')!= null ? document.getElementById('axioma_yyyy').value : '';

    // 18-09-2007 Ste: Rimosso questo if.... è inutile e permette di inserire delle date errate!
    //if( dd != '' && mm != '' && yyyy == '' )
    //{
      if ( !isDate( dd, mm, yyyy ) )
      {
        alert( errorMessage );
        return;
      }
    //}
 	  
 	  var formaActionBefore = document.getElementById('Form').action;
 	  // Attention!!!
 	  // Form id must be 'Form'
	  newwin=window.open('','Axioma','height=400, width=500,status= no, resizable= no, scrollbars=yes, toolbar=no,location=no,menubar=no '); 
	  document.getElementById('Form').target='Axioma';
	  document.getElementById('Form').action='../aspx/Axioma.aspx';
	  document.getElementById('Form').submit();
	  //set previous values for page form
	  document.getElementById('Form').target = '';
	  document.getElementById('Form').action = formaActionBefore;
  }

 	function submitAxiomaIframe( seoBooking, code, idDocument, errorMessage )
 	{
 	  var urlToGo = seoBooking + '?code=' + code;
 	  if ( errorMessage == null )
 	    errorMessage = "Data non valida";
 	  
 	  if ( idDocument == null )
 	  {
 	    alert("Si è verificato un errore imprevisto");
 	    return;
 	  }
 	  
 	  var dd    = document.getElementById('dd_'   + idDocument)!= null ? document.getElementById('dd_'   + idDocument).value : '';
 	  var mm    = document.getElementById('mm_'   + idDocument)!= null ? document.getElementById('mm_'   + idDocument).value : '';
 	  var yyyy  = document.getElementById('yyyy_' + idDocument)!= null ? document.getElementById('yyyy_' + idDocument).value : '';

    if ( !isDate( dd, mm, yyyy ) )
    {
      alert( errorMessage );
      return;
    }
    urlToGo += '&dd=' + dd + '&mm=' + mm + '&yyyy=' + yyyy;
    
    var stagingsite = document.getElementById('stagingsite');
    if( stagingsite != null )
    {
      urlToGo += '&stagingsite=' + stagingsite.options[stagingsite.selectedIndex].value;
    }
    
    document.location.href =  urlToGo; 
  }

  function showHideBox( idImg, idBox, guiElementsPrefix )
 	{
 		box = document.getElementById( idBox );
 		img = document.getElementById( idImg );
 		if ( box.style.display == 'none' || box.style.display == '' )
 		{
 			box.style.display = 'block';
			img.src = guiElementsPrefix + '/images/show_box_up.gif';
 		}
 		else
 		{
 			box.style.display = 'none';
 			img.src = guiElementsPrefix + '/images/show_box_down.gif';
 		}
 	}
  
  function showCalendar( formId, outputDayId, outputMonthId, outputYearId )
  {
    nsCalendarOutputFormId  = formId;
    nsCalendarOutputDayId   = outputDayId;
    nsCalendarOutputMonthId = outputMonthId;
    nsCalendarOutputYearId  = outputYearId;
    var calendar = window.open( applicationBasePath + 'aspx/NsCalendar.aspx','nscalendar','height=170, width=180,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no');     
    calendar.focus();
  }
  
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(strDay, strMonth, strYear){
	var daysInMonth = DaysArray(12)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	
  return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }

function selectStructure( ddlId, quarter )
{
  /*
  var v = document.getElementById( ddlId ).value;
  
  if ( v != "__none")
    window.location = '../aspx/Structure.aspx?code=' + v + '&quarter=' + quarter;
  */
}

function showGallery( code, language )
{
  var r = window.open( 'Gallery.aspx?code=' + code + '&lang=' + language, 'gallery', 'width=740,height=500' );
  r.focus();
}
function showMap( code, language )
{
  var r = window.open( 'Map.aspx?code=' + code + '&lang=' + language, 'map', 'width=740,height=500' );
  r.focus();
}

function openCloseStructure( n, guiElementsPrefix )
{
  var c = document.getElementById('divSubStructureBody_'+ n);
  var i = document.getElementById('imgSubStructureOpenClose_'+ n);
  
  if ( c.style.display == 'block' )
  {
    c.style.display = 'none';
    i.src = guiElementsPrefix + '/images/show_structure_down.gif';
  }
  else
  {
    c.style.display = 'block';
    i.src = guiElementsPrefix + '/images/show_structure_up.gif';
  }
}

function openReservedNotes( code, language )
{
  var r = window.open( 'ReservedNotes.aspx?code=' + code + '&lang=' + language, 'res', 'width=600,height=420' );
  r.focus();
}


function writeFlashHomePage( movie, flashVars, height, width )
{
  document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="vacanzeMappa" align="middle" viewastext="viewastext">');
  document.write( '<param name="allowScriptAccess" value="sameDomain" />');
	document.write( '<param name="movie" value="' + movie + '" />');
	document.write( '<param name="quality" value="high" />');
	document.write( '<param name="bgcolor" value="#f2f2f2" />');
	document.write( '<param name="FlashVars" value="' + flashVars + '" />' );
	document.write( '<embed src="' + movie + '" quality="high" bgcolor="#f2f2f2" width="' + width + '" height="' + height + '" name="vacanzeMappa" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="' + flashVars + '" />');
	document.write( '</object>');
}

function writeFlashHomePageSpot( movie, flashVars, height, width )
{
  document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="homeSpot" align="middle">');
  document.write( '<param name="movie" value="' + movie + '" />');
  document.write( '<param name="quality" value="high" />');
  document.write( '<param name="allowScriptAccess" value="always" />');
  document.write( '<param name="devicefont" value="true" />');
  document.write( '<param name="bgcolor" value="#f2f2f2" />');
  document.write( '<param name="FlashVars" value="' + flashVars + '" />');
  document.write( '<embed src="' + movie + '" FlashVars="' + flashVars + '" allowScriptAccess=always quality="high" devicefont="true"  bgcolor="#f2f2f2" width="' + width + '" height="' + height + '" name="images" align="middle"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
  document.write( '</object>');
}

function spotClick( p )
{
  window.location.href = p;
}

function showImage( file, hrefId, w ) {
  
  if ( w == null )
    w = 640;
  
  if ( document.getElementById( 'divCurrentLocalityDescription' ) != null )
    document.getElementById( 'divCurrentLocalityDescription' ).style.display = 'none';
  
  if ( document.getElementById( 'divEnlargedImage' ) != null )
    document.getElementById( 'divEnlargedImage' ).style.display = 'block';
  
  document.getElementById('imgEnlarged').src = '../aspx/ShowImage.aspx?f=' + file + '&w=' + w + '&h=330';
  _currentGalleryHrefId = hrefId;

  var sequenceArea = document.getElementById( 'divSequenceArea' );
  var hrefs = sequenceArea.getElementsByTagName( 'a' );
  var canDoNext = true;
  var canDoPrev = true;
  

  for( i = 0; i < hrefs.length; i++ )
  {
    if ( hrefs[i].id == _currentGalleryHrefId )
    {
      canDoNext =  i < hrefs.length - 1;  // can do next only if nextHref is not the last
      canDoPrev = i > 0;  // can do prev only if nextHref is not the first
      break;
    }
  }
  
  document.getElementById( 'hrefNext' ).style.visibility = canDoNext ? 'visible' : 'hidden';
  document.getElementById( 'hrefPrev' ).style.visibility = canDoPrev ? 'visible' : 'hidden';
  
}

function showPrev() {
  var sequenceArea = document.getElementById( 'divSequenceArea' );
  var hrefs = sequenceArea.getElementsByTagName( 'a' );
  var nextHref = null;
  
  for( i = 0; i < hrefs.length; i++ )
  {
    if ( hrefs[i].id == _currentGalleryHrefId )
    {
      nextHref = hrefs[i-1];
      break;
    }
  }
  
  eval( nextHref.href.replace( 'javascript:%20void%20', '' ) );
}

function showNext() {
  var sequenceArea = document.getElementById( 'divSequenceArea' );
  var hrefs = sequenceArea.getElementsByTagName( 'a' );
  var nextHref = null;
  
  for( i = 0; i < hrefs.length; i++ )
  {
    if ( hrefs[i].id == _currentGalleryHrefId )
    {
      nextHref = hrefs[i+1];
      break;
    }
  }
  
  eval( nextHref.href.replace( 'javascript:%20void%20', '' ) );
}

function getRegionIdByItalianName( n )
{
    switch ( n.toLowerCase() )
    {
      case 'sardegna':
        return 6;
      
      case 'liguria':
        return 8;
      
      case 'toscana':
        return 46;
      
      case 'lombardia':
        return 47;
        
      case 'campania':
          return 48;
        
      case 'lazio':
          return 49;
        
      case 'sicilia':
          return 50;
        
      case 'veneto':
          return 51;
        
      case 'piemonte':
          return 52;
        
      case 'puglia':
          return 53;
        
      case 'emiliaromagna':
          return 54;
        
      case 'calabria':
          return 55;
        
      case 'marche':
          return 56;
        
      case 'abruzzo':
          return 57;
        
      case 'friuliveneziagiulia':
          return 58;
        
      case 'rentinoaltoadige':
          return 59;
        
      case 'umbria':
          return 60;
        
      case 'basilicata':
          return 61;
        
      case 'molise':
          return 62;
        
      case 'valledaosta':
          return 63;
    }
    
    return 'noCodeFound';
}

function openRegionGallery( regionName, language )
{
  var r = window.open( '/aspx/Gallery.aspx?region=' + getRegionIdByItalianName( regionName ) + '&lang=' + language, 'gallery', 'width=740,height=500' );
  r.focus();
}

function showLocalityDescription( id )
{
  var divSource = document.getElementById( 'divLocalityDescription_' + id );
  var divDestination = document.getElementById( 'divCurrentLocalityDescription' );
  
  if ( divSource != null && divDestination != null )
  {
    document.getElementById( 'divEnlargedImage' ).style.display = 'none';
    divDestination.style.display = 'block';
    divDestination.innerHTML = divSource.innerHTML;
  }
  
}

function openLocalityDescriptionWindow()
{
  var r = window.open( '../aspx/LocalityDescription.aspx', 'ld', 'width=600,height=400' );
  r.focus();
}


function getCodXDescription( codX, language, isLongDescription )
{
  switch ( language.toLowerCase() )
  {
    case 'it':
    
      switch ( codX )
      {
        case 'A':
          return isLongDescription ? "I migliori \"hotel all'italiana\" per tutti: coppie d'ogni eta', famiglie, viaggi di nozze. Sempre in posizioni turisticamente valide e con servizi di qualita', in riferimento al livello del prezzo." : "Hotel Classico";
  
        case 'B':
          return isLongDescription ? "Le famiglie qui trovano tutto per sentirsi a loro agio, i bambini trovano assistenza e divertimento." : "Hotel Famiglia";
          
        case 'C':
          return isLongDescription ? "Sia le coppie che le famiglie che i single d'ogni eta' trovano qui la giusta atmosfera, con sport, intrattenimenti e animazione soft." : "Hotel Club";
          
        case 'D':
          return isLongDescription ? "Complessi ricettivi in genere distribuiti in ampie aree verdi. Ambiente elegante con un pizzico di internazionalita' e intrattenimenti in giusta misura." : "Resort";
          
        case 'E':
          return isLongDescription ? "Centri vacanza inseriti in ampie aree verdi, a volte con differenti tipologie abitative. Qui animazione, divertimento e sport sono assicurati per giovani, gruppi di amici, famiglie. E con i Mini e Junior Club anche i ragazzi di ogni età trovano il loro ambiente su misura." : "Villaggio";
          
        case 'M':
          return isLongDescription ? "L'eccellenza italiana nell'ospitalita', il fascino italiano. Complessi di varie tipologie sempre caratterizzati da un \"qualcosa in piu'\": una struttura di prestigio, un luogo particolarmente suggestivo, un ambiente particolare per eleganza, discrezione, fascino, arredamento, cura dei servizi." : "Italian Charme";
          
        case 'N':
          return isLongDescription ? "Complessi di varie tipologie caratterizzati da prezzo accessibile, ambienti informali e a volte essenziali, ma spesso in posizioni interessanti per visite, vacanze sportive, divertimento. Ideali per chi privilegia questi aspetti della vacanza." : "Casual";
          
        case '1':
          return isLongDescription ? "La Formula Residence si distingue dalla Formula Hotel per la presenza dell'angolo di cottura e quindi la possibilita' di cucinare i cibi, e per l'assenza dei servizi di biancheria e riassetto della camera salvo che non venga diversamente indicato. Il Residence propriamente detto, o Residenza Turistico Alberghiera, offre in genere sistemazioni all'interno di un complesso organizzato e con una reception comune. Le case e gli appartamenti sono invece di solito distribuiti nell'ambito di una localita' e, a parte la consegna e riconsegna chiavi, potrebbero non offrire alcun altro servizio oltre al puro uso dell'alloggio." : "Residence";
          
        case '2':
          return isLongDescription ? "Mentre il Residence propriamente detto offre in genere sistemazioni all'interno di un complesso organizzato con una reception e dei servizi comuni, villini case ed appartamenti sono invece di solito distribuiti nell'ambito di una località o di una zona residenziale e, a parte la consegna e riconsegna chiavi, potrebbero non offrire alcun altro servizio oltre al puro uso dell'alloggio" : "Case";
      }
    
      break;
    
    case 'en':
  
      switch ( codX )
      {
        case 'A':
          return isLongDescription ? "I migliori \"hotel all'italiana\" per tutti: coppie d'ogni eta', famiglie, viaggi di nozze. Sempre in posizioni turisticamente valide e con servizi di qualita', in riferimento al livello del prezzo." : "Hotel Classico";
  
        case 'B':
          return isLongDescription ? "Le famiglie qui trovano tutto per sentirsi a loro agio, i bambini trovano assistenza e divertimento." : "Hotel Famiglia";
          
        case 'C':
          return isLongDescription ? "Sia le coppie che le famiglie che i single d'ogni eta' trovano qui la giusta atmosfera, con sport, intrattenimenti e animazione soft." : "Hotel Club";
          
        case 'D':
          return isLongDescription ? "Complessi ricettivi in genere distribuiti in ampie aree verdi. Ambiente elegante con un pizzico di internazionalita' e intrattenimenti in giusta misura." : "Resort";
          
        case 'E':
          return isLongDescription ? "Centri vacanza inseriti in ampie aree verdi, a volte con differenti tipologie abitative. Qui animazione, divertimento e sport sono assicurati per giovani, gruppi di amici, famiglie. E con i Mini e Junior Club anche i ragazzi di ogni età trovano il loro ambiente su misura." : "Villaggio";
          
        case 'M':
          return isLongDescription ? "L'eccellenza italiana nell'ospitalita', il fascino italiano. Complessi di varie tipologie sempre caratterizzati da un \"qualcosa in piu'\": una struttura di prestigio, un luogo particolarmente suggestivo, un ambiente particolare per eleganza, discrezione, fascino, arredamento, cura dei servizi." : "Italian Charme";
          
        case 'N':
          return isLongDescription ? "Complessi di varie tipologie caratterizzati da prezzo accessibile, ambienti informali e a volte essenziali, ma spesso in posizioni interessanti per visite, vacanze sportive, divertimento. Ideali per chi privilegia questi aspetti della vacanza." : "Casual";
          
        case '1':
          return isLongDescription ? "La Formula Residence si distingue dalla Formula Hotel per la presenza dell'angolo di cottura e quindi la possibilita' di cucinare i cibi, e per l'assenza dei servizi di biancheria e riassetto della camera salvo che non venga diversamente indicato. Il Residence propriamente detto, o Residenza Turistico Alberghiera, offre in genere sistemazioni all'interno di un complesso organizzato e con una reception comune. Le case e gli appartamenti sono invece di solito distribuiti nell'ambito di una localita' e, a parte la consegna e riconsegna chiavi, potrebbero non offrire alcun altro servizio oltre al puro uso dell'alloggio." : "Residence";
          
        case '2':
          return isLongDescription ? "Mentre il Residence propriamente detto offre in genere sistemazioni all'interno di un complesso organizzato con una reception e dei servizi comuni, villini case ed appartamenti sono invece di solito distribuiti nell'ambito di una località o di una zona residenziale e, a parte la consegna e riconsegna chiavi, potrebbero non offrire alcun altro servizio oltre al puro uso dell'alloggio" : "Case";
      }
  
      break;
  }
  return '.';
}

	/*######## Gallery ########*/
	
	
	
	
	var arrowImageHeight = 35;	// Height of arrow image in pixels;
	var displayWaitMessage=true;	// Display a please wait message while images are loading?
	
	var previewImage = false;
	var previewImageParent = false;
	var slideSpeed = 0;
	var previewImagePane = false;
	var slideEndMarker = false;
	var galleryContainer = false;
	var imageGalleryCaptions = new Array();
	function getTopPos(inputObj)
	{		
	
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
		
	function showPreview(newSrc,imageIndex)
	{
		if(!previewImage){
			var images = document.getElementById('previewPane').getElementsByTagName('IMG');
			if(images.length>0){
				previewImage = images[0];
			}else{
				previewImage = document.createElement('IMG');
				document.getElementById('previewPane').appendChild(previewImage);	
			}
			
			
		}
		if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}

		previewImage.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); };				
		previewImage.src = newSrc;
		
	}
	function hideWaitMessageAndShowCaption(imageIndex)
	{
		document.getElementById('waitMessage').style.display='none';	
	}	
	
	function initSlide(e)
	{
		if(document.all)e = event;
		
		if(this.src.indexOf('over')<0)this.src = this.src.replace('.gif','-over.gif');
		
		slideSpeed = e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop) - getTopPos(this);
		if(this.src.indexOf('down')>=0){
			slideSpeed = (slideSpeed)*-1;	
		}else{
			slideSpeed = arrowImageHeight - slideSpeed;
		}
		slideSpeed = Math.round(slideSpeed * 10 / arrowImageHeight);
	}
	
	function stopSlide()
	{		
		slideSpeed = 0;
		this.src = this.src.replace('-over','');
	}
	
	function slidePreviewPane()
	{
		if(slideSpeed!=0){
			var topPos = previewImagePane.style.top.replace(/[^\-0-9]/g,'')/1;	
		
			if(slideSpeed<0 && slideEndMarker.offsetTop<(previewImageParent.offsetHeight - topPos)){
				slideSpeed=0;
			
			}
			topPos = topPos + slideSpeed;
			if(topPos>0)topPos=0;

		 	previewImagePane.style.top = topPos + 'px';
	 	
		}
	 	setTimeout('slidePreviewPane()',30);		
	}
	
	function revealThumbnail()
	{
		this.style.filter = 'alpha(opacity=50)';
		this.style.opacity = 0.5;
	}
	
	function hideThumbnail()
	{
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;
	}
	
	function initGalleryScript()
	{
		previewImageParent = document.getElementById('theImages');
		previewImagePane = document.getElementById('theImages').getElementsByTagName('DIV')[0];
		previewImagePane.style.top = '0px';
		galleryContainer  = document.getElementById('galleryContainer');
		var images = previewImagePane.getElementsByTagName('IMG');
		for(var no=0;no<images.length;no++){
			images[no].onmouseover = revealThumbnail;
			images[no].onmouseout = hideThumbnail;
		}	
		slideEndMarker = document.getElementById('slideEnd');
		
		document.getElementById('arrow_up_image').onmousemove = initSlide;
		document.getElementById('arrow_up_image').onmouseout = stopSlide;
		
		document.getElementById('arrow_down_image').onmousemove = initSlide;
		document.getElementById('arrow_down_image').onmouseout = stopSlide;
		var divs = previewImageParent.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			//if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
		}		
		slidePreviewPane();
		
	}
	
	function validateEmail( email )
  {  
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if ( filter.test( email ) )
      return true;
    else
      return false;
}

function showHideSideBarPart( elementId, tlId )
{
  var el = document.getElementById( elementId );
  var tl = document.getElementById( tlId );
 

  if ( el == null )
    return;
  
  if ( el.style.display == 'none' )
  {
    el.style.display = 'block';
    tl.className = 'active';
    }
  else
  {
    el.style.display = 'none';
    tl.className = '';
    }
}
/**************** SELECT TAB ***************/		
function selectTab(tabElem, box, urlToDownload)
{
	tabContainer = document.getElementById('offertTabMenu');
	menuItem = tabContainer.getElementsByTagName('li');
	boxItem = document.getElementsByTagName('div');
	boxToShow = document.getElementById(box);
	
	for(var i=0; i < menuItem.length; i++)
	{ 					
			menuItem[i].className=""
	}
	for(var i=0; i < boxItem.length; i++)
	{ 					
		if(boxItem[i].className.match(/(regionTabCont)/))
	 	{ 
			boxItem[i].style.display="none"
	 	}
	}
	tabElem.className="active"
	boxToShow.style.display="block"
	
  if ( urlToDownload != null && !_loaded)
  {
    GDownloadUrl( urlToDownload + _allStructuresListUrlParams, function(data, responseCode) {
      if ( responseCode != '200' || data == null || data == '' )
      {
        alert( 'Error:\nresponseCode: ' + responseCode + '\ndata: ' + ( data == null ? 'NULL' : '' ) );
        return;
      }
      
      boxToShow.innerHTML = data;
      _loaded = true;
    });
  }
}
	/*
	function gaLoadImg( imgTagName, imgUrl )
	{
	  var imgs = document.getElementsByTagName( 'img' );
	  for ( i = 0; i < imgs.length; i++ )
	  {
	    if ( imgs[i].name.indexOf( 'gaImg_' ) == 0 )
	      imgs[i].src = imgUrl;
	  }
	}
	*/
	
	/*#### Booking Form #####*/
	function isNotValidEmail(elem) {
				var str = elem.value;
				var re  = /\b[a-z0-9._%-]+@[a-z0-9._%-]+\.[a-z0-9._%-]{2,4}\b/;
				if (!str.match(re))
					return false;
				else
					return true;
			}

function advFileUploadOpen( fileId, updatePanelId )
{
  // used only from BO, so double ".."
  window.open('../../aspx/FileWebViewAttributeUpload.aspx?ida=' + fileId + '&uppid=' + updatePanelId,'fileupload','height=130,width=550,scrollbars=no');
}			
			
			
	