function sa_openImage(imgUrl, width, height) {
	var imgInfo = new Image();

	imgInfo.src = imgUrl;
	imgWidth = imgInfo.width + 16;
	imgHeight = imgInfo.height + 24; 

	x = Math.round((screen.width - imgWidth) / 2);
	y = Math.round((screen.height - imgHeight) / 2);

	window.open(imgUrl,'image_view','width=' + imgWidth + ',height=' + imgHeight + 'left='+x+',top='+y+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
}

function sa_flashWrite(url,w,h,id,bg,win) {
	var flashStr=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='movie' value='"+url+"'>"+
	"<param name='wmode' value='"+win+"'>"+
	"<param name='menu' value='false'>"+
	"<param name='quality' value='high'>"+
	"<param name='bgcolor' value='"+bg+"'>"+
	"<embed src='"+url+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>"+
	"</object>";
	document.write(flashStr);
}

function sa_select_copy (elname, selected) {
	var parent=elname.parentNode;
	var lis=parent.getElementsByTagName("li");
	for (i=1; i<=lis.length; i++) {
		if (i==selected) {
			lis[i-1].className="selected";
			document.getElementById(parent.id+i).style.display="block";
		} else {
			lis[i-1].className="";
			document.getElementById(parent.id+i).style.display="none";
		}
	}
}

function sa_select (elname, selected) {
	var parent=elname.parentNode;
	var lis=parent.getElementsByTagName("li");
	for (i=0; i<=lis.length; i++) {
		if (i==selected) {
			lis[i].className="selected";
			document.getElementById(parent.id+i).style.display="block";
		} else {
			lis[i].className="";
			document.getElementById(parent.id+i).style.display="none";
		}
	}
}

function sa_quick_select (subno) {
	document.getElementById("submenu0").style.display="none";
	document.getElementById("sub"+subno).className="selected";
	document.getElementById("submenu"+subno).style.display="block";
}

function checkRequired(form) {
  for (var i = 0; i < form.elements.length; i++) {
    element = form.elements[i];
    if (element.alt && element.alt.match(/required/) && element.value == '') {
      element.focus();
      alert("Please do not leave the field blank.");
      return false;
    }
  }
  return true;
}

function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}
