String.prototype.trim = function(){  
  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
} 

var box_middle_html="";

//var to have access to media objects on page
var mediaIds=new Array();
var contentpage_mediaIds=new Array();
var homepage_mediaIds=new Array();
//w&h
 	 function getNewHeight(aWidth, originalHeight, originalWidth){
 		newHeight=Math.round(originalHeight/(originalWidth/aWidth));
 		return newHeight;
 	}
	
 	function getNewWidth(aHeight, originalHeight, originalWidth){
 		newWidth=Math.round(originalWidth/(originalHeight/aHeight));
 		return newWidth;
 	}

//media actions
function contentpage_showMedia(aId){
		
	element=document.getElementById(aId);
	pureElement=element;

	for(i in element.childNodes){
		if(element.childNodes[i].nodeName=="OBJECT"){ //IS i.e FLASH!
			break;
		}
	}
	if(pureElement!=false){
		newElement=pureElement.cloneNode(true);
		newElement.id="bigimage";
		w=pureElement.getAttribute("originalWidth");
		h=pureElement.getAttribute("originalHeight");
		if(w>520){				
      		h=getNewHeight(520,h,w);
      		w=520;
      	}
		newElement.width=w;
		newElement.height=h
		newElement.style.position="static";
		if(newElement.getElementsByTagName("embed").length>0){
			newElement.getElementsByTagName("embed")[0].width=w;
			newElement.getElementsByTagName("embed")[0].height=h;
			newElement.getElementsByTagName("embed")[0].style.position="static";
		}
		document.getElementById("contentpage_mainimage").innerHTML="";
		document.getElementById("contentpage_mainimage").appendChild(newElement);
	}
}

function contentpage_setDefaultMedia(){
	if(contentpage_mediaIds.length==0){
		try{
			document.getElementById("mediabox").innerHTML="";
		}
		catch(e){}
	}
	
	for(i in contentpage_mediaIds){
  	if(contentpage_mediaIds!=null&&document.getElementById(contentpage_mediaIds[i])){
			contentpage_showMedia(contentpage_mediaIds[i]);
			break;
  	}
	}
	
}

function contentpage_initMedia(){
	count=0;
	for(i in contentpage_mediaIds){
  		if(contentpage_mediaIds[i]!=null&&document.getElementById(contentpage_mediaIds[i])){
  			count++;
    		}
		}

	if(count==0){
			
		try{
			document.getElementById("mediabox").innerHTML="";
		}
		catch(e){}
	}

	else if(count>1){
  		for(i in contentpage_mediaIds){
    			if(contentpage_mediaIds!=null&&document.getElementById(contentpage_mediaIds[i])){
      		m=document.getElementById(contentpage_mediaIds[i]);
					m.style.cursor="pointer";
       		m.onclick=function(){
        								contentpage_showMedia(this.id);
        								return false;
        							}    
					}					
  		}		
	}
	else{
		for(i in contentpage_mediaIds){
  		if(contentpage_mediaIds!=null&&document.getElementById(contentpage_mediaIds[i])){
				m=document.getElementById(contentpage_mediaIds[i]);
				box=document.getElementById("mediaboxsmall");
				m.style.display="none";
				box.innerHTML="";
				break;
    		}
		}
	}			
}

function homepage_initMedia(){
	for(i in homepage_mediaIds){
		if(homepage_mediaIds[i]!=null&&document.getElementById(homepage_mediaIds[i])){
			element=document.getElementById(homepage_mediaIds[i]);
			w=element.getAttribute("width");
			h=element.getAttribute("height");
			if(w>408){				
      		h=getNewHeight(408,h,w);
      		w=408;
      	}
			if(element.getElementsByTagName("embed").length>0){
			element.getElementsByTagName("embed")[0].width=w;
			element.getElementsByTagName("embed")[0].height=h;
			element.getElementsByTagName("embed")[0].style.position="static";
			}
		element.width=w;
		element.height=h;
		}
	}
}

//attachment rollover
function showAttachmentDetails(details){
	document.getElementById("attachment_details").innerHTML=details;
}
function hideAttachmentDetails(){
	document.getElementById("attachment_details").innerHTML="";
}



//+++++++++++++++++++++++ SCROLL NEWS


/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=4 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=0 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeedNews=marqueespeed
var pausespeed=(pauseit==0)? copyspeedNews: 0
var actualheightNews=''

