

     var preloadImageArray = Array();
	 var popupPrintWindow = null; //to open a popup window
	 var pageName = ""; //must me initialized with the page name of the current page!!
	 var videoWindow = null;
	 var videoPopUpWindow = null;
	 
	 function initializePageGlobal(){
			enlargeRightColumn();
			preloadImages();
   	}
	
	function getEvent( event ){
		if (!event) event = window.event

		if (event.target) {
			if (event.target.nodeType == 3) event.target = event.target.parentNode
		} else if (event.srcElement) {
			event.target = event.srcElement
		}

		return event
	}
	
	function handleEnterSubmission (field, evt) {
		var keyCode = evt.which ? evt.which : evt.keyCode;
		if (keyCode == 13) {
				field.form.submit();
				
			 var aform = document.getElementById("searchform1")
			 
			 if ( aform){
				 //var keyword = document.getElementById("keyword")
				
				 aform.submit();
			 }
				return false;
		}
		else{ 
			return true;
		}
	}
		
	
	
	
	
	
	function reloadFor800Resolution(){
		var criticalWidth = 800;
		var toredirect = "";
		if ( pageName!= "" && screen.width && screen.width <= criticalWidth ) {
			//alert("screen is less than "+ criticalWidth +"!!");
			if ( pageName.indexOf("?") == -1 ) {
				toredirect = pageName + "?res800=true";
			}else{
				toredirect = pageName + "&res800=true";
			}
	
			window.location = toredirect;

		}
	}
	 

	 /* Enlarge right column, to make it expand all the way down (to the footer) */
	 function enlargeRightColumn(){

			var rightcol = document.getElementById("rightcol2content");
			if ( rightcol ) {

				var tablecenter = document.getElementById("tablecenter");
				if ( tablecenter ) {
					var aheight = getObjectHeight(tablecenter);
					rightcol.style.height =  aheight+ "px";					
				}
			}else{
				//alert("not found");
			}
		 
	 }
	 
     function preloadImages() {

			for(var loop = 0; loop < preloadImageArray.length; loop++) {
				var an_image = new Image();
				//alert("preloading " + preloadImageArray[loop] );
				an_image.src = preloadImageArray[loop];
				
			}                
    }
	
	function preloadImage( imagesrc ) {
		// Cristhian Alcantara 20060117
		// preload 1 single image only
		var an_image = new Image();
		an_image.src = imagesrc
		//alert("preloading " + imagesrc );
	}
	
	function toggleImages(thisImg, thisToggleImg) {
		// In Koo Kim 20051228
		// this method toggles the images (usually on a mouseover)
		// thisImg == image id 
		// thisToggleImg == new image relative path
		document.images[thisImg].src = thisToggleImg;
	}
	function toggleImageObj(aimg, thisToggleImg) {
		// In Koo Kim 20051228
		// this method toggles the images (usually on a mouseover)
		// thisImg == image id 
		// thisToggleImg == new image relative path
		aimg.src = thisToggleImg;
	}
	
	
	function toggleCss( id , newcss ) {
		
		var obj = document.getElementById( id );
		if ( obj ) {
				obj.className = newcss;
		}
	}
	
	function getObjectHeight( divobj ){

			var height = 0;
		
			if ( !divobj ){
				alert("error");
			}
		
			if(divobj.offsetHeight){ 	
		
				height = divobj.offsetHeight;
				
			}else if(divobj.style.pixelHeight){ 	
				height = divobj.style.pixelHeight;
			}
		
			else if(divobj.style.height){ 	
				height = divobj.style.height;
			}
		
			//alert( "height is " + height );
		
			return height;
  }

  function openPrintWindow( url ) {
	  	
			var nWidth = 650;
			var nHeight = 650;
			var x = (screen.width - nWidth) / 3;
			var y = (screen.height - nHeight) / 3;		

			var optionString = "scrollbars=yes,location=no,resizable=yes,status=no,";
			optionString += "height=" + nHeight + ",width=" + nWidth;
			optionString += ",screenX="+ x +",screenY="+ y +",top="+ y +",left="+ x;

		    if (! popupPrintWindow || popupPrintWindow.closed ) {
		    	popupPrintWindow = window.open(url,"windowPrintView",optionString);
		    } else {
		    	// window already exists, so bring it forward
			    popupPrintWindow.location.href=url;
			    popupPrintWindow.focus();
			}
	}

	function openVideoClip( url ) {
		
			var nWidth = 375;
			var nHeight = 325;
			var x = (screen.width - nWidth) / 3;
			var y = (screen.height - nHeight) / 3;		

			var optionString = "scrollbars=yes,location=no,resizable=yes,status=no,";
			optionString += "height=" + nHeight + ",width=" + nWidth;
			optionString += ",screenX="+ x +",screenY="+ y +",top="+ y +",left="+ x;

		    if (! videoWindow || videoWindow.closed ) {
		    	videoWindow = window.open(url,"videoWindow",optionString);
		    } else {
		    	// window already exists, so bring it forward
			    videoWindow.location.href=url;
			    videoWindow.focus();
			}
		
	}

 	function doPrintPage(){
		
			window.print();
	}
	
	
	/* Interstitial and protected popup javascript windows */
	
    var subModalTargetPage = '/Default.asp';  //default
	var subModalProtectedTargetPage = ""; 
	var openNewWindow = false
	
    function inter1(targetPage) {
				openNewWindow = false
                if (targetPage && targetPage != '') {
                    subModalTargetPage = targetPage;
                }
                scroll(0,0);
				if (  document.getElementById('popupTitle') ) {
					document.getElementById('popupTitle').innerHTML = '';
				}
                showPopWin('/inter1.html', 510, 290);
                changeOpac(40,'popupMask');
                
                
                return false;
  	}

	
	function inter2(targetPage) {
				inter3(targetPage)
                
                return false;
  	}
	
	
	
	function inter3(targetPage) {
				openNewWindow = true
                if (targetPage && targetPage != '') {
                    subModalTargetPage = targetPage;
                }
                scroll(0,0);
				if (  document.getElementById('popupTitle') ) {
					document.getElementById('popupTitle').innerHTML = '';
				}
                showPopWin('/inter1.html?new=true', 510, 290);
                changeOpac(40,'popupMask');
                
                
                
  	}
	

	function protectedpage( protectedTargetPage ) {
				
		  		
                subModalProtectedTargetPage = protectedTargetPage ;
              
		
                scroll(0,0);
				if (  document.getElementById('popupTitle') ) {
					document.getElementById('popupTitle').innerHTML = '';
				}
                showPopWin('/protected.html', 510, 210);
                changeOpac(40,'popupMask');
                
                
  	}
	
	function noflashinter() {
				
		  		
                scroll(0,0);
				if (  document.getElementById('popupTitle') ) {
					document.getElementById('popupTitle').innerHTML = '';
				}
                showPopWin('/noflash.html', 510, 210);
                changeOpac(40,'popupMask');
                
                
  	}
	
	
    function changeOpac(opacity, objectid) {
                    var object = document.getElementById( objectid ).style;
                    object.opacity = (opacity / 100); 
                    object.MozOpacity = (opacity / 100); 
                    object.KhtmlOpacity = (opacity / 100); 
                    object.filter = "alpha(opacity=" + opacity + ")"; 
                    // object.style.filter = "alpha(opacity=" + opacity + ")"; 
    }	

	
	
	function TooltipKeyword(keyword, definition) {
                this.keyword=keyword;
                this.definition=definition;
    }


    function ConstructTooltip(tooltipKeyObj) {
    
				var tooltip_body = '<table cellpadding="0" cellspacing="0" border="0" id="tooltiptable" >'+
										'<tr>' +
											'<td width="9"><img src="/images/tooltip2/body_01.gif" width="9" height="8"></td>' +
											'<td width="268" class="backtop"><img src="/images/b.gif" width="1" height="1"></td>' +
											'<td width="9"><img src="/images/tooltip2/body_03.gif" width="9" height="8"></td>' +
										'</tr>'+
										'<tr>' +
											'<td class="backleft"><img src="/images/b.gif" width="1" height="1"></td>' +
											'<td class="content"><span class="title">'+  tooltipKeyObj.keyword+ '</span> '+ tooltipKeyObj.definition +'</td>' +
											'<td class="backright"><img src="/images/b.gif" width="1" height="1"></td>' +
										'</tr>'+
										'<tr>' +
											'<td><img src="/images/tooltip2/body_07.gif" width="9" height="9"></td>' +
											'<td class="backbottom"><img src="/images/b.gif" width="1" height="1"></td>' +
											'<td><img src="/images/tooltip2/body_09.gif" width="9" height="9"></td>' +
										'</tr>'+
									'</table>';
										
										
                return tooltip_body;
    }


	function TooltipConfig(e, width, xOffset, yOffset, above) {
                // In Koo Kim 20060104
                // the following configures the wz_tooltip
                if (xOffset && xOffset != null) {
                    e.T_OFFSETX=xOffset;
                } else {
                    e.T_OFFSETX=10;
                    e.T_OFFSETY=10;
                }
                if (yOffset && yOffset != null) {
                    e.T_OFFSETY=yOffset;
                } else {
                    e.T_OFFSETY=10;
                }
                if (above && above != null) {
                    e.T_ABOVE=above;
                }
                e.T_DELAY = 300;
                e.T_BGCOLOR='';
                e.T_BGIMG='';
                e.T_BORDERWIDTH=0;
                e.T_BORDERCOLOR='';
                e.T_FONTCOLOR='#333333';
                e.T_FONTFACE='Verdana, Geneva, Arial, Helvetica, sans-serif';
                e.T_FONTSIZE='12px';
                e.T_OPACITY=100;
                e.T_PADDING=0;
                e.T_STATIC=true;
                e.T_TEXTALIGN='right';
                e.T_TITLE='';
                e.T_TITLECOLOR='#ff6666';
                e.T_WIDTH=width;
                return e;
      }
	  
	  function onVideoClickOpenRegistrationParent(){
		  alert('will try to redirect parent ')
		  window.parent.location.href = "/join/register.asp"
		  window.close();
	  }
	  
	  /* To close the videoclips and show registration page afterwards */
	  
	  function popclose(){
		  
		  alert("hello");
		  //window.opener.location = "/join/register.asp"
		  //window.close();
		  
	  }
	  
	  function popcloseBen(){
		  closePopUpVideo("/hear/ben");
	  }
	  function popcloseStefano(){
		  closePopUpVideo("/hear/stefano");
	  }
	  function popcloseGrazia(){
		  closePopUpVideo("/hear/maria");
	  }
	  function popcloseMarcello(){
		  closePopUpVideo("/hear/marcello");
	  }
	  
	  function closePopUpVideo(  someurl ){
		  window.opener.location = someurl;
		  window.close();
	  }
	  
	
	  /* Popup blocker detection */
	  
	  function IsPopupBlocker() {
				
		  		var strNewURL = "/blank.html"
				var Strfeature = "" ;
				var WindowOpen = window.open(strNewURL,"MainWindow",Strfeature);
				try{
					var obj = WindowOpen.name;
					WindowOpen.close();
					return false;
					//alert("Popup blocker NOT detected");
				} 
				catch(e){ 
					//alert("System has been blocked by POP-UP BLOCKER.\nPlease disable the POP-UP BLOCKER and try again\nor\nPlease contact your system administrator. ");
					
				}
				return true;
	}
	
	function openvideo( anid ){
			
				var url = "/downloadwrapper.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
				scroll(0,0);
				if (  document.getElementById('popupTitle') ) {
					document.getElementById('popupTitle').innerHTML = '';
				}
                showPopWin(  url , 510, 210);
                changeOpac(40,'popupMask');
	}
	function openvideoNewWindowPopup( anid ){
	
				    
					//alert("will open " + anid )
					
			//openvideoWithoutWrapper( anid )
					//var url = "/downloadwrapper.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
					
					//try{
											//var url = "/download.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
						//alert("url will be " + url)
											//window.location =  url
						//window.open(url)
					//}catch(e){
						//var r = '';
						//for (var p in e)
						//  r += p + ': ' + e[p] + '\n';
						//alert(r);
					//}
		
				//alert("received " + anid )
				
				
				
				var message = "\n\nPlease disable your popup blocker system to be able to download the videos\n\n" 
				//if ( IsPopupBlocker() ) {
				//	alert(message);
				//}else{
					//var url = "/download.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
					var url = "/downloadwrapper.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
					//alert("will open " + url )
					try{
							var nWidth = 500;
							var nHeight = 200;
							var x = (screen.width - nWidth) / 3;
							var y = (screen.height - nHeight) / 3;		
				
							var optionString = "scrollbars=no,location=no,resizable=no,status=no,";
							optionString += "height=" + nHeight + ",width=" + nWidth;
							optionString += ",screenX="+ x +",screenY="+ y +",top="+ y +",left="+ x;
				
							if (! videoPopUpWindow || videoPopUpWindow.closed ) {
								videoPopUpWindow = window.open(url,"videoPopUpWindow",optionString);
							} else {
								// window already exists, so bring it forward
								videoPopUpWindow.location.href=url;
								videoPopUpWindow.focus();
							} 
					}catch(e){
						alert(message);
					}
				
					
					
					
	}
	
	function openvideoWithoutWrapper( anid ){
		
				
	
				//var message = "\n\nPlease disable your popup blocker system to be able to download the videos\n\n" 
				//if ( IsPopupBlocker() ) {
						//alert(message);
				//}else{
					//var url = "/download.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
					var url = "/downloadwrapper.asp?id=" + anid + "&nocache=" + (new Date()).getTime();
					//alert("will open " + url )
					try{
						window.location.href =  url
					}catch(e){
						//alert(message);
					}
				//}
				
					
					
					
	}
	  
	function addToDiv( divid, toadd) {
	
		var adiv = document.getElementById( divid );
		if ( adiv){
			adiv.innerHTML += toadd;
		}
	}

	var flashVersion = 0;
	
	function getFlashVersion ( ) {
		
			/*
			for(var i=7; i>0; i--){
				flashVersion = 0;
				try{
					var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					flashVersion = i;
				}
				catch(e){
						var r = '';
						for (var p in e)
						  r += p + ': ' + e[p] + '\n';
						alert(r);

				}
			}
			return flashVersion;
			*/
			var flashinstalled = 0;
			var flashversion = 0;
			MSDetect = "false";
			if (navigator.plugins && navigator.plugins.length)
			{
				x = navigator.plugins["Shockwave Flash"];
				if (x)
				{
					flashinstalled = 2;
					if (x.description)
					{
						y = x.description;
						flashversion = y.charAt(y.indexOf('.')-1);
					}
				}
				else
					flashinstalled = 1;
				if (navigator.plugins["Shockwave Flash 2.0"])
				{
					flashinstalled = 2;
					flashversion = 2;
				}
			}
			else if (navigator.mimeTypes && navigator.mimeTypes.length)
			{
				x = navigator.mimeTypes['application/x-shockwave-flash'];
				if (x && x.enabledPlugin)
					flashinstalled = 2;
				else
					flashinstalled = 1;
			}
			else{
				MSDetect = "true";
			}
			
			return flashversion 
			
	}
	

