var ie=false;
var ns=false;
var isNav6=false;
if(document.layers)ns = true;
if(window.sidebar)isNav6 = true;
if(document.all)ie = true;

// date function
function writeDate()
{
  var now = new Date();
  var date = now.getDate();
  var year = now.getFullYear();

  var monthNumber = now.getMonth();
  var month = "";
  switch (monthNumber)
  {
    case 0:
      month = "Jan";
      break;
    case 1:
      month = "Feb";
      break;
    case 2:
      month = "Mar";
      break;
    case 3:
      month = "Apr";
      break;
    case 4:
      month = "May";
      break;
    case 5:
      month = "Jun";
      break;
    case 6:
      month = "Jul";
      break;
    case 7:
      month = "Aug";
      break;
    case 8:
      month = "Sep";
      break;
    case 9:
      month = "Oct";
      break;
    case 10:
      month = "Nov";
      break;
    case 11:
      month = "Dec";
      break;
  }


  var hour = now.getHours();
  var numMinutes = now.getMinutes();
  var minutes = "";
  if (numMinutes < 10)
  {
    minutes = "0" + numMinutes;
  }
  else
  {
    minutes = numMinutes;
  }

  var dateString = "<span class='date'>";
  dateString += hour + ":" + minutes + " - " + date + " " + month + " " + year;
  dateString += "</span>";
  document.writeln(dateString);
}


// validation function for event booking
function validateBookingForm()
{
  // check the contact name
  if (document.eventBooking.contactName.value.length < 2)
  {
    alert("Please enter your name");
    document.eventBooking.contactName.focus();
    return false;
  }

  // Check to see that at least one person is booking
  if (document.eventBooking.members.selectedIndex == 0 && document.eventBooking.nonMembers.selectedIndex == 0)
  {
    alert("Please indicate how many people will be attending.");
    return false;
  }

  // Check the to see if a member, if yes check membership number entered
  if (document.eventBooking.notPMIMember.checked == false && document.eventBooking.membershipNumber.value.length < 1)
  {
   alert("Please enter your PMI membership number\nor indicate that you are not a member");
   document.eventBooking.membershipNumber.focus();
   document.eventBooking.membershipNumber.select();
   return false;
  }

  // Check contact email address
  if (document.eventBooking.contactEmail.value.length < 1)
  {
    alert("Please enter your email address");
    document.eventBooking.contactEmail.focus();
    document.eventBooking.contactEmail.select();
    return false;
  }

  else
  {
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|([^\w\.\@\-\_])/;       // not valid
    var reg2 = /^.+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})$/;    // valid

    var email = document.eventBooking.contactEmail.value;

    if (!reg1.test(email) && reg2.test(email)) // if syntax is valid
    {
      return true;
    }
    else
    {
      alert("The contact email address you entered is not valid.\nPlease check it and try again.");
      document.eventBooking.contactEmail.focus();
      document.eventBooking.contactEmail.select();
      return false;
    }
  }
  return true;
}

// validation function for event booking
function validateAGMBookingForm()
{
  // check the contact name
  if (document.eventBooking.contactName.value.length < 2)
  {
    alert("Please enter your name");
    document.eventBooking.contactName.focus();
    return false;
  }

  // Check to see that at least one person is booking
  if (document.eventBooking.members.selectedIndex == 0)
  {
    alert("Please indicate how many people will be attending.");
    return false;
  }

  // Check the to see if a member, if yes check membership number entered
  if (document.eventBooking.membershipNumber.value.length < 1)
  {
   alert("Please enter your PMI membership number");
   document.eventBooking.membershipNumber.focus();
   document.eventBooking.membershipNumber.select();
   return false;
  }

  // Check contact email address
  if (document.eventBooking.contactEmail.value.length < 1)
  {
    alert("Please enter your email address");
    document.eventBooking.contactEmail.focus();
    document.eventBooking.contactEmail.select();
    return false;
  }

  else
  {
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|([^\w\.\@\-\_])/;       // not valid
    var reg2 = /^.+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})$/;    // valid

    var email = document.eventBooking.contactEmail.value;

    if (!reg1.test(email) && reg2.test(email)) // if syntax is valid
    {
      return true;
    }
    else
    {
      alert("The contact email address you entered is not valid.\nPlease check it and try again.");
      document.eventBooking.contactEmail.focus();
      document.eventBooking.contactEmail.select();
      return false;
    }
  }
  return true;
}

