		function MM_preloadImages() { //loads the rollover images
			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() { //replaces rolled over image
			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) { //finds an object, for rollover
			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 && document.getElementById) x=document.getElementById(n); return x;
		}

		function MM_swapImage() { //swaps an image, for rollover
			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];}
		}

// daves additions

function getMainObj(name){
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  } else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  } else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function showStatusMsg(msg){
	window.status=msg;
	//return true;
}

function toggleFolder(strID){
	var target = new getMainObj(strID);
	if (target.style.display == "none"){
  	target.style.display = "";
  	if (document.images) {
			document["img"+strID].src = eval("openFolder.src");
		}
		/* seems not not fuck up so bad if the reset footer thing is conditional */
		setFooter();

  }else {
  	target.style.display = "none";
  	if (document.images) {
			document["img"+strID].src = eval("closedFolder.src");
		}
  }
 // setFooter();
}

function toggle(strID){
	var target = new getMainObj(strID);
	//alert(target.style.display);
	if (target.style.display == "none"){
  	target.style.display = "block";
  	store(strID, "block");
  }else {
  	target.style.display = "none";
    store(strID, "none");
  }
}

function setPD_forReading(f, e) {
	// set PD to 60 if reading is selected
	if (e.value== '2/0')
		{
			f.PD.value='60';
		}
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}	else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setFooter() {
	//alert('setting footer');
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var container_Element = document.getElementById('container');
			var container_Height = container_Element.offsetHeight; // a variable height
			var leftContent_Element = document.getElementById('leftContent');
			var leftContent_Height = leftContent_Element.offsetHeight;
			var rightContent_Element = document.getElementById('rightContent');
			var rightContent_Height = rightContent_Element.offsetHeight;
			var greatest= leftContent_Height;
			//if (rightContent_Height>leftContent_Height)
				//greatest= rightContent_Height;

			if (windowHeight > container_Height) {
				rightContent_Element.style.height= windowHeight- 308;
			}
		}
	}

	var msg='';
	msg+= 'windowHeight='+windowHeight+'\r\n';
	msg+= 'container_Height='+container_Height+'\r\n';
	msg+= 'leftContent_Height='+leftContent_Height+'\r\n';
	msg+= 'rightContent_Height='+rightContent_Height+'\r\n';
	//alert(msg);

}

function hov(loc,cls){
	if(loc.className)
  loc.className=cls;
}

var menu_selection="";
var radio_selection="";

function  formValidate(f) {
	var myindex=document.forms[0].s2.selectedIndex;
	if (myindex==0) {
		alert("\nYou must select a region from the drop-down menu.");
		document.forms[0].s2.focus();
		return false;
	}	else {
		//menu_selection=document.forms[0].s2.options[myindex].value;
		return true;
	}
}


function store(data,value) {
  var today = new Date();
  var expires = new Date();
  // set it for a short time
  var nDays= 1;
  expires.setTime(today.getTime() + 3600000*24*nDays);
  setCookie(data, value, expires);
  //alert(value);
}

function setCookie(name, value, expire) {
	var path= ';path=/';
  document.cookie = name + "=" + escape(value)  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) +path
}

function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
  	offset = document.cookie.indexOf(search);
  	if (offset != -1) { // if cookie exists
    	offset += search.length;
    	// set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end))
  	}
	}
	return null;
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes,status=no';
	win=window.open(mypage,myname,settings);
}


$(document).ready(function(){
    $('#home-flash').flash({
        src: '/website/flash/sd-home-banner-v1.swf',
        width: 290,
        height: 255
    });

    
    $('#brands-flash').flash({
        src: '/website/flash/spectacles-brands.swf',
        width: 220,
        height: 60
    });
    
});
