function updateLinksElements()
{
	try 
	{
		var lists = document.getElementsByTagName("a");
		for (var i = 0; i < lists.length; i++) {
			var tmpString = lists[i].href.toLowerCase();
			if (tmpString.indexOf('.pdf') !=-1 || tmpString.indexOf('.PDF') !=-1)
			{
				lists[i].target = "_blank";
			}		
		}
	}
	catch(e)
	{
		
	}
}

function popImage(page) {
	var w = 640, h = 480;
	w = screen.width;
	h = screen.height;
	
	var popW = 600, popH = 600;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	window.open('popImage.php?img='+page,'Page','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+', scrollbars=yes,resize=yes');
}


// Example: obj = findObj("image1");

function findObj(theObj, theDoc)
{

  var p, i, foundObj;
  if(!theDoc) theDoc = document;

  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }

  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);


  return foundObj;

}


// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');

function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)
  {

    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

var menu_timerID = 0;
var menu_tStart  = null;


function showMenu(menu)
{
	if(menu_timerID) {
		clearTimeout(menu_timerID);
		menu_timerID  = 0;
	}
		
	switch(menu)
	{
	case 1:
		showHideLayers("menuPop1", "", "show", "menuPop2", "", "hide");
		break;
	case 2:
		showHideLayers("menuPop1", "", "hide", "menuPop2", "", "show");
		break;
	}
}
function rollOutMenu()
{
	if(menu_timerID) {
		clearTimeout(menu_timerID);
		menu_timerID  = 0;
	}
	
	menu_timerID = setTimeout("hideMenu()", 1000);
}

function hideMenu()
{
	showHideLayers("menuPop1", "", "hide", "menuPop2", "", "hide");
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}

function checkSendUpdatesForm(form)
{
	if (IsEmpty(form.name))
	{
		alert("Please enter your name");
		return false;
	}
	if (IsEmpty(form.email))
	{
		alert("Please enter your email");
		return false;
	}
	if (!isValidEmail(form.email))
	{
		alert("Please enter a valid email");
		return false;		
	}
	if (form.email != form.email2)
	{
		alert("Please check your email address!");
		return false;
	}	
	return true;
}