// fuction to set the name of the event by checking the url search string
// takes one argument the URL search string
function setEventTitle(qryString)
{
  if (qryString != null)
  {
    var eventName = qryString;
    eventName = eventName.substring(5, eventName.length);
    document.eventBooking.eventTitle.selectedIndex =  eventName;
  }
}


// function to open a popup window
function openPopup(url)
{
  window.open(url, "new", "width=670, height=500, toolbar=no, menubar=no, scrollbars=yes");
}

// function to open a popup window - used on the events pages
function openWin(url)
{
  var strURL = url
  window.open(strURL, 'newWin', 'width=400, height=400, left=100, top=100, menubar=no, toolbar=no, scrollbars=yes, status=no, location=no');
}

////////////////////////////////////////////////////////
/* Show or Hide faq answers */
function shfaq(thisFAQ)
{
	if(thisFAQ.style.display!='block'){thisFAQ.style.display='block'}else{thisFAQ.style.display='none'}
}
var breakitln=false;
var adsln=0
function showadsln(sID){
		if(isNaN(sID)){
		return
		}
		if(breakitln){
			breakitln=true
			return
		}
			numsIDln=new Number(sID)
			var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
			document.all ? document.all.tags("DIV") : null;
			var bDOM, oElement, sId;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			var countadsln=0
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(new String(oElement.id).slice(0,2)=="ln"){
					countadsln++
				}
			}
			if(countadsln > 1){
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,2)=="ln"){
						oElement.style.display = "none"
					}
				}
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,3)=="ln"+sID){
						oElement.style.display = "block"
						}
				}
				numsIDln++;
				if(numsIDln>countadsln){
					numsIDln=1;
				}
			//	targetID=new String(numsID)
				targetIDln=numsIDln
				breakitln=false
				adsln=setTimeout('showadsln(targetIDln)',5000)
				
			}	
	
}
var breakitmi=false;
var adsmi=0

function showadsmi(sID){
		if(isNaN(sID)){
		return
		}
		if(breakitmi){
			breakitmi=true
			return
		}
			numsIDmi=new Number(sID)
			var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
			document.all ? document.all.tags("DIV") : null;
			var bDOM, oElement, sId;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			var countadsmi=0
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(new String(oElement.id).slice(0,2)=="mi"){
					countadsmi++
				}
			}
			if(countadsmi > 1){
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,2)=="mi"){
						oElement.style.display = "none"
					}
				}
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,3)=="mi"+sID){
						oElement.style.display = "block"
						}
				}
				numsIDmi++;
				if(numsIDmi>countadsmi){
					numsIDmi=1;
				}
			//	targetID=new String(numsIDmi)
				targetIDmi=numsIDmi
				breakitmi=false
				adsmi=setTimeout('showadsmi(targetIDmi)',5000)
				
			}	
	
}

var breakitsc=false;
var adssc=0
function showadssc(sID){
		if(isNaN(sID)){
		return
		}
		if(breakitsc){
			breakitsc=true
			return
		}
			numsIDsc=new Number(sID)
			var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
			document.all ? document.all.tags("DIV") : null;
			var bDOM, oElement, sId;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			var countadssc=0
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(new String(oElement.id).slice(0,2)=="sc"){
					countadssc++
				}
			}
			if(countadssc > 1){
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,2)=="sc"){
						oElement.style.display = "none"
					}
				}
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,3)=="sc"+sID){
						oElement.style.display = "block"
						}
				}
				numsIDsc++;
				if(numsIDsc>countadssc){
					numsIDsc=1;
				}
			//	targetID=new String(numsIDsc)
				targetIDsc=numsIDsc
				breakitsc=false
				adssc=setTimeout('showadssc(targetIDsc)',5000)
				
			}	
	
}
var breakitsw=false;
var adssw=0