function scrollmarqueeNews(){
  if(copyspeedNews>0){//up
    //if (parseInt(cross_marquee.style.top)<(actualheightNews*(-1)+8)){
		if (parseInt(cross_marquee.style.top)>(actualheightNews-200)*-1){
    	cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeedNews+"px";
    }
    else{
    	//cross_marquee.style.top=parseInt(marqueeheight)+8+"px";
			cross_marquee.style.top=(actualheightNews-200)*-1;
    }
  }
	else if((copyspeedNews<0)&&parseInt(cross_marquee.style.top)<0){
		//if (parseInt(cross_marquee.style.top)>(200*(+1)+8)){
		if (parseInt(cross_marquee.style.top)>0){
			//cross_marquee.style.top=-parseInt(marqueeheight)-200+8+"px";
			cross_marquee.style.top=0;
    	//cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeedNews+"px";
    }
    else{
    	cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeedNews+"px";
    }
	}
}

function startmarqueeNews(){
	copyspeedNews=marqueespeed;
}
function startmarqueedownNews(){
	copyspeedNews=-marqueespeed;
}
function pausemarqueeNews(){
	copyspeedNews=0;
}

function initializemarqueeNews(){
if(document.getElementById("marqueecontainerNews")){
  pausemarqueeNews();
  cross_marquee=document.getElementById("vmarqueeNews")
  cross_marquee.style.top=0
  marqueeheight=document.getElementById("marqueecontainerNews").offsetHeight
  actualheightNews=cross_marquee.offsetHeight
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
  cross_marquee.style.height=marqueeheight+"px"
  cross_marquee.style.overflow="scroll"
  return
  }
  setTimeout('lefttime=setInterval("scrollmarqueeNews()",30)', delayb4scroll)
}
}

if (window.addEventListener)
window.addEventListener("load", initializemarqueeNews, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarqueeNews)
else if (document.getElementById)
window.onload=initializemarqueeNews

/*****************************   SCROLL AGENDA


//+++++++++++++++++++++++ SCROLL Agenda


/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=4 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=0 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeedAgenda=marqueespeed
var pausespeed=(pauseit==0)? copyspeedAgenda: 0
var actualheightAgenda=''

function scrollmarqueeAgenda(){
  if(copyspeedAgenda>0){
    //if (parseInt(cross_marqueeAgenda.style.top)>(actualheightAgenda*(-1)+8)){
		if (parseInt(cross_marqueeAgenda.style.top)>(actualheightAgenda-200)*-1){
    	cross_marqueeAgenda.style.top=parseInt(cross_marqueeAgenda.style.top)-copyspeedAgenda+"px";
    }
    else{
    	//cross_marqueeAgenda.style.top=parseInt(marqueeheight)+8+"px";
			cross_marqueeAgenda.style.top=(actualheightAgenda-200)*-1;
    }
  }
	else if((copyspeedAgenda<0)&&parseInt(cross_marqueeAgenda.style.top)<0){
		//if (parseInt(cross_marqueeAgenda.style.top)>(200*(+1)+8)){
		if (parseInt(cross_marqueeAgenda.style.top)>0){
			//cross_marquee.style.top=-parseInt(marqueeheight)-200+8+"px";
			cross_marqueeAgenda.style.top=0;
			//cross_marqueeAgenda.style.top=-parseInt(marqueeheight)-200+8+"px";
    	//cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeedAgenda+"px";
    }
    else{
    	cross_marqueeAgenda.style.top=parseInt(cross_marqueeAgenda.style.top)-copyspeedAgenda+"px";
    }
	}
}

function startmarqueeAgenda(){
	copyspeedAgenda=marqueespeed;
}
function startmarqueedownAgenda(){
	copyspeedAgenda=-marqueespeed;
}
function pausemarqueeAgenda(){
	copyspeedAgenda=0;
}

function initializemarqueeAgenda(){
if(document.getElementById("marqueecontainerAgenda")){
  pausemarqueeAgenda();
  cross_marqueeAgenda=document.getElementById("vmarqueeAgenda")
  cross_marqueeAgenda.style.top=0
  marqueeheight=document.getElementById("marqueecontainerAgenda").offsetHeight
  actualheightAgenda=cross_marqueeAgenda.offsetHeight
  if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
  cross_marqueeAgenda.style.height=marqueeheight+"px"
  cross_marqueeAgenda.style.overflow="scroll"
  return
  }
  setTimeout('lefttime=setInterval("scrollmarqueeAgenda()",30)', delayb4scroll)
	}
}

if (window.addEventListener)
window.addEventListener("load", initializemarqueeAgenda, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarqueeAgenda)
else if (document.getElementById)
window.onload=initializemarqueeAgenda

