/*
Site JavaScript file
    - At the top are our custom site functions
    - At the bottom is the JS-Menu script
*/

// These three lines are used by JS-Menu, but are listed at the top so they can be referred to by our functions
var DOM = document.getElementById;
var IE4 = document.all;
var NN4 = document.layers;


// Redirect browsers that are too old
if (NN4) document.location.href = "/unsupported.html"


//Google analytics code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12108010-2']);
_gaq.push(['_setDomainName', '.mwhsoft.com']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


// Draw page elements
function drawPage(){
    menuStrip();
    mainMenu();
    topBarTools();
    loginBox();
    screenShotBox();
    footer();
    sideBarSwitch();
    shrinkLayout();
    //ga();
}

function drawFrontPage(){
    menuStrip();
    mainMenu();
    topBarTools();
    loginBox();
    footer();
    shrinkLayout();
    //ga();
    getNews();
}

function drawSupportPage(){
    menuStrip();
    mainMenu();
    loginBox();
    footer();
    //ga();
    sideBarSwitch();
}

// Draw background image at top of page, background strip for menu and items to the right of the menu
function menuStrip(){
    document.write("<div id='headImage'><img src='/images/structure/header_images/" + headerImage() + "' alt='MWH Soft Products' usemap='#barMap' style='border-width:0px;' /><map name='barMap'><area shape='rect' coords='0,0,250,100' href='/' alt='MWH Soft'</map></div>")
    document.write("<div id='menuStrip'><table id='contactUsTable'><tr><td><img src='/images/structure/menuStripPhone.gif' style='width:20px;height:20px;border-width:0px;' alt='Contact Us' /></td><td class='contactUsCell' style='padding:0px 5px'><a href='/contactus/'>Contact Us</a> | <a href='/quote/'>Request a Quote</a></td></tr></table></div>")
    headerImage();
}

function headerImage(){

    var thePattern = /http:\/\/[\w\.-]+\/{1}/i;
	var theServer = document.location.href.match(thePattern)[0]; // extract server name so current page can be compared to link
	var currentPage = document.location.href.replace(theServer,"");
	if (currentPage.search(/products/)==0){
	    return "headerBG_products.jpg"
	}else if (currentPage.search(/pricing/)==0){
	    return "headerBG_products.jpg"    
	}else if (currentPage.search(/support/)==0){
	    return "headerBG_support.jpg"
	}else if (currentPage.search(/p_support/)==5){
	    return "headerBG_support.jpg"
    }else if (currentPage.search(/updates/)==0){
	    return "headerBG_support.jpg"
	}else if (currentPage.search(/about/)==0){
	    return "headerBG_about.jpg"
	}else if (currentPage.search(/education/)==0){
	    return "headerBG_education.jpg"
	}else if (currentPage.search(/services/)==0){
	    return "headerBG_services.jpg"
	}else if (currentPage.search(/news/)==0){
	    return "headerBG_news.jpg"
	}else {
	    return "headerBG_general.jpg"
	}
	

}


// Copy HTML from holders into side columns. Keeps things tidy and improves SEO
function sideBarSwitch(){
    if (document.getElementById("leftBarContent")){
        if(DOM) document.getElementById("leftBar").innerHTML = document.getElementById("leftBarContent").innerHTML;
        else if(IE4) document.all["leftBar"].innerHTML = document.all["leftBarContent"].innerHTML;
    }
    
    if (document.getElementById("rightBarContent")){
        if(DOM) document.getElementById("rightBar").innerHTML = document.getElementById("rightBarContent").innerHTML;
        else if(IE4) document.all["rightBar"].innerHTML = document.all["rightBarContent"].innerHTML;
    }
    
}


// Draw standard page footer
function footer(){
    var today = new Date();
    footerHTML = "&copy; Copyright " + today.getFullYear() + ", MWH Soft. All rights reserved.<br/><a href='/about/privacy.aspx'>Privacy</a> | <a href='/about/terms.aspx'>Terms of Use</a>";
    if(DOM) document.getElementById("footer").innerHTML = footerHTML;
    else if(IE4) document.all["footer"].innerHTML = footerHTML;
}


// Draw search box, login and register links
function topBarTools(){
    document.write("<div id='topBarTools'>")
    document.write("<div style='float:right'><input type='text' onkeydown='searchSubmit(this,event)' onfocus='this.value=\"\";' id='searchBox' value='Search Articles' /> ")
    
    if (lb==1){
        document.write("<a href='javascript:showLogin(0)'>Logout</a> | <a href='/user/register/'>Profile</a></div>")
    }else{
        document.write("<a href='javascript:showLogin(0)'>Login</a> | <a href='/user/register/'>Register</a></div>")
    }    
    document.write("</div>")
}


// Search button onKeyDown function. Looks for [Return] in order to submit search request
function searchSubmit(theField,e){
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13)
       {
       
       window.location.href = "/news/search/?k=" + escape(theField.value);
       
       return true;
       }
    else
       return true;
}

function searchAdvSubmit(){

    if (document.getElementById){
        if ((document.getElementById("searchSide").value != "") && (document.getElementById("searchSide").value != "Search Articles")){
            var scope = "b";   
            if (document.getElementById("scope_title").checked){
                scope = "t";
            } else if (document.getElementById("scope_content").checked){
                scope = "c";
            }
            
            var area = "b";
            if (document.getElementById("area_press").checked){
                area = "p";
            } else if (document.getElementById("area_case").checked){
                area = "c";
            }
            
            var theSearchString = document.getElementById("searchSide").value;
            
            window.location.href = "/news/search/?k=" + escape(theSearchString) + "&s=" + scope + "&a=" + area;
           
            
        }
    }
}


