/*  08-Sept-2011
 *  Yet another hack to add functionality without interfering with the
 *  existing code.  Essentially uses hash-anchors as a primitive query
 *  string in order to add permalinks to the hidden image gallery.
 *  Also had to add to one of the onclick events in the imageMenu.js
 *                                                    - search tag: // FI
 */
togTestimonials = false; // hack! (function not declared till later)

window.addEvent('domready', function(){
  if(document.URL.indexOf('#')<0)
    window.location = document.URL.split('#')[0]+'#';
});

queryString = (function(){
  var current = ''; listen();
  function listen(){
    var c = getCurrent();
    if(c!=current){
      switch(c){
        case 'wedding'      : $(1,c); break;
        case 'corporate'    : $(2,c); break;
        case 'home'         : $(4,C); break;
        case 'events'       : $(5,c); break;
        case 'sympathy'     : $(6,c); break;
        case 'testimonials' : test(); break;
      }
    }
    setTimeout(listen,500);
  }; 
  function getCurrent(){
    var u = document.URL.split('#');
    return u.length < 2 ? '' : u[1].toLowerCase();
  };
  function $(x,c){ 
    var e = document.getElementById('kwick'+x);
    if(e!=null && e.select!=null && e.select!=undefined){
      e.select(); current = c;
    }
  };
  function test(){
    if(!togTestimonials) setTimeout(test, 500);
    else { togTestimonials(); current = 'testimonials'; }
  };
  this.setCurrent = function(x){
    current = ['wedding','corporate','','home','events','sympathy','testimonials'][x];
    if(x!=2) window.location = document.URL.split('#')[0]+'#'+current;
  };
  return this;
})();
