﻿// javascript-request-object 
// Programmed 2002-08-20 by Richard Appelgren (c) 
// version 1.0 
var request = new Object();
request.querystring = function(skey) { 
    var val="", qs, arr = [], nr, key = skey+"="; 
    if(window.location.href.indexOf("?")>-1) { 
        qs = window.location.href.substring(window.location.href.indexOf("?")+1); 
        arr = qs.split("&"); 
        for(var i=0;i<arr.length;i++) { 
            nr = arr[i].lastIndexOf(key); 
            if(nr>-1) { 
                val = arr[i].substring(nr+key.length); 
                break; 
            } 
        } 
    } 
    return val; 
} 
//var theValue = request.querystring("test2")); 
/*
 zooma -object
*/
var zooma = new Object(); 
zooma.openWin = function(url, name, prop) {
    name = (name==null || (name==''))?'PopupWindow':name;
    window.open(url, name, prop);
}
zooma.openMediaWindow = function(url) {
    zooma.openWin(url,'MediaWindowFlash','width=1,height=1,scrollbars=yes,resizable=no,left=100,top=100');
}
zooma.openTextWindow = function(url) {
    zooma.openWin(url,'TextWindow','resizable=yes,scrollbars=yes,location=no,menubar=no,status=yes,top=1,left=1,width=650,height=530');
}
zooma.open800Window = function(url, name) {
    zooma.openWin(url,name,'resizable=yes,scrollbars=yes,location=no,menubar=no,status=yes,top=1,left=1,width=800,height=600');
}
zooma.openXmasWindow = function(url) {
    var strName = 'Holidays'
    zooma.openWin(url,strName,'resizable=yes,scrollbars=no,location=no,menubar=no,status=yes,top=1,left=1,width=800,height=500');
}
zooma.openHuskyWindow = function(url, name) {
    zooma.openWin(url,name,'resizable=yes,scrollbars=yes,location=no,menubar=no,status=yes,top=1,left=1,width=790,height=600');
}
zooma.setMediaWindow = function() {
    /*
        resizes the window and layers, to make
        the media appear in the middle with some margin
    */
    var pageMarginWidth=100, pageMarginHeight=100;
    var contentMarginWidth=10, contentMarginHeight=10;
    var frm = document.getElementById("frmMediaProperties");
    var w = parseInt(frm.width.value);
    var h = parseInt(frm.height.value);
    window.resizeTo(w+pageMarginWidth, h+pageMarginHeight);
    var pageLayer = document.getElementById("pagemedia");
    pageLayer.style.width = w+contentMarginWidth+"px";
    window.focus();
}
zooma.gotoSelectUrl = function(sel) {
    var url = sel.options[sel.options.selectedIndex].value;
    url = (url=='' || (url==null))?'':url;
    if(url!='') {
        window.location.href = sel.options[sel.options.selectedIndex].value;
    }
}
zooma.changePage = function(id, inc) {
    var sel = document.getElementById(id);
    var currentindex=-1;
    for(currentindex=0;currentindex<sel.options.length;currentindex++) {
        if(sel.options[currentindex].value==zooma.currentPageName) {break;}
    }
    // check if this page is the last or first ...
    if((currentindex==-1) || (inc==1 && (currentindex==sel.options.length-1)) || (inc==-1 && (currentindex==0))) {return;}
    if(sel.options[currentindex+inc].value==null || (sel.options[currentindex+inc].value=='')) {return;}
    
    window.location.href = sel.options[currentindex+inc].value;
}

zooma.startPageInit = function() {
    
    //$('#globalbanner')
    $('.localbanneritem').bind('mouseout', null, function(e) { $(this).children().children('img.over').css('visibility', 'hidden') ;$(this).children().children().children('a').css({'color' : '#000000'});$(this).children().children('a').css({'color' : '#000000'}); });
    $('.localbanneritem').bind('mouseover', null, function(e) { $(this).children().children('img.over').css('visibility', 'visible') ;$(this).children().children().children('a').css({'color' : '#999999'});$(this).children().children('a').css({'color' : '#999999'}); });
    $('a').bind('click', function() {window.clearInterval(waveButtonIntervalID);});
    
};
zooma.startPageSliderInit = function(a,p){
    $("#globalbanner").easySlider({
        auto: a || true,
        continuous: true,
        pause: p || 3000,
        speed: 300,
        nextText: '<img src="Images/design/next.png" alt="Next" />',
        prevText: '<img src="Images/design/prev.png" alt="Previous" />'
    });
    $("#localbanner").easySlider({
        auto: false,
        continuous: false,
        pause: 300,
        nextId: 'slider1nextid',
        prevId: 'slider1previd',
        nextText: '<img src="Images/design/next.png" alt="Next" />',
        prevText: '<img src="Images/design/prev.png" alt="Previous" />',
        itemHeight: 350,
        itemWidth: 217,
        speed: 200,
        itemstoShow: 20,
        itemsAdjust: 3,
        controlsBefore: '',
        controlsAfter: '',
        numeric: false,
        widthAdjust: 12
    
    });
};
$.fn.reorder = function() {
 
  // random array sort from
  // http://javascript.about.com/library/blsort2.htm
  function randOrd() { return(Math.round(Math.random())-0.5); }
 
  return($(this).each(function() {
    var $this = $(this);
    var $children = $this.children();
    var childCount = $children.length;
 
    if (childCount > 1) {
      $children.remove();
 
      var indices = new Array();
      for (i=0;i<childCount;i++) { indices[indices.length] = i; }
      indices = indices.sort(randOrd);
      $.each(indices,function(j,k) { $this.append($children.eq(k)); });
 
    }
  }));
}
zooma.fadeInButtons = function() {
    
    //$("#prevBtn img").animate({width:"39px", height:"39px"}, 100, function() {$("#slider1previd img").animate({width:"34px", height:"34px"})});
    //$("#nextBtn img").animate({width:"39px", height:"39px"}, 100, function() {$("#slider1previd img").animate({width:"34px", height:"34px"})});
    
    $("#slider1previd img").animate({width:"39px", height:"39px"}, 100, function() {$("#slider1previd img").animate({width:"34px", height:"34px"})});
    $("#slider1nextid img").animate({width:"39px", height:"39px"}, 100, function() {$("#slider1nextid img").animate({width:"34px", height:"34px"})});
    waveButtonIntervalID = window.setInterval(zooma.waveButtons, 5000);
};
zooma.waveButtons = function(){
    
    $("#slider1previd img").animate({width:"40px", height:"40px", top:"-4px"}, 50, function() {$("#slider1previd img").animate({width:"37px", height:"37px", top:"-2px"})});
    $("#slider1nextid img").animate({width:"40px", height:"40px", top:"-4px"}, 50, function() {$("#slider1nextid img").animate({width:"37px", height:"37px", top:"-2px"}); zooma.again();});
    
        
};
zooma.again = function() {
    
    $("#slider1previd img").animate({width:"40px", height:"40px", top:"-4px"}, 50, function() {$("#slider1previd img").animate({width:"34px", height:"34px", top:"0px"})});
    $("#slider1nextid img").animate({width:"40px", height:"40px", top:"-4px"}, 50, function() {$("#slider1nextid img").animate({width:"34px", height:"34px", top:"0px"})});    
}
$(document).ready(function() {
});
