	Event.observe(window, "load", function() {
		$A($("header-content").getElementsByTagName("img")).each(function(el) {
			Event.observe(el, "mouseover", function(s) {
				el.src = el.src.sub("-up","-over");
			});
			Event.observe(el, "mouseout", function(s) {
				el.src = el.src.sub("-over","-up");
			});
			
			//compare page name and image name
			var pageName = document.location.toString().substring((document.location.toString().lastIndexOf("http://digitalcopy.warnerbros.com/")+1),document.location.toString().lastIndexOf(".html"));
			if(pageName.indexOf("http") == 0) pageName = "index";
			if(el.src.indexOf(pageName+"-") != -1) {
				el.src = el.src.sub("-up","-sel");
			}
		});
		
		$A($("footer-content").getElementsByTagName("img")).each(function(el) {
			Event.observe(el, "mouseover", function(s) {
				el.src = el.src.sub("-up","-over");
			});
			Event.observe(el, "mouseout", function(s) {
				el.src = el.src.sub("-over","-up");
			});
		});

		$('searchTerm').onfocus = function() {
			// if already cleared, do nothing
			if (this._cleared) return

			// when this code is executed, "this" keyword will in fact be the field itself
			this.clear()
			this._cleared = true
		}		
	
		$('searchTerm').onkeypress = function(e) {
			// fetch event object
			var keynum;

			if(window.event) // IE
			{
			  	keynum = window.event.keyCode;
			}
			else if(e.which) // Netscape/Firefox/Opera
			{
				keynum = e.which;
			}
/*
			if (keynum == Event.KEY_RETURN) {	// enter key pressed
				doSearch();
			}
*/					

		}	
		
		$('search-button').observe('click', doSearch);
		
				
//		$('searchForm').onsubmit = function(e) {
//			doSearch();
//		}
		
		

	});
	
	
	// this function replaces the method of submitting the form. it's a workaround with the bug in Safari (Mac)
	// that includes the coordinates of the mouse-click in the query when images are used as submit buttons
	function doSearch() {
		var query = $('searchTerm').getValue();  
		location.href = "/?page=search&q=" + query;
		return false;
		
	}


	function showHide(lyrId, elem) {
		for (var i=0; i<elem.length; i++){
			var lyrObj = (document.layers)?d["device"+i]:document.all?document.all["device"+i].style:document.getElementById("device"+i).style;
			lyrObj.display = "none";
		}
		/*if(lyrId == "device"+(elem.length-1)){
			var lyrObj = (document.layers)?d["device0"]:document.all?document.all["device0"].style:document.getElementById("device0").style;
			lyrObj.display = "inline";
		
		} else {*/
			var lyrObj = (document.layers)?d[lyrId]:document.all?document.all[lyrId].style:document.getElementById(lyrId).style;
			lyrObj.display = "inline";
		//}
	}

	function selectDevice(elem, option) {
		showHide("device"+option, elem);
	}
	
    
    function checkMail(pMail)
    {
	    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    if (filter.test(pMail)) return true;
	    else return false;
    }
	function validate() {
		var f = document.supportForm;
		if(f.txbDiscTitle.selectedIndex == 0){
			alert("Please select a DVD Title");
			return false;
		} else if(!CheckInput()){
			alert("Please enter the Authorization Code.");
			return false;
		} else if(f.txbEmail.value == ""){
			alert("Please enter your Email Address.");
			return false;
		} else if(!checkMail(f.txbEmail.value)){
			alert("Please enter a valid Email Address.");
			return false;
		} else if(f.txbOS.selectedIndex == 0){
			alert("Please select a Operating System");
			return false;
		} else if(f.txbWMPVersion.selectedIndex == 0){
			alert("Please select a Windows Media Player");
			return false;
		} else if(f.txbProblemType.selectedIndex == 0){
			alert("Please select a Support Request Type");
			return false;
		} else if(f.txbDescription.value == ""){
			alert("Please enter your Comments or Questions.");
			return false;
		} else {
			var addr = f.txbEmail.value;
			var atsign = addr.indexOf("@");
			var domainname = addr.substring(atsign+1);
			if (atsign > 0 && domainname.indexOf(".") > 0) {
				return true;
			} else {
				alert("Please enter a valid Email Address.");
				return false;
			}
		}
	}
	function navigateNext(currentId, nextId)
    {
         var msg = document.getElementById(currentId).value;
         msg = msg.toUpperCase();
         document.getElementById(currentId).value = msg;
         if ((document.getElementById(currentId).value.length == 5) && (nextId != null))
             document.getElementById(nextId).focus();
             
    }

    function CheckInput()
    {
        var nTotalLength = document.getElementById("auth1").value + 
                           document.getElementById("auth2").value + 
                           document.getElementById("auth3").value + 
                           document.getElementById("auth4").value +
                           document.getElementById("auth5").value;
         switch(nTotalLength.length)
         {
            case 5:
            {
                navigateNext("auth1", "auth2");
                break;
            }
            case 10:
            {
                navigateNext("auth2", "auth3");
                break;
            }
            case 15:
            {
                navigateNext("auth3", "auth4");
                break;
            }
            case 20:
            {
                navigateNext("auth4", "auth5");
                break;
            }
            case 25:
            {
                navigateNext("auth5", null);
                break;
            }
            
                
         }
         /// returns whether user has entered 25 characters
         return (nTotalLength.length == 25);
    }