Event.observe(window, 'load',
	function() { 
		addRollovers();
	}
);

if(window.attachEvent)
	window.attachEvent("onload",setListeners);

function addRollovers() {

//	var arVersion = navigator.appVersion.split("MSIE")
//	var version = parseFloat(arVersion[1])
//	var transparentImage = "/_images/transparent.gif";

	var images;
	var rolloverSRC = "";
	if(document.getElementById)
		images = document.getElementsByTagName('img');
	else if(document.all)
		images = document.all.tags('img');
	else return
	for (var i=0; i<images.length; i++) {
		var img = images[i];

//		if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
//			var imgName = img.src.toUpperCase();
//			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
//				var imgFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "',sizingMethod='scale')";
//				img.src = transparentImage;
//				img.runtimeStyle.filter = imgFilter;
//				i = i-1
//			}
//		}

		if (img.className == 'rollover'){
			img.onmouseover = function() {
				var imgOriginSrc = this.getAttribute('src');
				this.setAttribute('src',imgOriginSrc.replace('_out',"_over"));
			}
			img.onmouseout = function() {
				var imgOriginSrc = this.getAttribute('src');
				this.setAttribute('src',imgOriginSrc.replace('_over',"_out"))
			}
		}
	}
	if(document.getElementById)
		inputs = document.getElementsByTagName('input');
	else if(document.all)
		inputs = document.all.tags('input');
	else return
	for (var i=0; i<inputs.length; i++) {
		var input = inputs[i];
		if (input.className == 'rollover'){
			input.onmouseover = function() {
				var imgOriginSrc = this.getAttribute('src');
				this.setAttribute('src',imgOriginSrc.replace('_out',"_over"));
			}
			input.onmouseout = function() {
				var imgOriginSrc = this.getAttribute('src');
				this.setAttribute('src',imgOriginSrc.replace('_over',"_out"))
			}
		}
	}
}

function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
		inputList[i].attachEvent("onpropertychange",restoreStyles);
		inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
		selectList[i].attachEvent("onpropertychange",restoreStyles);
		selectList[i].style.backgroundColor = "";
	}
}

function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "#a0d0ff"){
		event.srcElement.style.backgroundColor = "#B2846E"; /* color of choice for AutoFill */
		// document.all['googleblurb'].style.display = "block";
	}
}

function cleanValue(obj) {
	switch (obj.value) {
		case "email address":
		case "******":
		case "Enter your search terms":
			obj.value='';
			break;
		default: break;
	}
}

var viewWindow;

function repurposeWindow(width, height, xLeft, yTop) {
	viewWindow.moveTo(xLeft, yTop);
	if (viewWindow.resizeTo || navigator.userAgent.indexOf('Gecko') == -1) {
			viewWindow.resizeTo(width,height);
		} else { 
			viewWindow.outerWidth=width;
			viewWindow.outerHeight=height;
		}
	viewWindow.moveTo(xLeft, yTop);//This must be done twice so browser doesn't override setting for window being off screen.
	setTimeout('viewWindow.focus();', 100);
}

function openWindow(fileName, width, height) {
	if (!height) height = 500;
	if (!width) width = 310;
	xLeft = (screen.width) ? (screen.width-width)/2 : 0;
	yTop = (screen.height) ? (screen.height-height)/2 : 0;
	if (window.locationbar) height += 50;
	if (viewWindow && !viewWindow.closed) {
		viewWindow.location = fileName;
	} else {
		viewWindow = 'window.open("'+fileName+'", "viewWindow", "height='+height+',width='+width+',' +
		'status=no,scrollbars=1,resizable=no,toolbar=no,copyhistory=no,location=no,left='+xLeft+',top='+yTop+',screenX='+xLeft+',screenY='+yTop+'")';
		viewWindow = eval(viewWindow);
	}
	repurposeWindow(width, height, xLeft, yTop);
}

function feedback() {
	openWindow("/msgcenter/feedback.aspx",500,250);	
}

function confirmContinue() {
	var success	= confirm("Are you sure?");
	return success;
}

function recommendCustomURL(strIn) {
	strIn = strIn.replace(/[^a-zA-Z0-9]+/g,'');
	$("tb_CustomURL").value = strIn;
}

function doToggle(element) {
	var ie = (navigator.userAgent.indexOf("MSIE") != -1);	if (ie) {		Effect.toggle(element, 'appear');	} else {		Effect.toggle(element, 'slide');	}}function toggleFilmPlayer(divid, originalWidth, originalHeight){

	flashDiv = document.getElementById(divid);
	var win = window;
	var windowWidth = document.body.clientWidth;
	var windowHeight = document.body.clientHeight;
	windowWidth.toString();
	windowHeight.toString();

	if (flashDiv.style.zIndex == "3000") {
		flashDiv.style.zIndex = "";
		flashDiv.style.position = "";
		flashDiv.style.top = "";
		flashDiv.style.left = "";
		flashDiv.style.width = originalWidth + "px";
		flashDiv.style.height = originalHeight + "px";
	} else {
		flashDiv.style.zIndex = "3000";
		flashDiv.style.position = "fixed";
		flashDiv.style.top = "0px";
		flashDiv.style.left = "0px";
		flashDiv.style.width = windowWidth + "px";
		flashDiv.style.height = windowHeight + "px";
	}
}
