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_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_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;
}

var last_scroll_pos;
function HideNotifyDiv(mydiv){
	MM_findObj(mydiv).style.visibility='hidden';
	}
function toggleBlock(div_id, container_div_id, dividclass){
	var d = MM_findObj(div_id);
	var c = MM_findObj(dividclass);
	if(container_div_id) last_scroll_pos = parseInt($(container_div_id).css("top")) * -1;
	if(d != null){
		if(d.style.display == "block"){
			d.style.display = "none";
			c.className = 'plus';
		} else {
			d.style.display = "block";
			c.className='minus';
		}
	}
	if(container_div_id) {
	    $(container_div_id).jScrollPane({ showArrows:true });
    	$(container_div_id)[0].scrollTo(last_scroll_pos);
	}
}
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_showHideLayers() { //v6.0
  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')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

var fontVariation=2;
var minFontSize=11;
var maxFontSize=15;
function enlargeFont(bigger)
{
	var mydiv=document.getElementById('Text2Enlarge');
	if(!mydiv) return; 
	
	var newFontSize = parseInt(mydiv.style.fontSize);
	if(isNaN(newFontSize)) newFontSize = minFontSize;
	
	if(bigger)
		newFontSize=(newFontSize<maxFontSize)?(newFontSize+fontVariation):(maxFontSize);
	else
		newFontSize=(newFontSize>minFontSize)?(newFontSize-fontVariation):(newFontSize);
	
	mydiv.style.fontSize=newFontSize+'px';
}



function print_function()
{ 
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
		disp_setting+="scrollbars=yes,width=700, height=550, left=150, top=150";
	var content_vlue = document.getElementById("PrintText").innerHTML;

	var docprint=window.open("","",disp_setting);

	docprint.document.open();
	docprint.document.write('<html><head><title> Spinneys</title>');
	docprint.document.write('</head><link href="css/styles.css" rel="stylesheet" type="text/css"><body onLoad="self.print(); self.close();" style="background:none; padding-left:20px;" >');
	docprint.document.write('<img src="images/globalLogo.gif"');
	docprint.document.write('<div style="color:#626262;font-family:arial;font-size:11px;">'+content_vlue+'</div>');
	docprint.document.write('</body></html>');
	docprint.document.close(); 
 	docprint.focus();
}

function setHeight(){
	bodyheight = $(window).height();
//  alert( $("#pane2").height() ); 
	//alert(bodyheight)
	if($.browser.msie){
		newheight =  bodyheight - 390;/*380*/
		flashheight = bodyheight - 0;
	}
	if($.browser.mozilla){
		newheight =  bodyheight - 400;/*380*/
		flashheight = bodyheight;
	}
	if($.browser.safari){
		newheight =  bodyheight - 500;/*380*/
		flashheight = bodyheight;
	}
	$(".flash").css("height", flashheight+"px");
	$("#pane2").css("height", newheight+"px");
	
}

function setWidth()
{
	thewidth = $(window).width();
	//alert(thewidth);
	if(thewidth <= 1400){
		flashwidth = 100;
		$(".flash").css("width", flashwidth+"%");
		//alert(flashwidth);
	} if(thewidth > 1400){
		flashwidth = 1400;
		$(".flash").css("width", flashwidth+"px");
		alert(flashwidth);
	}			
}





//------------------------------------------------------------

function setFlashHeight(){
	bodyheight = $(window).height();
//  alert( $("#pane2").height() ); 
	//alert(bodyheight)
	if($.browser.msie){
		flashheight = bodyheight;
	}
	if($.browser.mozilla){
		flashheight = bodyheight;
	}
	if($.browser.safari){
		flashheight = bodyheight;
	}
	$(".flash").height(flashheight);
}

function getMaxHeight(){
	totalheight = $(window).height();
	if($.browser.msie){
		maxheight =  totalheight - 150;
	}
	if($.browser.mozilla){
		maxheight =  totalheight - 150;
	}
	if($.browser.safari){
		maxheight =  totalheight - 150;
	}
	return maxheight;
}

function getScrollHeight(){
	scrollheight =  getMaxHeight() - 50
	if($("#thequotes").children().not("script").length > 0) {
		$("#thequotes").css("position", "relative")
	}
	if($("#thequotes").height() > 0) scrollheight -=  $("#thequotes").height();
	return scrollheight;
}

function adjustContent(){
	$(".jScrollPaneContainer").css({"height":"auto"});
	$("#pane2").css({"overflow":"visible", "height":"auto", position: "relative" });
	contentHeight = $("#contenthold").height();
	menuHeight = $("#menuhold").height();
	maxheight = getMaxHeight();
	scrollheight = getScrollHeight() - 50; //padding
	if(contentHeight > (menuHeight)) {
		if($(".no-internal-scroll").length == 0) {				// Class 'no-internal-scroll' is added to 
			$("#pane2").height(scrollheight);					// the pages that should not show the 
			$(".jScrollPaneContainer").height(scrollheight - 20);	// inside scrollbar
			$('#pane2').jScrollPane({showArrows:true});			//////////////////////////////////////////
		}
	} 
	var offset = 0;
	if($(".jScrollPaneContainer").length){
		offset = $(".jScrollPaneContainer").offset().top - 126
	}
	var h = $(".jScrollPaneContainer").height() + offset + 20;
	h = Math.max(h, menuHeight);
	$(".blackbg").height(h);
}



//------------------------------------------------------------

$(document).ready(function(){
	//adjustContent();
	window.setTimeout(adjustContent, 500);
	
	// stop flash bg movement when mouse is over the main content area
	$("#thecontent").hover(function(){
		$(".flashbg").each(function(){
			this.stopMoving(true);
		})
	}, function(){
		$(".flashbg").each(function(){
			this.stopMoving(false);
		})
	});
});
$(window).resize(adjustContent)

//------------------------------------------------------------
currentanswer="";
function showAnswer(answerid){
	$("#"+currentanswer).css("display", "none");
	$("#terms"+answerid).css("display", "block");
	currentanswer = "terms"+answerid;
}

function launchBackgrounds() {

var scrnWidth=screen.availWidth;
var scrnHeight=screen.availHeight - 30;
var rrr = window.open('backgrounds.html','newWinddd','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=0,top=0,width='+scrnWidth+',height='+scrnHeight);
rrr.focus();

}


function ShowPhotoUpload(){
	document.getElementById("txtPicture").style.display='block';
}
function popUserPhoto(myPhoto){
	openWnd('pop_gl.htm?img=Library/Members/'+myPhoto+"&caption=",800,550);
	}
	function popCatPhoto(myPhoto){
	openWnd('pop_gl.htm?img=Library/PhotoGallery_Category/Thumbnail/'+myPhoto+"&caption=",800,550);
	}
	function openWnd(u,W,H, sc, rz) {
	window.open(u, '',"width="+W+",height="+H+",scrollbars="+(sc ? "yes" : "no")+",resizable="+(rz ? "yes" : "no")+",status=yes, left="+250+",top="+200);
}