// Draws loginBox in either logged in or logged out format
function loginBox(){

    if (lb==1){
        document.write("<div id='loginBox'>")
        document.write("<form action='/user/login/index.aspx' enctype='application/x-www-form-urlencoded' method='post'>")
        document.write("<table style='width:100%'>")
        document.write("<tr>")
        document.write("<td colspan='2'>Please confirm that you wish to logout.<input type='hidden' name='lb_email' value='logout'/></td>")
        document.write("</tr>")
        document.write("<tr><td colspan='2' style='text-align:center'><input type='submit' value='Logout' name='loginButt' class='loginButt'/> <input type='button' onclick='showLogin(0);' value='Cancel' class='loginButt' /></td></tr>")
        document.write("</table>")
        document.write("</form>")
        document.write("</div>")
    }else{
        document.write("<div id='loginBox'>")
        document.write("<form action='/user/login/index.aspx' enctype='application/x-www-form-urlencoded' method='post'>")
        document.write("<table style='width:100%'>")
        document.write("<tr>")
        document.write("<td>E-mail:</td><td><input type='text' id='emailField' name='lb_email' style='width:125px;font-size:12px;' /></td>")
        document.write("</tr><tr>")
        document.write("<td>Password:</td><td><input type='password' name='lb_pass' style='width:125px;font-size:12px;' /></td>")
        document.write("</tr><tr><td colspan='2' style='text-align:center'><input type='submit' value='Login' name='loginButt' class='loginButt'/> <input type='button' onclick='showLogin(0);' value='Cancel' class='loginButt' /></td></tr>")
        document.write("<tr><td colspan='2' style='text-align:center'><span style='font-size:10px'><a href='/user/login/?help=forgotten'>Forgotten Password?</a></span></td></tr>")
        document.write("</table>")
        document.write("</form>")
        document.write("</div>")
    }  
}





// Shows or hides login box
function showLogin(localLocation){
    if (document.getElementById){
        if (document.getElementById("loginBox").style.visibility == 'visible'){
            document.getElementById("loginBox").style.visibility = 'hidden';
        }else{
            if (localLocation==0){ //make sure login box is in reset position
                document.getElementById("loginBox").style.top  =  "50px";
                if (screen.width < 1200) document.getElementById("loginBox").style.left  = "740px";
                else document.getElementById("loginBox").style.left  = "940px";
            }
	        document.getElementById("loginBox").style.visibility = 'visible';
	        document.getElementById("emailField").focus();
        }
    } else { 
        window.location.href = "/user/login/"; // if old browser send user to login page
    }
}


function localLoginClick(e){
    if (document.getElementById){
	    var posx = 0;
	    var posy = 0;
	
	    if (!e) e = window.event;
	    if (e.clientX || e.clientY){
		    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		    posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	        
		    document.getElementById("loginBox").style.top  =  ((posy+20).toString() + "px")
		    document.getElementById("loginBox").style.left  =  ((posx+20).toString() + "px"); 			     
	    }
    }
    showLogin(1); // Show login box using above position, not reset position
}


function shrinkLayout(){
    if (screen.width < 1200 && document.getElementById){
        //document.getElementById("main").style.width = "975px";
        //document.getElementById("content").style.width = "500px";
        document.getElementById("topBarTools").style.width = "385px";
        // product menu moved by changing "left" code below
        //document.getElementById("menuStrip").style.width = "975px";
        document.getElementById("loginBox").style.left = "740px";
        //document.getElementById("menuStrip").style.backgroundImage = "none";
        //document.getElementById("contactUsTable").style.marginRight = "0px";
        //document.getElementById("footer").style.backgroundImage = "url('/images/structure/footer_1000.jpg')";
        //document.getElementById("footer").style.paddingTop = "30px";
        
    }
}


function screenShotBox(){
    document.write("<div id='screenShot' onclick='hideScreenShot()'><div style='text-align:right;margin-bottom:10px;'>Click to close screenshot</div><img src='/images/structure/loading.gif' id='screenShotImg' border='1'></div>");
}

function showScreenShot(picRef){
	if (document.getElementById){
	        document.getElementById("screenShot").style.left  = Math.floor((pageWidth()-800)/2) + "px" ;       
            if (document.body.scrollTop){
                document.getElementById("screenShot").style.top  = Math.floor((document.body.scrollTop+50)) + "px";
            }else if (document.documentElement.scrollTop){
                document.getElementById("screenShot").style.top  = Math.floor((document.documentElement.scrollTop+50)) + "px";
            }else {
                document.getElementById("screenShot").style.top  = "100px";
            }
			document.getElementById("screenShotImg").src = picRef;
			document.getElementById("screenShot").style.display = 'block';
	}
}

function hideScreenShot(){
	if (document.getElementById){
		document.getElementById("screenShotImg").src = "/images/structure/loading.gif";
		document.getElementById("screenShot").style.display = 'none';
	}
}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}



////////////////////////////////////////////////////////////////////
// sideMenu object constructors and methods
////////////////////////////////////////////////////////////////////

function sideMenuCollection(){		// menuCollection object constructor
		this.menuCount = 0;				// counter to aid iteration through menus
		this.addSideMenu = addSideMenuFunc;		// method linked to additional function
}

function sideMenuObj(shortTextStr,menuDesc){		// menu object constructor
		this.ref = shortTextStr;		// shorten version of text (without spaces) to be used as reference
		this.desc = menuDesc            // longer description of what menu is for
		this.linkCount = 0;				// counter to aid iteration through menu items
		this.addItem = addSideMenuLink;	// method linked to additional function
}

function sideMenuLink(type,title,textStr,itemHref,newWin){	// menuItem object constructor
        this.linkType = type;           // text or image
        this.isTitle = title;           // Is item a section title (1-Yes,0-No)
		this.text = textStr;			// text shown in menu
		this.href = itemHref;			// href for text
		this.blankWin = newWin;			// Is link launched in new window (1-Yes,0-No)
}

function addSideMenuFunc(shortTextStr,menuDesc){			// constructor method
		this.menuCount++;				// increase menuCount
		this[shortTextStr] = new sideMenuObj(shortTextStr,menuDesc);	// create menu object using menuCount to create iterative name
}

