var bPricelist=false;

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 to overcome "Click here to activate this object" MS security patch
function CreateGalleryControl()
{
  var strW='100%', strH='100%', strIntro='', i, args=CreateGalleryControl.arguments;
  for (i=0; i<args.length; i++) {
    strIntro='<div id="intro">' + args[i] + '</div>';
  }
  var d = document.getElementById('gallery');
  d.innerHTML = strIntro +
    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + strW + '" height="' + strH + '">' +
    '<param name="menu" value="false">' +
    '<param name="movie" value="imageVue.swf">' +
    '<param name="quality" value="high">' +
    '<param name="BGCOLOR" value="#383838">' +
    '<param name="wmode" value="transparent">' +
    '<param name="FLASHVARS" value="textcol=E5851F&configfile=config.ini&">' +
    '<embed src="imageVue.swf" width="' + strW + '" height="' + strH + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#383838" flashvars="textcol=E5851F&configfile=config.ini&"></embed></object>';
}

function CreatePopControl(value,w,h)
{
  var d = document.getElementById('gallery');
  d.innerHTML =
    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="841" height="561" style="border:1px solid black;">' +
		'<param name="movie" value="preload.swf">' +
		'<param name="quality" value="high">' +
		'<param name="FLASHVARS" value="' + value + '">' +
		'<param name="wmode" value="opaque">' +
		'<embed src="preload.swf" width="' + w + '" height="' + w + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="' + value + '"></embed></object>';
}

function resizeMe() {
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName.indexOf("Microsoft")!=-1) {
      winW = document.body.offsetWidth;
      winH = document.body.offsetHeight;
      if (navigator.appVersion.indexOf("Windows NT 5.1")>0) {
      	window.resizeTo(winW+28, winH+40);
//alert("xp");
      } else {	// not XP
      	window.resizeTo(winW+36, winH+30);
//alert("not xp");
      }
    } else {
      winW = window.innerWidth;
      winH = window.innerHeight;
      window.resizeTo(winW+18, winH+60);
      var d=document.getElementById('pop_link_div');
      d.style.width=winW-40;
      d.style.bottom=36;
      d.style.left=15;
//alert("not IE");
    }
  }
}

function vote(img,score) {
  //store in DB - this window then self-closes
  var w=window.open('/vote.php?img='+img+'&score='+score,"_self");
}

function email() {
	window.location="mailto:dan@orpheus-" + "photo.co.uk";
}

function orpheus() {
	var new_win = window.open("http://www.orpheus-software.co.uk");
}

function swpp() {
	var new_win = window.open("http://www.swpp.co.uk");
}

function contactSubmit() {
 var f=document.forms[0];
 var bOK=true;

 if (f.txtName.value=="") {
 	 alert("Please enter your name");
 	 f.txtName.focus();
 	 return;
 }

 if (f.txtContactNo.value=="") {
 	 alert("Please enter a contact telephone number or email address");
 	 f.txtContactNo.focus();
 	 return;
 }

 if (f.txtEnquiry.value=="") {
 	 alert("Please enter the details of your enquiry");
 	 f.txtEnquiry.focus();
 	 return;
 }

 if (f.txtSum.value=="") {
 	 alert("Please enter the sum of the two numbers");
 	 f.txtSum.focus();
 	 return;
 }

 f.txtUserAction.value = 'Send';
 f.submit(); 
}

function stretchHeight() {
	if (top.location != location) {
	  top.location.href = document.location.href;
	}
	var mb=document.getElementById('fullBody');
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    if (myHeight<600) { myHeight=600 };
    mb.style.height=myHeight-180;    // Firefox sizes differently to IE
    mb.style.width=myWidth-30;
    var c=document.getElementById('content');
    c.style.height=myHeight-110;
//    c.style.width=myWidth-70;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
//    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight-20;
    mb.style.height=myHeight-36;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
//    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight-50;
    mb.style.height=myHeight-36;
  }
	//mb.style.height=myHeight-36;
}

function toggle_pricelist() {
var divPL, lnkPL;
  if (true==bPricelist) {   // hide pricelist div
    bPricelist=false;
    divPL=MM_findObj('pricelist');
    divPL.style.visibility = 'hidden';
    lnkPL=MM_findObj('priceListLink');
    lnkPL.innerText='View price list';
  } else {
    bPricelist=true;        // show pricelist div
    divPL=MM_findObj('pricelist');
    divPL.style.visibility = 'visible';    
    lnkPL=MM_findObj('priceListLink');
    lnkPL.innerText='Hide price list';
 //   alert("In Firefox on low-res screens this price-list gets obscured.  I'm searching for a solution...  Sorry!");
  }
}