function showadssw(sID){
		if(isNaN(sID)){
		return
		}
		if(breakitsw){
			breakitsw=true
			return
		}
			numsIDsw=new Number(sID)
			var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
			document.all ? document.all.tags("DIV") : null;
			var bDOM, oElement, sId;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			var countadssw=0
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(new String(oElement.id).slice(0,2)=="sw"){
					countadssw++
				}
			}
			if(countadssw > 1){
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,2)=="sw"){
						oElement.style.display = "none"
					}
				}
				for(i = 0; i < oElements.length; i++)
				{
					oElement = oElements.item(i);
					if(new String(oElement.id).slice(0,3)=="sw"+sID){
						oElement.style.display = "block"
						}
				}
				numsIDsw++;
				if(numsIDsw>countadssw){
					numsIDsw=1;
				}
			//	targetID=new String(numsIDsw)
				targetIDsw=numsIDsw
				breakitsw=false
				adssw=setTimeout('showadssw(targetIDsw)',5000)
				
			}	
	
}
var topimg=null;
var tnum
function changeImages(n){
		var nmbr= new Number(n)
		var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
		document.all ? document.all.tags("DIV") : null;
		var bDOM, oElement, sId;
		bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
		for(i = 0; i < oElements.length; i++)
		{
			oElement = oElements.item(i);
			if(new String(oElement.id).slice(0,2)=="im"){
				oElement.style.display = "none"
			}
		}
		for(i = 0; i < oElements.length; i++)
		{
			oElement = oElements.item(i);
			if(new String(oElement.id).slice(0,2)=="im"){
					if(new String(oElement.id).slice(0,3)=="im"+new String(nmbr)){
						oElement.style.display = "block"
					}
			}
		}
		nmbr++
		if(nmbr>4){
			nmbr=1}
		tnum=nmbr
		topimg=setTimeout('changeImages(tnum)',5000)
	
}

function roundedCorners(dname) { 
 for(var c=0; c<dname.length; c++){
	 var dn=dname[c]
	 var dnlong="rounded"+dn
	 var divs = document.getElementsByTagName('div'); 
	 var rounded_divs = []; 
	 /* First locate all divs with 'rounded' in their class attribute */
	 for (var i = 0; i < divs.length; i++) { 
	   
	  var re= new RegExp('\\b'+dnlong+'\\b')
	  if (re.exec(divs[i].className)) { 
	     rounded_divs[rounded_divs.length] = divs[i]; 
	   } 
	 } 
	/* Now add additional divs to each of the divs we have found */ 
	 for (var i = 0; i < rounded_divs.length; i++) {
	   var original = rounded_divs[i]; 
	//   original.className = original.className.replace('roundedde', ''); 
	   original.className = original.className.replace(dnlong, ''); 
	   var h=original.childNodes[0].height
	   var w=original.childNodes[0].width
	   original.style.position='relative'
	   original.style.top='0px'
	   original.style.left='0px'
	   original.style.zindex='1'
	   var one = document.createElement('div'); 
	    one.style.position = 'relative'; 
	   original.parentNode.replaceChild(one, original); 
	   var two = document.createElement('div');
	   two.style.position='absolute'
	   two.style.top='0px'
	   two.style.left='0px'
	   two.style.zindex='2'
	   var three = document.createElement('div');
	   three.style.position='absolute'
	   three.style.top='0px'
	   three.style.left=w-10
	   three.style.zindex='2'
	   var four = document.createElement('div');
	   four.style.position='absolute'
	   four.style.top=h-11
	   four.style.left='0px'
	   four.style.zindex='2'
	   var five = document.createElement('div');
	   five.style.position='absolute'
	   five.style.top=h-11
	   five.style.left=w-10
	   five.style.zindex='2'
	   var ltc = document.createElement('img');
	   ltc.src = '/images/corners/ltc'+dn+'.gif'
	   ltc.style.border = 'none'
	   var rtc = document.createElement('img');
	   rtc.src = '/images/corners/rtc'+dn+'.gif'
	   rtc.style.border = 'none'
	   var lbc = document.createElement('img');
	   lbc.src = '/images/corners/lbc'+dn+'.gif'
	   lbc.style.border = 'none'
	   var rbc = document.createElement('img');
	   rbc.src = '/images/corners/rbc'+dn+'.gif'
	   rbc.style.border = 'none'
	  /* Now glue the nodes back in to the document */ 
	   one.appendChild(original); 
	   one.appendChild(two); 
	   two.appendChild(ltc); 
	   one.appendChild(three); 
	   three.appendChild(rtc); 
	   one.appendChild(four); 
	   four.appendChild(lbc); 
	   one.appendChild(five); 
	   five.appendChild(rbc); 
	  }
	} 
} 



