function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.x
	// edited to use display attribute
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

// restore all images except the active one
function restore () {
	if (!MM_findObj('menupreservation').src.match(/-active/)) MM_swapImage('menupreservation','','/images/layout/menu/preservation.gif',1);
	if (!MM_findObj('menuexperience').src.match(/-active/)) MM_swapImage('menuexperience','','/images/layout/menu/experience.gif',1);
	if (!MM_findObj('menuinvolved').src.match(/-active/)) MM_swapImage('menuinvolved','','/images/layout/menu/involved.gif',1);
	if (!MM_findObj('menunews').src.match(/-active/)) MM_swapImage('menunews','','/images/layout/menu/news.gif',1);
	if (!MM_findObj('menushop').src.match(/-active/)) MM_swapImage('menushop','','/images/layout/menu/shop.gif',1);
	if (!MM_findObj('menuabout').src.match(/-active/)) MM_swapImage('menuabout','','/images/layout/menu/about.gif',1);
}

// restore all images, including active ones
function restoreActive () {
	MM_swapImage('menupreservation','','/images/layout/menu/preservation.gif',1);
	MM_swapImage('menuexperience','','/images/layout/menu/experience.gif',1);
	MM_swapImage('menuinvolved','','/images/layout/menu/involved.gif',1);
	MM_swapImage('menunews','','/images/layout/menu/news.gif',1);
	MM_swapImage('menushop','','/images/layout/menu/shop.gif',1);
	MM_swapImage('menuabout','','/images/layout/menu/about.gif',1);
}

// swap the image on mouseover unless it is the active one
function swapOver(theButton) {
	if (!MM_findObj("menu" + theButton).src.match(/-active/)) {
		var theName = "menu" + theButton;
		var theImage = "/images/layout/menu/" + theButton + "-over.gif";
		MM_swapImage(theName,'',theImage,1)
	}
}

function showDiv(theDiv) {
	MM_showHideLayers('divpreservation','','hide','divexperience','','hide','divinvolved','','hide','divnews','','hide','divshop','','hide','divabout','','hide');
	MM_showHideLayers(theDiv,'','show');
}

function windowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body &&  document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
//  window.alert( 'Width = ' + myWidth );
  if (myWidth < 980 ) {
	var myX = ((myWidth - 980) / 2 ) * -1;
	window.scroll(myX,0);
   }
}

var myCrumbs;


//
// NAV
//

var timeout         = 100;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open() {	
	jsddm_canceltimer();
	jsddm_close();
	$(this).find('table').eq(0).css('display', 'block');
	$(this).find('.nav').eq(0).css('display', 'none');
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}

function jsddm_close() {	
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	$('.tab').css('display', 'none');
	$('.nav').css('display', 'block');
}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;



// store

function submitHandling(theform) {
	 var params = $("#handlingForm").serialize();
			$.post("/cgi-bin/store/special_order.cgi", params,
			   	function(data){
					$("#handlingForm").hide();
					$("#handlingForm").after(data);
			});
			
			return false;
}




$(document).ready(function(){

	$('.handlingDiv').click(function (e) {
		e.preventDefault();
		$('#handlingDiv').modal(
			{
				opacity : '75',
				closeHTML: '<a href="" class="closeLink">close</a>'
			}
		);
	});

});