function addSideMenuLink(type,title,textStr,itemHref,newWin){	// constructor method
		this.linkCount++;				// increase itemCount
		this["link_" + this.linkCount] = new sideMenuLink(type,title,textStr,itemHref,newWin);	// create menuitem object using itemCount to create iterative name
}

////////////////////////////////////////////////////////////////////
// sideMenu drawing functions
////////////////////////////////////////////////////////////////////


function leftMenu(menuRef){

	var thePattern = /http:\/\/[\w\.-]+\/{1}/i;
	var theServer = document.location.href.match(thePattern)[0]; // extract server name so current page can be compared to link
	
	htmlStr = "";
	thisSideMenu = sideMenus[menuRef];
	
	lastItemIsLink = false; // This will be used to determine if a content div needs closing before a title
	
	for (i=1; i <= thisSideMenu.linkCount; i++){
	
		thisLink = thisSideMenu['link_'+i];
		linkPage = theServer.substr(0,(theServer.length-1))+thisLink.href; // work out full URL of the link
		currentPage = document.location.href;
		currentPage = currentPage.replace(/index.aspx/,""); // remove index page ref
		currentPage = currentPage.replace(/\?\S*/,"");       // remove querystring
		
		if (thisLink.isTitle){
		    if(lastItemIsLink == true) htmlStr = htmlStr + "</div>";    // Close content div if just had link
		    htmlStr = htmlStr + "<div class='leftBarHeader'>" + thisLink.text + "</div>";
		    lastItemIsLink = false;
		    
		} else{ // is link
		    if(lastItemIsLink == false) htmlStr = htmlStr + "<div class='leftBarContent'>";  // Start content div if not preceeded by link
		    
		    if (thisLink.linkType == "text"){   // text Link
		        if (linkPage == currentPage){
		            htmlStr = htmlStr + "<p class='leftBarCurrent'><strong>" + thisLink.text + "</strong></p>";
		        } else {
		            htmlStr = htmlStr + "<p><a href='" + thisLink.href + "' ";
		            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
		            htmlStr = htmlStr + ">";
		            htmlStr = htmlStr +  thisLink.text + "</a></p>";
		        }
		    } else if (thisLink.linkType == "pdf"){   // pdf Link
		            htmlStr = htmlStr + "<p><a href='" + thisLink.href + "' ";
		            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
		            htmlStr = htmlStr + ">";
		            htmlStr = htmlStr +  thisLink.text + "</a>";
		            htmlStr = htmlStr + " <a href='" + thisLink.href + "' ";
		            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
		            htmlStr = htmlStr + ">";
		            htmlStr = htmlStr + "<img src='/images/structure/icons/pdficon_small.gif' style='border-width:0px' align='middle'  /></a></p>";
		    } else if (thisLink.linkType == "image"){   // image Link
		        if (thisLink.href == ""){
		            htmlStr = htmlStr + "<p><img src='" + thisLink.text + "' class='leftBarImage' /></p>";
		        } else {
		            htmlStr = htmlStr + "<p><a href='" + thisLink.href + "' ";
		            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
		            htmlStr = htmlStr + "><img src='" + thisLink.text + "' class='leftBarImage' /></a></p>";
		        }
		    }
		    
		    lastItemIsLink = true;
		}
		
		if (i==thisSideMenu.linkCount){
		    htmlStr = htmlStr + "</div>"
		}
	}
	document.write (htmlStr);
}	

function rightMenu(menuRef){

	var thePattern = /http:\/\/[\w\.-]+\/{1}/i;
	var theServer = document.location.href.match(thePattern)[0]; // extract server name so current page can be compared to link
	
	htmlStr = "";
	thisSideMenu = sideMenus[menuRef];
	
	lastItemIsLink = false; // This will be used to determine if a content div needs closing before a title
	
	for (i=1; i <= thisSideMenu.linkCount; i++){
	
		thisLink = thisSideMenu['link_'+i];
		linkPage = theServer.substr(0,(theServer.length-1))+thisLink.href; // work out full URL of the link
		currentPage = document.location.href;
		currentPage = currentPage.replace(/index.aspx/,""); // remove index page ref
		currentPage = currentPage.replace(/\?\S*/,"");       // remove querystring
		
		if (thisLink.isTitle){
		    if(lastItemIsLink == true) htmlStr = htmlStr + "</div><div class='rightBarFooter'><img src='/images/structure/blank.gif' style='width:1px;height:8px;' /></div>";    // Close content div if just had link
		    
		    htmlStr = htmlStr + "<div class='rightBarContent'><p class='rightBarTitle'>" + thisLink.text + "</p>";
		    lastItemIsLink = false;
		    
		} else if (thisLink.linkType == "image"){ 
		
		    if(lastItemIsLink == true) htmlStr = htmlStr + "</div><div class='rightBarFooter'><img src='/images/structure/blank.gif' style='width:1px;height:8px;' /></div>";    // Close content div if just had link
		    
		    if (thisLink.href == ""){
	            htmlStr = htmlStr + "<p><img src='" + thisLink.text + "' class='rightBarImage' /></p>";
	        } else {
	            htmlStr = htmlStr + "<p><a href='" + thisLink.href + "' ";
	            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
	            htmlStr = htmlStr + "><img src='" + thisLink.text + "' class='rightBarImage' /></a></p>";
	        }
		    lastItemIsLink = false;    
		
		} else if (thisLink.linkType == "text"){   // text Link
		        if (linkPage == currentPage){
		            htmlStr = htmlStr + "<p class='rightBarCurrent'>" + thisLink.text + "</p>";
		        } else {
		            htmlStr = htmlStr + "<p><a href='" + thisLink.href + "' ";
		            if (thisLink.blankWin) htmlStr = htmlStr + " target='_blank' ";
		            htmlStr = htmlStr + ">";
		            htmlStr = htmlStr +  thisLink.text + "</a></p>";
		        }
		       lastItemIsLink = true; 
		}
		
		if (i==thisSideMenu.linkCount){
		    htmlStr = htmlStr + "</div><div class='rightBarFooter'><img src='/images/structure/blank.gif' style='width:1px;height:8px;' /></div>"
		}
	}
	document.write (htmlStr);
}	