/* handle preloading of images */
var homedir=""

var saImgs=new Array;
saImgs[0] = homedir + "/images/fp-image1.jpg";
saImgs[1] = homedir + "/images/fp-image1.jpg";
saImgs[2] = homedir + "/images/fp-image1.jpgf";
saImgs[3] = homedir + "/images/fp-image1.jpg";

function preloadImages()
{
	var i;
	var o = new Array;

	for(i = 0; i < saImgs.length; i += 1)
	{
		o[i] = new Image();
		o[i].src = saImgs[i];
	}
}



/*

          Tips & Tricks

             1: Use the 'enable_visual_design_mode' parameter below to turn the visual design pad on or off.
                When set to false the visual pad is not loaded and there is no overhead added to the menu. All
                required source code for the menu to function is included within this document.  There are no
                communications with OpenCube or other third party servers when the design pad is disabled.

             2: Adjust the "function imenus_data0()" numeric id in the statement below to match the numeric id of
                the id='imenus0' statement within the menu structure and links section above.  The numbers must
                match for the menu to work, multiple menus may be used on a single page by adding new sections
                with new id's.

             3: To specifically define settings for an individual item or container, apply classes or inline styles
                directly to the UL and A tags in the HTML tags which define your menus structure and links above.

             4: Use the parameter options below to define borders and padding.  Borders and padding specified
                within the menus HTML structure may cause positioning and actual sizing to be offset a bit in
                some browsers.

             5: Padding values in sequence apply to the top, right, bottom, and left edges in that order.

*/




/*-------------------------------------------------
************* Parameter Settings ******************
---------------------------------------------------*/


