﻿// JScript File


//Preloaded slideshow script- By Jason Moon
//For this script and more
//Visit http://www.dynamicdrive.com

// PUT THE URL'S OF YOUR IMAGES INTO THIS ARRAY...

// DO NOT EDIT BELOW THIS LINE!
function CacheImage(ImageSource) { // TURNS THE STRING INTO AN IMAGE OBJECT
   var ImageObject = new Image();
   ImageObject.src = ImageSource;
   return ImageObject;
}

function imgOnError(e) {

        var target=e.target!=null?(e.target.id?e.target:e.currentTarget):e.srcElement;
 target.src = "images/bits/mainPic.gif"

}

function ShowSlide(Direction) {
if (SlideReady) {
   NextSlide = CurrentSlide + Direction;
   // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
   if (document.form1.Previous != null || document.form1.Next != null) {
       document.form1.Previous.disabled = (NextSlide == 0);
       document.form1.Next.disabled = (NextSlide == (Slides.length-1)); }
   if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
            if (!(document.images['Screen'])) return false;
            document.images['Screen'].src = Slides[NextSlide].src;
            CurrentSlide = NextSlide++;
            Message = 'Picture ' + (CurrentSlide+1) + ' of ' + Slides.length;
            self.defaultStatus = Message;
            if (Direction == 1) CacheNextSlide();
      }
      return true;
   }
}

function Download() {
   if (Slides[NextSlide].complete) {
      SlideReady = true;
      self.defaultStatus = Message;
   }
   else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
   return true;
}

function CacheNextSlide() {
   if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 
'string'))
{ // ONLY CACHES THE IMAGES ONCE
      SlideReady = false;
      self.defaultStatus = 'Downloading next picture...';
      Slides[NextSlide] = CacheImage(Slides[NextSlide]);
      Download();
   }
   return true;
}

function StartSlideShow() {
   CurrentSlide = -1;
   Slides[0] = CacheImage(Slides[0]);
   SlideReady = true;
   ShowSlide(1);
}


function dropdown() 
{
    if (document.formAccom.listRegion.value == "-1" )
    {
        document.formAccom.listRegion.selectedIndex ++;
    }
}


function doNotCheck(obj, Type)
{
//alert(Type);
switch (Type) {
    case "Accom":  //sets Accomadation off 
       var cBoxAccom = document.getElementById("cBoxAccomType").getElementsByTagName("input");
       for(var a=0;a<cBoxAccom.length;a++)
       {
            cBoxAccom[a].checked = false;
       }
    break;
    case "StarRating": //sets star rating off 
        document.formAccom.stars5.checked = false
        document.formAccom.stars4.checked = false
        document.formAccom.stars3.checked = false
        document.formAccom.stars2.checked = false
        document.formAccom.stars2.checked = false    
    break;
 
       case "facilities": //Sets facilities off
       var cBoxfacility = document.getElementById("cBoxfacilities").getElementsByTagName("input");
       for(var a=0;a<cBoxfacility.length;a++)
       {
            cBoxfacility[a].checked = false;
       }
    break;
    
        case "chain": //Sets chains off
        //alert(document.formAccom.chain1.checked);
        document.formAccom.chain1.checked = false
        document.formAccom.chain2.checked = false
        document.formAccom.chain3.checked = false
        document.formAccom.chain4.checked = false
        document.formAccom.chain5.checked = false
        document.formAccom.chain6.checked = false
        document.formAccom.chain7.checked = false
//        document.formAccom.chain8.checked = false                                                        
        document.formAccom.chain9.checked = false
        document.formAccom.chain10.checked = false
        document.formAccom.chain11.checked = false
        document.formAccom.chain12.checked = false
    break;
      //default: result = 'unknown';
    }
    
   //keeps ALL checkbox checked
     obj.checked = true; 

}

//for asp:checkBoxList 
 function check(Type) 
 {
    switch (Type) 
    {
    case "Accom": 
        document.formAccom.cBoxAccomTypeall.checked = false; 
    break;
    case "StarRating": 
        document.formAccom.cBoxStarRatingAll.checked = false;
    break;         
    case "facilities": 
        document.formAccom.cBoxFacilitiesALL.checked = false; 
    break;
    case "chain": 
        document.formAccom.chainALL.checked = false; 
    break;
      }
 
 }
 
 	function backToList()
	{
		document.mapForm.pageMode.value=document.mapForm.searchCategory.value ; //'Restore the previous search category
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
		document.mapForm.SortClause.value='';	//Set initial sort clause Charlie Su 14-01-05 to set initial sort 
		document.mapForm.submit();
	}

	function goBackHistory()
	{
    var histCount = document.form1.ClickCount.value
alert(histCount);
	}


function popup(url, width, height, x, y) {
	window.open(url, 'lpi_new', 'menubar=no,scrollbars=yes,resizable=yes,screenX=' + x + ',screenY=' + y + ',top='+ x + ',left=' + x + ',height='+ height + ',width=' + width);
}


////FIX: Internet Explorer has a bug where wrapping a label around an image doesn't work 
//// the same as if you wrap it around text.
//window.onload = function(){
//  if(document.all && navigator.appVersion.indexOf("MSIE")>-1 && navigator.appVersion.indexOf("Windows")>-1)
//  {
//    var a = document.getElementsByTagName("label");
//    for(var i=0,j=a.length;i<j;i++){
//      if(a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG")
//      {
//        a[i].childNodes.item(0).forid = a[i].htmlFor;
//        a[i].childNodes.item(0).onclick = function(){
//          var e = document.getElementById(this.forid);
//          switch(e.type){
//            case "radio": e.checked|=1;break;
//            case "checkbox": e.checked=!e.checked;break;
//            case "text": case "password": case "textarea": e.focus(); break;
//          }
//        }
//      }
//    }
//  }
//}