function ga(){
    
    var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12108010-2']);
  _gaq.push(['_setDomainName', '.mwhsoft.com']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

    //var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    //document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    //try {
    //var pageTracker = _gat._getTracker("UA-12108010-1");
    //pageTracker._setDomainName(".mwhsoft.com");
   // pageTracker._trackPageview();
    //} catch(err) {}
}


function displaySection(theObjectStr){

	if (DOM){
		if (document.getElementById(theObjectStr).style.display == 'block'){
			document.getElementById(theObjectStr).style.display = 'none';
		}
		else{
			document.getElementById(theObjectStr).style.display = 'block';
		}
	}
	else if (NN4){
		if (document.layers[theObjectStr].display == 'block'){
			document.layers[theObjectStr].display = 'none';
		}
		else{
			document.layers[theObjectStr].display = 'block';
		}
	}
	else {
		if (document.all[theObjectStr].style.display == 'block'){
			document.all[theObjectStr].style.display = 'none';
		}
		else{
			document.all[theObjectStr].style.display = 'block';
		}
	}
}		

function showSection(theObjectStr){
        if (DOM){document.getElementById(theObjectStr).style.display = 'block';
        }else if (NN$){document.layers[theObjectStr].display = 'block';
        }else {document.all[theObjectStr].style.display = 'block';}
}
    
function hideSection(theObjectStr){
        if (DOM){document.getElementById(theObjectStr).style.display = 'none';
        }else if (NN4){document.layers[theObjectStr].display = 'none';
        }else {document.all[theObjectStr].style.display = 'none';}
}		



function qquote(theProduct){
        window.open("/products/quickquote/" + theProduct + ".htm","qqWindow","width=840,height=450,resizable=1,status=0")    
}



////////////////////////////////////////////////////////////////////
// Features and Benefits Functions
////////////////////////////////////////////////////////////////////

var currentBox = "";
var screenPreviewX = 312;
var screenPreviewY = 250;


function newXY(e){
	if (document.getElementById){
		var posx = 0;
		var posy = 0;
	
		if (!e) e = window.event;
		if (e.clientX || e.clientY){
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	
			if (currentBox == "screen"){
			
				
				if ((e.clientY + screenPreviewY + 20) < pageHeight()){
					topPosition = posy + 20;
				} else {
					topPosition = posy - screenPreviewY - 20;
				}
			
				if ((e.clientX + screenPreviewX + 15) < pageWidth()){
					leftPosition = posx;
				} else {
					leftPosition = posx - screenPreviewX + 10;
				}
				document.getElementById("infoBox").style.top  = topPosition + "px";
				document.getElementById("infoBox").style.left  = leftPosition + "px";
				
				
				
			}
			if (currentBox == "info"){
				document.getElementById("iconInfo").style.top  = (posy + 25 ) + "px";
				document.getElementById("iconInfo").style.left  = (posx) + "px";
				movieBoxY = posy - 300;
				if (movieBoxY < 50){ movieBoxY = 50;}
				if (document.getElementById("movieBox")){
				    document.getElementById("movieBox").style.top  = movieBoxY + "px";
				}
			}
			
			
		}
	}

}


function showBox(picRef){
	currentBox = "screen";
	document.onmousemove = newXY;
	if (document.getElementById){
			document.getElementById("infoImg").src = picRef;
			document.getElementById("infoBox").style.display = 'block';
	}
}


function hideBox(){
	document.onmousemove = "";
	currentBox = "";
	if (document.getElementById){
		document.getElementById("infoImg").src = "/images/structure/loading_small.gif";
		document.getElementById("infoBox").style.display = 'none';
		document.getElementById("infoBox").style.top  = "-500px";
		document.getElementById("infoBox").style.left  = "-500px";
	}
}



function showInfo(infoRef){
	currentBox = "info";
	document.onmousemove = newXY;
	if (document.getElementById){
			document.getElementById("iconInfo").innerHTML = document.getElementById(infoRef).innerHTML;
			document.getElementById("iconInfo").style.display = 'block';
	}
}

function hideInfo(){
	document.onmousemove = "";
	currentBox = "";
	if (document.getElementById){
		document.getElementById("iconInfo").style.display = 'none';
		document.getElementById("iconInfo").style.left  = "-500px";
	}
	
}

function showInfo2(){
    currentBox = "info";
	document.onmousemove = newXY;
	if (document.getElementById){
			document.getElementById("iconInfo").style.display = 'block';
	}
}

function showMovie(videoName,videoWidth,videoHeight){
	if (document.getElementById){
			document.getElementById("movieLoader").innerHTML = movieLoad(videoName,videoWidth,videoHeight);
			document.getElementById("movieBox").style.display = 'block';
	}
}

function hideMovie(){
	if (document.getElementById){
			document.getElementById("movieBox").style.display = 'none';
	}
}

function movieLoad(videoName,videoWidth,videoHeight){
	movieStr ='<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="' + videoWidth + '" height="' + videoHeight + '" id="demoMovie" align="middle">';
	movieStr = movieStr + '<param name="allowScriptAccess" value="sameDomain" />';
	movieStr = movieStr + '<param name="movie" value="' + videoName + '" /><param name="quality" value="high" /><param name="bgcolor" value="#dee9f5" /><embed src="' + videoName + '" quality="high" bgcolor="#dee9f5" width="' + videoWidth + '" height="' + videoHeight + '" name="demoMovie" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	movieStr = movieStr + '</object>';
	return movieStr;
}




/*
 +-------------------------------------------------------------------+
 |                       J S - M E N U   (v1.8)                      |
 |                                                                   |
 | Copyright Gerd Tentler                 www.gerd-tentler.de/tools  |
 | Created: Jul. 19, 2002                 Last modified: May 1, 2007 |
 +-------------------------------------------------------------------+
 | This program may be used and hosted free of charge by anyone for  |
 | personal purpose as long as this copyright notice remains intact. |
 |                                                                   |
 | Obtain permission before selling the code for this program or     |
 | hosting this software on a commercial website or redistributing   |
 | this software over the Internet or in any other medium. In all    |
 | cases copyright must remain intact.                               |
 +-------------------------------------------------------------------+

======================================================================================================
 This script was tested with the following systems and browsers:

 - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2
 - Mac OS X:   IE 5, Safari 1

 If you use another browser or system, this script may not work for you - sorry.
======================================================================================================
*/

var mObj = new Array();

function MENU(style) {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------

  this.style = style ? style : "left";      // menu style (top or left)
  this.floatMenu = false;                    // floating menu (true or false)*

  this.fadeInSpeed = 0;                    // fade-in speed (0 - 30; 0 = no fading)
  this.fadeOutSpeed = 0;                   // fade-out speed (0 - 30; 0 = no fading)
  this.fadeOutDelay = 0;                  // fade-out delay (1/1000 seconds)

  this.imgBlank = "/images/structure/blank.gif";              // path to blank image
  this.imgArrow = "/images/structure/arrow.gif";              // path to arrow image
  this.imgArrowWidth = 7;                   // arrow image width (pixels)

  // main menu configuration:

  this.mainTop = 0;                         // top position (pixels)
  this.mainLeft = 0;                        // left position (pixels)
  this.mainBGColor = "#406080";             // background color OR background image
  this.mainBorderWidth = 0;                // border width (pixels)
  this.mainArrows = false;                   // show sub menu arrows (true or false)
  this.mainOpacity = 100;                   // opacity (0 - 100)**

  this.mainItemWidth = 100;                 // item width (pixels)
  this.mainItemColor = "#dddddd";           // item color
  this.mainItemHilight = "#0099FF";         // item hilight color
  this.mainItemFont = "Arial, Helvetica";   // font family (CSS-spec)
  this.mainItemFontColor = "#676767";         // font color
  this.mainItemFontHilight = "white";     // font hilight color; NN4: not supported
  this.mainItemFontSize = 11;               // font size (pixels)
  this.mainItemAlign = "center";            // text align (left / center / right)
  this.mainItemPadding = 2;                 // text padding (pixels)
  this.mainItemSpacer = 0;                 // space between items (pixels)
  this.mainItem3D = 0;                      // 3D border (pixels); NN4: not supported

  // sub menu(s) configuration:

  this.subBGColor = "white";              // background color OR background image
  this.subBorderWidth = 1;                  // border width (pixels)
  this.subArrows = false;                    // show sub menu arrows (true or false)
  this.subOpacity = 100;                     // opacity (0 - 100)**
  this.subOffsetLeft = 10;                  // left offset (pixels)

  this.subItemWidth = 120;                  // item width (pixels)
  this.subItemColor = "#eeeeee";            // item color
  this.subItemHilight = "#0099FF";          // item hilight color
  this.subItemFont = "Arial, Helvetica";    // font family (CSS-spec)
  this.subItemFontColor = "#676767";        // font color
  this.subItemFontHilight = "white";      // font hilight color; NN4: not supported
  this.subItemFontSize = 11;                // font size (pixels)
  this.subItemAlign = "left";               // text align (left / center / right)
  this.subItemPadding = 5;                  // text padding (pixels)
  this.subItemSpacer = 1;                   // space between items (pixels)
  this.subItem3D = 0;                         // 3D border (pixels); NN4: not supported

// *  With Safari 1 (Mac OS X) performance was poor, i.e. floating speed was slow. With IE 5 (Mac OS X)
//    floating didn't work properly.
//
// ** Opacity was successfully tested only on Windows XP with IE 6, NN 7, Opera 9 and Firefox 1 + 2;
//    NN 7 showed different results, though. It should also work with Safari, version 1.2 or higher.

//----------------------------------------------------------------------------------------------------
// Functions
//----------------------------------------------------------------------------------------------------

  this.mOver = false;
  this.mNr = this.iv = this.timer = 0;
  this.sections = new Array();
  this.items = new Array();
  this.targetWindow = 0;

  this.entry = function(level, height, text, url, target, onClick) {
    var nr = this.items.length;
    var parent = nr - 1;
    this.items[nr] = new makeItem(level, height, text, url, target, onClick);
    if(parent >= 0) {
      if(level == this.items[parent].level + 1) this.items[nr].parent = parent;
      else if(level == this.items[parent].level) this.items[nr].parent = this.items[parent].parent;
      else if(level < this.items[parent].level) {
        for(var i = parent; i >= 0; i--) {
          if(this.items[i].level == level) {
            this.items[nr].parent = this.items[i].parent;
            break;
          }
        }
      }
    }
  }

  this.getObj = function(id, cont) {
    var obj;
    if(DOM) obj = document.getElementById(id).style;
    else if(IE4) obj = document.all[id].style;
    else if(NN4) obj = cont ? document.layers[cont].document.layers[id] : document.layers[id];
    return obj;
  }

  this.getScrTop = function() {
    var scrTop = 0;
    if(document.documentElement && document.documentElement.scrollTop)
      scrTop = document.documentElement.scrollTop;
    else if(document.body && document.body.scrollTop)
      scrTop = document.body.scrollTop;
    else if(window.pageYOffset) scrTop = window.pageYOffset;
    return scrTop;
  }

  this.setOpacity = function(nr, opacity) {
    if(!NN4) {
      var obj = this.getObj('section' + this.mNr + '_' + nr);
      if(obj) {
        obj.opacity = opacity / 100;
        obj.MozOpacity = opacity / 100;
        obj.KhtmlOpacity = opacity / 100;
        obj.filter = 'alpha(opacity=' + opacity + ')';
      }
    }
  }

  this.fadeIn = function(nr) {
    if(this.sections[nr].active) {
      var maxOp = (this.items[this.sections[nr].nr].level < 2) ? this.mainOpacity : this.subOpacity;
      if(this.fadeInSpeed && this.sections[nr].opacity < maxOp) {
        this.sections[nr].opacity += this.fadeInSpeed;
        if(this.sections[nr].opacity > maxOp) this.sections[nr].opacity = maxOp;
        this.setOpacity(nr, this.sections[nr].opacity);
        if(this.sections[nr].timer) clearTimeout(this.sections[nr].timer);
        this.sections[nr].timer = setTimeout('mObj[' + this.mNr + '].fadeIn(' + nr + ')', 1);
      }
      else {
        this.sections[nr].opacity = maxOp;
        this.setOpacity(nr, maxOp);
      }
    }
  }

  this.fadeOut = function(nr) {
    if(this.fadeOutSpeed && this.sections[nr].opacity > 0) {
      this.sections[nr].opacity -= this.fadeOutSpeed;
      if(this.sections[nr].opacity < 0) this.sections[nr].opacity = 0;
      this.setOpacity(nr, this.sections[nr].opacity);
      if(this.sections[nr].timer) clearTimeout(this.sections[nr].timer);
      this.sections[nr].timer = setTimeout('mObj[' + this.mNr + '].fadeOut(' + nr + ')', 1);
    }
    else {
      var obj = this.getObj('section' + this.mNr + '_' + nr);
      obj.visibility = NN4 ? 'hide' : 'hidden';
      this.sections[nr].opacity = 0;
    }
  }

  this.showMenu = function(nr) {
    var obj = this.getObj('section' + this.mNr + '_' + nr);
    if(!this.sections[nr].active) {
      if(this.floatMenu) this.sections[nr].y = this.getScrTop() + this.sections[nr].topY;
      if(IE4) obj.pixelTop = this.sections[nr].y;
      else obj.top = this.sections[nr].y + (DOM ? 'px' : '');
      obj.visibility = NN4 ? 'show' : 'visible';
      this.sections[nr].active = true;
      this.fadeIn(nr);
    }
  }

  this.hideMenu = function(nr) {
    var obj = this.getObj('section' + this.mNr + '_' + nr);
    if(this.sections[nr].active) {
      this.sections[nr].active = false;
      this.fadeOut(nr);
    }
  }

  this.hilight = function(section, item, bgColor, fontColor) {
    var obj = this.getObj('item' + this.mNr + '_' + item, 'section' + this.mNr + '_' + section);
    if(NN4) obj.bgColor = bgColor;
    else obj.backgroundColor = bgColor;
    if(!NN4) {
      obj = this.getObj('text' + this.mNr + '_' + item);
      obj.color = fontColor;
    }
    if(bgColor == this.subItemColor || bgColor == this.mainItemColor) this.mOver = false;
    else this.mOver = true;
  }

  this.getMenu = function(item, section) {
    if(this.sections[section].active) {
      for(var i = section+1; i < this.sections.length; i++) {
        if(this.sections[i].nr == item) {
          if(!this.sections[i].active) this.showMenu(i);
        }
        else if(this.sections[i].active) this.hideMenu(i);
      }
    }
  }

  this.hideSubs = function(start) {
    if(!this.mOver) for(var i = start; i < this.sections.length; i++) {
      if(this.sections[i].active) this.hideMenu(i);
    }
    this.timer = 0;
  }

  this.jumpURL = function(item) {
    if(this.items[item].url) {
      if(this.items[item].target) {
        if(this.items[item].target.indexOf('parent.') == -1 && this.items[item].target.indexOf('top.') == -1) {
          if(this.targetWindow && !this.targetWindow.closed) this.targetWindow.location.href = this.items[item].url;
          else this.targetWindow = window.open(this.items[item].url, 'targetWindow');
          this.targetWindow.focus();
        }
        else eval(this.items[item].target + '.location.href = "' + this.items[item].url + '"');
      }
      else document.location.href = this.items[item].url;
    }
  }

  this.checkIt = function() {
    var active = false;
    var i;
    if(this.floatMenu) for(i = 0; i < this.sections.length; i++) {
      if(this.sections[i].active) this.floatIt(i, this.sections[i].topY);
    }
    if(!this.mOver && !this.timer) {
      for(i = 0; i < this.sections.length && !active; i++) {
        if(this.sections[i].active) active = true;
      }
      if(active) {
        if(this.fadeOutDelay) this.timer = setTimeout('mObj[' + this.mNr + '].hideSubs(1)', this.fadeOutDelay);
        else this.hideSubs(1);
      }
    }
  }

  this.floatIt = function(nr, topY) {
    var obj = this.getObj('section' + this.mNr + '_' + nr);
    if(obj.visibility == 'visible' || obj.visibility == 'show') {
      var scrTop = this.getScrTop() + topY;
      var elmTop = IE4 ? obj.pixelTop : parseInt(obj.top);
      if(elmTop != scrTop) this.smoothIt(obj, nr, scrTop);
    }
  }

  this.smoothIt = function(obj, nr, scrTop) {
    if(scrTop != this.sections[nr].y) {
      var percent = .1 * (scrTop - this.sections[nr].y);
      if(percent > 0) percent = Math.ceil(percent);
      else percent = Math.floor(percent);
      this.sections[nr].y += percent;
      if(IE4) obj.pixelTop = this.sections[nr].y;
      else if(NN4 || DOM) obj.top = this.sections[nr].y + (DOM ? 'px' : '');
    }
  }

  this.buildItems = function(parent, section) {
    var arrows, link, img, color, itemColor, itemHilight, itemAlign, left;
    var width, height, border, spacer, itemPadding, item3D, topY, clsItem, j;

    for(var i = cnt = 0; i < this.items.length; i++) {
      if(this.items[i].parent == parent) {
        if(this.items[i].level < 2) {
          border = this.mainBorderWidth;
          color = this.mainBGColor;
          spacer = this.mainItemSpacer;
          arrows = this.mainArrows;
          itemColor = this.mainItemColor;
          itemFontColor = this.mainItemFontColor;
          itemHilight = this.mainItemHilight;
          itemFontHilight = this.mainItemFontHilight;
          itemAlign = this.mainItemAlign;
          itemPadding = this.mainItemPadding;
          item3D = this.mainItem3D;
          clsItem = 'clsMainItem' + this.mNr;
          width = this.mainItemWidth + itemPadding*2;
          if(this.style == 'top') left = border + (width + item3D*2 + spacer) * cnt++;
          else left = border;
        }
        else {
          border = this.subBorderWidth;
          color = this.subBGColor;
          spacer = this.subItemSpacer;
          arrows = this.subArrows;
          itemColor = this.subItemColor;
          itemFontColor = this.subItemFontColor;
          itemHilight = this.subItemHilight;
          itemFontHilight = this.subItemFontHilight;
          itemAlign = this.subItemAlign;
          itemPadding = this.subItemPadding;
          item3D = this.subItem3D;
          clsItem = 'clsSubItem' + this.mNr;
          width = this.subItemWidth + itemPadding*2;
          left = border;
        }
        height = this.items[i].height + itemPadding*2;

        if(!topY) topY = border;
        link = 'javascript:mObj[' + this.mNr + '].jumpURL(' + i + ')';
        if(arrows && i+1 < this.items.length && this.items[i+1].level > this.items[i].level) img = this.imgArrow;
        else img = '';

        for(j = 0; j < this.sections.length; j++) {
          if(this.sections[j].nr == i+1) {
            this.sections[j].topY = this.sections[section].topY + topY;
            this.sections[j].y = this.sections[j].topY;
          }
        }

        if(IE4 || DOM) document.write('<div id="item' + this.mNr + '_' + i + '" style="position:absolute' +
                                      '; top:' + topY + 'px' +
                                      '; left:' + left + 'px' +
                                      '; width:' + width + 'px' +
                                      '; height:' + height + 'px' +
                                      (itemColor ? '; background-color:' + itemColor : '') +
                                      (item3D ? '; border:' + item3D + 'px outset white' : '') +
                                      '; z-index:11">');
        else if(NN4) document.write('<layer id="item' + this.mNr + '_' + i + '"' +
                                    ' top=' + topY +
                                    ' left=' + left +
                                    ' width=' + width +
                                    ' height=' + height +
                                    (itemColor ? ' bgcolor=' + itemColor : '') +
                                    ' z-index=11>');
        document.write('<table border=0 cellspacing=0 cellpadding=' + itemPadding +
                       ' width=' + width + ' height=' + height + '><tr>' +
                       '<td id="text' + this.mNr + '_' + i + '" class="' + clsItem + '" align="' + itemAlign + '">' +
                       this.items[i].text + '</td>' +
                       (img ? '<td width=' + this.imgArrowWidth + ' align=right><img src="' + img + '" width=' + this.imgArrowWidth + '></td>' : '') +
                       '</tr></table>');
        if(IE4 || DOM) document.write('</div>');
        else if(NN4) document.write('</layer>');

        if(IE4 || DOM) document.write('<div style="position:absolute' +
                                      '; top:' + topY + 'px' +
                                      '; left:' + left + 'px' +
                                      '; z-index:12">');
        else if(NN4) document.write('<layer' +
                                    ' top=' + topY +
                                    ' left=' + left +
                                    ' z-index=12>');
        document.write('<a href="' + link + '" ' +
                       'onMouseOver="mObj[' + this.mNr + '].hilight(' + section + ', ' + i + ', \'' + itemHilight + '\', \'' + itemFontHilight + '\'); ' +
                       'mObj[' + this.mNr + '].getMenu(' + (i+1) + ', ' + section + '); ' +
                       'window.status=\'' + this.items[i].url + '\'; return true" ' +
                       'onMouseOut="mObj[' + this.mNr + '].hilight(' + section + ', ' + i + ', \'' + itemColor + '\', \'' + itemFontColor + '\'); ' +
                       'window.status=\'\'" ' + (this.items[i].onClick ? 'onClick="' + this.items[i].onClick + '" ' : '') +
                       'onFocus="if(this.blur) this.blur()">' +
                       '<img src="' + this.imgBlank + '" border=0 width=' + (width + item3D*2) + ' height=' + (height + item3D*2) + '></a>');
        if(IE4 || DOM) document.write('</div>');
        else if(NN4) document.write('</layer>');

        if(this.items[i].level > 1 || this.style != 'top') topY += height + item3D*2 + spacer;
      }
    }
  }

  this.buildSections = function() {
    document.write('<style> ' +
                   '.clsMainItem' + this.mNr + ' { color:' + this.mainItemFontColor +
                   '; font-family:' + this.mainItemFont +
                   '; font-size:' + this.mainItemFontSize + 'px; } ' +
                   '.clsSubItem' + this.mNr + ' { color:' + this.subItemFontColor +
                   '; font-family:' + this.subItemFont +
                   '; font-size:' + this.subItemFontSize + 'px; } ' +
                   '</style>');

    var width, border, color, itemPadding, item3D, spacer, left, height, level, section, cnt, j;
    var mainHeight = 0;
    var bgImg = '';

    for(var i = 0; i < this.items.length; i++) {
      if(!i || this.items[i].level > this.items[i-1].level) {
        this.sections[this.sections.length] = new makeSection(i, this.items[i].level, this.mainTop);
      }
    }

    for(i = cnt = 0; i < this.sections.length; i++) {
      section = this.sections[i].nr;
      level = this.sections[i].level;
      if(level < 2) {
        border = this.mainBorderWidth;
        color = this.mainBGColor;
        itemPadding = this.mainItemPadding;
        item3D = this.mainItem3D;
        spacer = this.mainItemSpacer;
        width = (this.style == 'top') ? 0 : this.mainItemWidth + border*2 + itemPadding*2 + item3D*2;
        left = this.mainLeft;
      }
      else {
        border = this.subBorderWidth;
        color = this.subBGColor;
        itemPadding = this.subItemPadding;
        item3D = this.subItem3D;
        spacer = this.subItemSpacer;
        width = this.subItemWidth + border*2 + itemPadding*2 + item3D*2;
        if(this.style == 'top') {
          if(level == 2) for(j = cnt = 0; j < section; j++) {
            if(this.items[j].level == 1) cnt++;
          }
          left = this.mainLeft + this.mainBorderWidth + (this.mainItemWidth + this.mainItemPadding*2 + this.mainItem3D*2 + this.mainItemSpacer) * (cnt-1);
          left += (level-2) * (width - this.subOffsetLeft);
        }
        else left = this.mainLeft + this.mainItemWidth - this.subOffsetLeft + ((this.mainBorderWidth+this.mainItemPadding+this.mainItem3D)*2) + (level-2) * (width-this.subOffsetLeft);
      }
      height = 0;

      for(j = section; j < this.items.length; j++) {
        if(this.items[j].parent == this.items[section].parent) {
          if(level < 2 && this.style == 'top') {
            width += this.mainItemWidth + itemPadding*2 + item3D*2 + spacer;
            if(this.items[j].height > height) height = mainHeight = this.items[j].height;
          }
          else height += this.items[j].height + itemPadding*2 + item3D*2 + spacer;
        }
      }
      if(this.style == 'top') {
        if(level < 2) {
          width += border*2 - spacer;
          height += itemPadding*2 + item3D*2 + spacer;
          mainHeight += border + itemPadding*2 + item3D*2;
        }
        else if(level == 2) {
          this.sections[i].topY += mainHeight;
          this.sections[i].y = this.sections[i].topY;
        }
      }
      height += border*2 - spacer;

      if(color.search(/\.(jpg|jpeg|jpe|gif|png)$/i) != -1) {
        bgImg = color;
        color = '';
      }
      else bgImg = this.imgBlank;

      this.sections[i].width = width;
      this.sections[i].height = height;
      
      // added by AnthonyW, for 1024 support
      ////////////////////////////////////////
      //if (screen.width < 1200 && document.getElementById){
      //  left=left-150;
      //}
      // Finish addition

      if(IE4 || DOM) document.write('<div id="section' + this.mNr + '_' + i + '" style="position:absolute' +
                                    '; top:' + this.sections[i].topY + 'px' +
                                    '; left:' + left + 'px' +
                                    '; width:' + width + 'px' +
                                    '; height:' + height + 'px' +
                                    (color ? '; background-color:' + color : '') +
                                    '; z-index:1' + i +
                                    '; visibility:hidden">');
      else if(NN4) document.write('<layer id="section' + this.mNr + '_' + i + '"' +
                                  ' top=' + this.sections[i].topY +
                                  ' left=' + left +
                                  ' width=' + width +
                                  ' height=' + height +
                                  (color ? ' bgcolor=' + color : '') +
                                  ' z-index=1' + i +
                                  ' visibility="hide">');

      document.write('<a href="#" onMouseOver="mObj[' + this.mNr + '].mOver=true" onMouseOut="mObj[' + this.mNr + '].mOver=false">' +
                     '<img src="' + bgImg + '" border=0 width=' + this.sections[i].width +
                     ' height=' + this.sections[i].height + '></a>');

      this.buildItems(section-1, i);

      if(IE4 || DOM) document.write('</div>');
      else if(NN4) document.write('</layer>');

      if(this.mainOpacity && level < 2) this.setOpacity(i, this.mainOpacity);
      else if(this.subOpacity && level > 1) this.setOpacity(i, this.subOpacity);
    }
  }

  this.create = function() {
    this.mNr = mObj.length;
    if(mObj[this.mNr] = this) {
      this.buildSections();
      this.showMenu(0);
      if(this.iv) clearInterval(this.iv);
      this.iv = setInterval('mObj[' + this.mNr + '].checkIt()', 1);
    }
    else alert("Could not create menu!");
  }

  //-------------------------------------------------------------------------------------
  // Arguments: position level 1, [position level 2], ... [position level n]
  // Example:   jumpTo(1, 3, 2, 1) ==> this jumps to menu item 1.3.2.1
  // Note:      does not work with NN 4 (who knows why?)
  //
  this.jumpTo = function() {
    var pos, aktPos;
    var item = 0;
    var level = 1;
    if(!arguments) var arguments = this.jumpTo.arguments;
    for(i = 0; i < arguments.length; i++, level++) {
      pos = arguments[i];
      for(aktPos = 0; item < this.items.length && aktPos < pos; item++) {
        if(this.items[item].level == level) aktPos++;
      }
    }
    if(item) {
      item--;
      if(this.items[item].onClick) eval(this.items[item].onClick);
      this.jumpURL(item);
    }
  }
  //-------------------------------------------------------------------------------------
}

function makeItem(level, height, text, url, target, onClick) {
  this.level = level;
  this.height = height;
  this.text = text;
  this.url = url;
  this.target = target;
  this.onClick = onClick;
  this.parent = -1;
}

function makeSection(nr, level, topY) {
  this.nr = nr;
  this.level = level;
  this.topY = topY;
  this.active = false;
  this.y = topY;
  this.width = 0;
  this.height = 0;
  this.timer = 0;
  this.opacity = 0;
}

//----------------------------------------------------------------------------------------------------