function imenus_data0(){

	this.unlock = "Add your unlock statement here."
	this.enable_visual_design_mode = false

	this.main_is_horizontal = true
	this.menu_showhide_delay = 0


   /*---------------------------------------------
   Images (expand and pointer icons)
   ---------------------------------------------*/


	this.main_expand_image = '/images/menus/main_arrow.gif'
	this.main_expand_image_hover = '/images/menus/main_blank.gif'
	this.main_expand_image_width = '13'
	this.main_expand_image_height = '13'
	this.main_expand_image_offx = '-5'
	this.main_expand_image_offy = '0'

	this.sub_expand_image = '/images/menus/sub_arrow.gif'
	this.sub_expand_image_hover = '/images/menus/sub_arrow.gif'
	this.sub_expand_image_width = '14'
	this.sub_expand_image_height = '14'
	this.sub_expand_image_offx = '-5'
	this.sub_expand_image_offy = '0'






   /*---------------------------------------------
   Global Menu Styles
   ---------------------------------------------*/

	//Main Menu

	this.main_container_styles = "background-image:url(/images/menus/sample4_main_bg_default.gif); border-style:solid; border-color:#000099; border-left-width:1px; border-bottom-width:1px; border-right-width:0px; border-top-width:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; "
	//this.main_item_styles = "color:#ffffff; text-align:left; font-family:verdana; font-size:11px; font-weight:normal; font-style:normal; text-decoration:none; border-style:none; border-color:#aaccfb; border-width:0px; padding:2px 0px 5px 10px; "
	this.main_item_styles = "color:#000099; text-align:left; font-family:Arial Narrow; font-size:11px; font-weight:normal; text-decoration:none; padding-top:9px; padding-right:5px; padding-bottom:10px; padding-left:15px; border-style:none; border-color:#000000; border-width:0px; "
	//this.main_item_hover_styles = "background-color:#37a8ef; color:#ffffff; "
	this.main_item_hover_styles = "background-image:url(/images/menus/sample4_main_bg_rolld.gif); color:#ffffff; "
	this.main_item_active_styles = ""



	//Sub Menu

	this.subs_container_styles = "background-color:transparent; border-style:none; border-color:#356595; border-width:0px; padding-top:5px; padding-right:5px; padding-bottom:5px; padding-left:5px; "
	this.subs_item_styles = "color:#000099; text-align:left; font-family:arial; font-size:11px; font-weight:normal; text-decoration:none; padding-top:2px; padding-right:5px; padding-bottom:2px; padding-left:8px; border-style:none; border-color:#000000; border-width:1px; "
	this.subs_item_hover_styles = "color:#999999; "
	this.subs_item_active_styles = ""



}


function divpos(){
			var oElements = document.getElementsByTagName ? document.getElementsByTagName("TD") : 
			document.all ? document.all.tags("TD") : null;
			var bDOM, oElement, sId;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(oElement.id=="wrapper2"){
					var ph=oElement.offsetHeight
					if(ph<=350)
						ph=335
				}			
			}

			var oElements = document.getElementsByTagName ? document.getElementsByTagName("DIV") : 
			document.all ? document.all.tags("DIV") : null;
			bDOM = (oElements.item(0).getAttribute != null && typeof(oElements.item(0).className) == "undefined");
			for(i = 0; i < oElements.length; i++)
			{
				oElement = oElements.item(i);
				if(oElement.id=="wrapper"){
					var th=oElement.offsetHeight
				}			
				if(oElement.id=="bnews"){
					var bh=oElement.offsetHeight
					var oh=ph-bh
					oElement.style.top=th+oh
				}			
			}
}






//GO1.1


///////////////////////////////////////
//
//  Generic onload by Brothercake
//  http://www.brothercake.com/
//
///////////////////////////////////////



//onload function
function generic()
{
	//preloadImages();
	//changeImages(Math.round(1+(Math.random()*3)))
	//roundedCorners(["","e8","fe"]);
	divpos();
}



//setup onload function
if(typeof window.addEventListener != 'undefined')
{
	//.. gecko, safari, konqueror and standard
	window.addEventListener('load', generic, false);
}
else if(typeof document.addEventListener != 'undefined')
{
	//.. opera 7
	document.addEventListener('load', generic, false);
}
else if(typeof window.attachEvent != 'undefined')
{
	//.. win/ie
	window.attachEvent('onload', generic);
}

//** remove this condition to degrade older browsers
else
{
	//.. mac/ie5 and anything else that gets this far
	
	//if there's an existing onload function
	if(typeof window.onload == 'function')
	{
		//store it
		var existing = onload;
		
		//add new onload handler
		window.onload = function()
		{
			//call existing onload function
			existing();
			
			//call generic onload function
			generic();
		};
	}
	else
	{
		//setup onload function
		window.onload = generic;
		
	}
}
