var PopW;
PopW=0;


/* ---- Pre-load Menu Images -----*/
var imgObj;
var imgPath = '/img/menu/'
var miAr = new Array;
imgObj = new Image; imgObj.src = imgPath + 'gbg-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'gl-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'gr-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'obg-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'ol-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'or-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'rbg-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'rl-up.gif';  miAr[miAr.length] = imgObj;
imgObj = new Image; imgObj.src = imgPath + 'rr-up.gif';  miAr[miAr.length] = imgObj;

var imgPath2 = '/img/block/'
imgObj = new Image; imgObj.src = imgPath2 + 'bgblue.gif'; 
imgObj = new Image; imgObj.src = imgPath2 + 'bgred.gif'; 
imgObj = new Image; imgObj.src = imgPath2 + 'bggreen.gif'; 
imgObj = new Image; imgObj.src = imgPath2 + 'bgyel.gif'; 


/* ---- Menu Functions -----*/
function CIM(who,what,border)
{
 type=who.charAt(0);
 type=type.toUpperCase();
 cl="menuTd"+type;

 direct=""
 imgdirect=""
 if (what==1) {direct="Up"; imgdirect="-up"};
 
 if (border)
 {
   path='/img/menu/';
   img=document.getElementById(border); 
   img.src=path + border + imgdirect + ".gif";
 }
 m=document.getElementById(who); 
 m.className=cl + direct;  
};

function pop(img,w,h)
{
  ww = w + 30;
  hh = h + 33;
//  path='/img/photos/'+img;
  path=img;

//  alert(ww);
//  alert(hh);

  if (PopW) {PopClose();};
  PopW=window.open('/pop.html?'+path+'&'+w+"&"+h,'poppic','marginheight=0,marginweight=0,toolbar=no,width='+ww+',height='+hh+', left=100, top=100, resizable=no, scrollbars=no');
  PopW.focus();
}

function popFscroll(img,w,h)
{
  stepLeft=100;
  stepTop=100;
  ww = w + 40;
  hh = h + 50;
  path='/img/'+img;

  if (ww > 800){ww = 800};
  if (hh > 600){hh = 600};

  if (PopW) {PopClose();};
  PopW = window.open('pop.html?'+path+'&'+w+"&"+h,'poppic','marginheight=0,marginweight=0,toolbar=no,width='+ww+',height='+hh+', left='+stepLeft+', top='+stepTop+', resizable=no, scrollbars=yes');
  PopW.focus();
};

function PopClose()
{
  PopW.close();
  PopW=0;
};

function popHtml(url,w,h)
{
  stepLeft=100;
  stepTop=100;

  if (w > 800) w = 800;
  if (h > 600) h = 600;

  if (PopW) PopClose();
  PopW = window.open(url, 'popdoc', 
'marginheight=0,marginweight=0,toolbar=no,width='+w+',height='+h+',left='+stepLeft+',top='+stepTop+',resizable=no,scrollbars=auto');
  PopW.focus();
}


///////////////////////////////////////////////////////////
// confirm something
function request(message)
{
  if(confirm(message)) { return true; }
  else { return false; }
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// open w2 window
function w2(url, name, width, height, scroll)
{
  var w2 = window.open(url, name,
'marginheight=0,marginweight=0,toolbar=no,width='+width+',height='+height+',left=50,top=50,resizable=no,scrollbars='+scroll);
  w2.focus();
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// open image window
function w22(url, name, width, height, scroll)
{

  var w22 = window.open('/w22.html?img='+url, name,
'marginheight=0,marginweight=0,toolbar=no,width='+width+',height='+height+',left=50,top=50,resizable=no,scrollbars='+scroll);
  w22.focus();
}
///////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////
// preview window
function preview(form, width, height, scroll)
{
  var d = document.forms[form];  
  w2('/w2.html?section='+form, 'w2', width, height, scroll);
  d.action = '/w2.html?section='+form;
  d.target = 'w2';
  d.submit();
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// show and hide hint
function showTip(id)
{
  var el = document.getElementById('tips');
  if(id != '' && el.style.display == 'none') { el.innerHTML = id; }
  var x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft - el.offsetWidth + 8;
  var y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop + 20;
  el.style.left = x + 'px';
  el.style.top = y + 'px';
  if(el.style.display == 'none') { el.style.display = ''; }
}

function hideTip()
{
  document.getElementById('tips').style.display = 'none';
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// roll & expand
function expand(id)
{
  document.getElementById(id+'_opened').style.display = '';
  document.getElementById(id+'_closed').style.display = 'none';
}
function roll(id)
{
  document.getElementById(id+'_opened').style.display = 'none';
  document.getElementById(id+'_closed').style.display = '';
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// preload images
function preload(i)
{ 
  var img = new Image(); 
  img.src = '/img/'+i;
  
  return img; 
}

preload('menu/divl.gif');
preload('menu/rl.gif');
preload('menu/rr.gif');
preload('red.gif');
preload('menu/rbg-up.gif');
preload('menu/rbg-this.gif');
preload('menu/ol.gif');
preload('menu/or.gif');
preload('orange.gif');
preload('menu/obg-up.gif');
preload('menu/obg-this.gif');
preload('menu/gl.gif');
preload('menu/gr.gif');
preload('green.gif');
preload('menu/gbg-up.gif');
preload('menu/gbg-this.gif');
///////////////////////////////////////////////////////////


function doprint(a,b) {
  var req = new JsHttpRequest();
  req.open(null, '/_ajax/fundraisers/print.php', true);
  var data = { 'a': a, 'b': b };
    req.send(data);

  document.getElementById('goprint1').style.display = 'none';
  document.getElementById('goprint2').style.display = 'none';
  print();
}

function ShowDiv(name) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(name).style.visibility = 'visible';
		document.getElementById(name).style.display = 'inline';
	}
}

function HideDiv(name) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(name).style.visibility = 'hidden';
		document.getElementById(name).style.display = 'none';
	}
}
