
function link(url) {
	window.location.href = url;
}

function search() {
	var searchform = document.getElementById('searchform');
	document.getElementById('searchtext').value = document.getElementById('search_displaytext').value;
	searchform.submit();
}

function initPicture() {
		document.getElementById("gallery_prev").style.display= 'none';
		document.getElementById("gallery_prev_image_box").style.display= 'none';		
		
		if (photoArray.length == 1) {
				document.getElementById("gallery_next").style.display= 'none';
				document.getElementById("gallery_next_image_box").style.display= 'none';		
		}
		document.getElementById("mainPicture").src = photoArray[0] + "&w=450";
		document.getElementById("gallery_picture_text_title").innerHTML = nameArray[0]
		document.getElementById("nextPicture").src = photoArray[1];
}

function nextPic() {
		photoIdx++;
		if (photoIdx == photoArray.length - 1) {
				document.getElementById("gallery_next").style.display= 'none';
				document.getElementById("gallery_next_image_box").style.display= 'none';		
		}
		if (photoIdx > 0) {		
				document.getElementById("gallery_prev").style.display= 'block';
				document.getElementById("gallery_prev_image_box").style.display= 'block';		
		}

		document.getElementById("prevPicture").src = "images/5_spacer.gif";	
//		document.getElementById("mainPicture").src = photoArray[photoIdx] + "&w=450";
		document.getElementById("nextPicture").src = "images/5_spacer.gif";

		document.getElementById("prevPicture").src = photoArray[photoIdx - 1];
		document.getElementById("mainPicture").src = photoArray[photoIdx] + "&w=450";
		document.getElementById("gallery_picture_text_title").innerHTML = nameArray[photoIdx];
		document.getElementById("gallery_picture_current_picnum").innerHTML = photoIdx + 1;		
		document.getElementById("nextPicture").src = photoArray[photoIdx + 1];
}

function prevPic() {
		photoIdx--;

		if (photoIdx == 0) {		
				document.getElementById("gallery_prev").style.display= 'none';
				document.getElementById("gallery_prev_image_box").style.display= 'none';		
		}
		if (photoIdx < photoArray.length - 1) {
				document.getElementById("gallery_next").style.display= 'block';
				document.getElementById("gallery_next_image_box").style.display= 'block';		
		}

		document.getElementById("prevPicture").src = "images/5_spacer.gif";	
//		document.getElementById("mainPicture").src = photoArray[photoIdx] + "&w=450";
		document.getElementById("nextPicture").src = "images/5_spacer.gif";

		document.getElementById("prevPicture").src = photoArray[photoIdx - 1];	
		document.getElementById("mainPicture").src = photoArray[photoIdx] + "&w=450";
		document.getElementById("gallery_picture_text_title").innerHTML = nameArray[photoIdx];
		document.getElementById("gallery_picture_current_picnum").innerHTML = photoIdx + 1;
		document.getElementById("nextPicture").src = photoArray[photoIdx + 1];
}

$(document).ready(function()
  {
    $('#jsddm > li').bind('mouseover', jsddm_open);
	  $('#jsddm > li').bind('mouseout',  jsddm_timer);    
    if ("function" == typeof secondary_load) 
    {
      secondary_load();
    } 
  }
);


jQuery.fader = function(control_selector, layer_selector, active_class, config, heightset, reverse, instance, postrun) 
{
  this.control_selector = control_selector;
  this.layer_selector = layer_selector;
  this.active_class = active_class;
  this.active = -1;
  this.next = -1;
  this.cycling_enabled = true;
  this.timer = (config.timer)?(config.timer):20000;
  this.instance = instance;
  this.heightset = heightset;
  this.reverse = reverse;
  this.postrun = postrun;
  this.speed = (config.speed)?(config.speed):4000;
  var autostart = (config.autostart)?(config.autostart):false;
  var self = this;
  var maxheight = 0;
  this.len =  $(control_selector).length ;
  if(this.reverse == 'reverse')
  {
    this.active = this.len;
    this.next = this.len;
  }
  this.timeout = false;
  this.start = function()
  {
    var i=0;
    $(control_selector).each(function(n)
      {
        $(this).click(function(event) 
          {
            self.show_next(n);
          }
        );
      }  
    );
    if(!autostart)
    {
      self.cycling_enabled = false;
    }
    if(heightset.length > 0)
    {
      $(layer_selector).each(function(n)
        {
          var height = $(this).height();
          if(height>maxheight)
          {
            maxheight = height;
          }
        }  
      );
      $(heightset).height(maxheight + 10);
    }
    self.show_next();
  }
  this.show_this = function(n)
  {
  }

  this.start();
}
jQuery.fader.prototype.show_next = function(n)
{
  $(this.layer_selector+':visible').hide();
  $(this.control_selector).removeClass(this.active_class);
  if ("undefined" != typeof n)
  {
    this.cycling_enabled = false;
    window.clearTimeout(this.timeout);
    if(this.reverse != 'reverse')
    {
      this.next = n;
    }
    else
    {
      this.next = this.len-n-1;
    }
  }
  else
  {
      this.next ++;
      if(this.next >= this.len)
      {
        this.next = 0;
      }
/*    
    if(this.reverse != 'reverse')
    {
      this.next ++;
      if(this.next >= this.len)
      {
        this.next = 0;
      }
    }
    else
    {
      this.next --;
      if(this.next < 0)
      {
        this.next = this.len-1;
      }
    }
*/    
  }
  //say(this.instance + " " + this.active + " " + this.next);
  if(this.active>=0 && this.active<this.len)
  {
    $($(this.layer_selector)[this.active]).hide();
    //say('hide '+$(this.layer_selector)[this.active].id);
  }
  if(this.next>=0 && this.next<this.len)
  {
    //$($(this.layer_selector)[this.next]).fadeIn(this.speed);
    $($(this.layer_selector)[this.next]).show();
    if (this.postrun.length > 0 && (eval("typeof " + this.postrun + " == 'function'")))
    {
      eval(this.postrun+'()');
    }
    if(this.reverse != 'reverse')
    {
      $($(this.control_selector)[this.next]).addClass(this.active_class);
    }
    else
    {
      $($(this.control_selector)[this.len-this.next-1]).addClass(this.active_class);
    }
    //say('show '+$(this.layer_selector)[this.next].id);
  }
  if(this.cycling_enabled)
  {
    this.timeout = window.setTimeout(this.instance+'.show_next()', this.timer);      
  }
  this.active = this.next;
} 
function say(text) 
{
  return false;
  if(typeof(console) == 'object' && typeof(console.log) == 'function')
  {
    console.log(text); 
  }
  else
  {
    alert($('#console').length);
    if($('#console').length > 0 && $('#console').id == 'console')
    {
      $('#console').append('<div>'+text+'</div><br/>');
    }
    else
    {
      alert(text);
    }
  }
}
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}


document.onclick = jsddm_close;

