// JavaScript Document

	//*************************************************************************************
	// FUNCTIONS TO LOAD THE POPUPS (FROM A REGULAR BROWSER WINDOW)
	//*************************************************************************************
	function doTileVideoPopUp() {
		doMediaCenterPopUp('/flash/mediaCenter.cfm?regPopUp=TRUE&swf=tileVideo', 'tileVideo', '600', '400');
	}
	function doMagnifiqueVideoPopUp() {
		//doMediaCenterPopUp('/flash/mediaCenter.cfm?regPopUp=TRUE&swf=magnifiqueVideo', 'CMInstall', '400', '300');
		doMediaCenterPopUp('http://s3.amazonaws.com/static.ceilume.com/flash/CMInstall.html?regPopUp=TRUE', 'magnifiqueVideo', '400', '300');
	}
	function doGridStripVideoPopUp() {
		doMediaCenterPopUp('http://s3.amazonaws.com/static.ceilume.com/flash/cmDecoInstall.html?regPopUp=TRUE', 'gridStripVideo', '400', '300');
	}
	function doEdgeTrimVideoPopUp() {
		doMediaCenterPopUp('/flash/mediaCenter.cfm?regPopUp=TRUE&swf=edgeTrimVideo', 'edgeTrimVideo', '445', '415');
	}
	function doProfileVideoPopUp() {
		doMediaCenterPopUp('/flash/mediaCenter.cfm?regPopUp=TRUE&swf=profileVideo', 'profileVideo', '445', '415');
	}
	
	function doMediaCenterPopUp(popPage, name, width, height) {
		//alert('inside popUp: ' + popPage);
		moveWidth = (screen.width - width)/2;
		moveHeight = (screen.height - height)/2;
	
		properties = 'toolbars=0, scrollbars=no, location=0, statusbars=0, statusbar=no, menubars=0, resizable=1, width=' + width + ', height=' + height + ',left=' + moveWidth + ', top = ' + moveHeight + '';
		mediaCenterPopUpWindow=window.open(popPage, name, properties);
	}

	//*************************************************************************************
	//  E-MAIL/REDIRECT FUNCTIONS THAT ARE USED INSIDE OF THE MEDIA CENTER POPUPS
	//*************************************************************************************
	// call page to send e-mail
	function sendEmail(myUrl) 
	{
		if(window.XMLHttpRequest) {
			try {
				xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
			}
			catch(e) {
				alert('We\'re sorry, but your browser was unable to handle this request.\nPlease e-mail your question or comment to us <a href="/aboutus/contactus.htm" target="newemail">by clicking here</a>.\n\nTo avoid this type of problem in the future, please consider\nswitching to the Mozilla Firefox browser (www.getfirefox.com).');
				return false;
			}
		} else if(window.ActiveXObject) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer
			}
			catch(e) { 
				try {
    				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); // IE for Mac
				}
				catch(e) {
					alert('We\'re sorry, but your browser was unable to handle this request.\nPlease e-mail your question or comment to us <a href="/aboutus/contactus.htm" target="newemail">by clicking here</a>.\n\nTo avoid this type of problem in the future, please consider\nswitching to the Mozilla Firefox browser (www.getfirefox.com).');
					return false;
				}
   			}
		} else {
			alert('We\'re sorry, but your browser was unable to handle this request.\nPlease e-mail your question or comment to us <a href="/aboutus/contactus.htm" target="newemail">by clicking here</a>.\n\nTo avoid this type of problem in the future, please consider\nswitching to the Mozilla Firefox browser (www.getfirefox.com).');
			return false;
		}
		xmlhttp.open("GET", myUrl, true); // Open a connection. Replace GET with HEAD in order to do a HEAD request.
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState == 4) { // Wait until everything is fetched!
				//alert(xmlhttp.getAllResponseHeaders()); // Prints all teh response headers to the screen to see if it was successful
				// xmlhttp.responseText contains the contents of the response.
			}
		}
		xmlhttp.send(null); // send() is used to initiate the transfer. No actual data have to be sent in this case.
	}
	
	// Prepare to send e-mail
	function doSendEmail(email, question) 
	{
		baseUrl = "mail.cfm";
		//alert("Email: " + unescape(email));
		//alert("Message: " + unescape(question));
		fullUrl = baseUrl + "?email=" + email + "&message=" + question;
		//alert("URL: " + fullUrl);
		sendEmail(fullUrl);
	}
	
	// Page redirects for parent and self
	function doJump(jumpUrl) {
		// Check if the page is a popup window
		var strHref = window.location.href;
		strHref = strHref.toUpperCase();
		if (strHref.indexOf("REGPOPUP") != -1) {
			// Popup window, reload in parent
			if (jumpUrl == 'samplepage') {
				opener.location.href= '/ceilingtile_browsesamples.cfm';
			}
			else if (jumpUrl == 'tilepage') {
				opener.location.href= '/ceilingtile_browseall.cfm';
			}
			self.close();
		}
		else {
			// Main window, reload in self
			if (jumpUrl == 'samplepage') {
				self.location.href= '/ceilingtile_browsesamples.cfm';
			}
			else if (jumpUrl == 'tilepage') {
				self.location.href= '/ceilingtile_browseall.cfm';
			}
		}
	}


	//*************************************************************************************
	//  LOAD/RESIZE FUNCTIONS THAT ARE USED INSIDE OF THE MEDIA CENTER POPUPS
	//*************************************************************************************
	function doTileVideo()
	{
		loadMovie('tileVideo');
	}
	function doMagnifiqueVideo()
	{
		loadMovie('magnifiqueVideo');
	}
	function doGridStripVideo()
	{
		loadMovie('gridStripVideo');
	}
	function doEdgetrimVideo()
	{
		loadMovie('edgeTrimVideo');
	}
	function doProfileVideo()
	{
		loadMovie('profileVideo');
	}
	
	function resizeWindow(swfWidth, swfHeight) {
		ieWidthOffset = 12;
		ieHeightOffset = 38 + 23; // Extra 23 is for status bar
		nsWidthOffset = 8;
		
		leftOffset = (screen.width - swfWidth)/2;
		topOffset = (screen.height - swfHeight)/2;
		
		if (ie) {
			//alert ('using IE: ' + brow);
			window.moveTo(leftOffset, topOffset);
			window.resizeTo(swfWidth+ieWidthOffset, swfHeight+ieHeightOffset);
		}
		else {
			//alert ('Non IE: ' + brow); 
			window.moveTo(leftOffset, topOffset);
			window.innerHeight = swfHeight;
			window.outerWidth = swfWidth + nsWidthOffset;
		}		
	}
	
	function loadMovie(swfName)
	{
		// Set to S3 host to load from there, or set to empty string to load locally
		// Removed allowLocalScript references on 2/14/07
		//swfHost = "";
		swfHost = "https://s3.amazonaws.com/static.ceilume.com";
		
		if (swfName == 'tileVideo')
		{
			var tileCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="600" height="400" id="TileVideo" align="middle"><param name="movie" value="' + swfHost + '/flash/tileVideo.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#3a434c" /><embed src="' + swfHost + '/flash/tileVideo.swf" quality="high" bgcolor="#3a434c" width="600" height="400" name="TileVideo" align="middle" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
		
			//window.resizeTo(600 + 10, 400 + 50);
			resizeWindow(600, 400);
			document.bgcolor = "#3a434c";
			document.getElementById("showSWF").innerHTML = tileCode;
		}
		else if (swfName == 'magnifiqueVideo')
		{
			var tileCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="300" id="CMInstall" align="middle"><param name="movie" value="' + swfHost + '/flash/CMInstall.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="' + swfHost + '/flash/CMInstall.swf" quality="high" bgcolor="#ffffff" width="400" height="300" name="CMInstall" align="middle" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
		
			//window.resizeTo(400 + 10, 300 + 50);
			resizeWindow(400, 300);
			document.bgcolor = "#3a434c";
			document.getElementById("showSWF").innerHTML = tileCode;
		}
		else if (swfName == 'gridStripVideo')
		{
			var tileCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="300" id="cmDecoInstall" align="middle"><param name="movie" value="' + swfHost + '/flash/cmDecoInstall.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="' + swfHost + '/flash/cmDecoInstall.swf" quality="high" bgcolor="#ffffff" width="400" height="300" name="cmDecoInstall" align="middle" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
		
			//window.resizeTo(400 + 10, 300 + 50);
			resizeWindow(400, 300);
			document.bgcolor = "#3a434c";
			document.getElementById("showSWF").innerHTML = tileCode;
		}
		else if (swfName == 'edgeTrimVideo')
		{
			var edgeTrimCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="445" height="415" id="edgetrimVideo" align="middle"><param name="movie" value="' + swfHost + '/flash/edgetrimVideo.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#373838" /><embed src="' + swfHost + '/flash/edgetrimVideo.swf" quality="high" bgcolor="#373838" width="445" height="415" name="edgetrimVideo" align="middle" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
		
			//window.resizeTo(445 + 10, 415 + 50);
			resizeWindow(445, 415);
			document.bgcolor = "#373838";
			document.getElementById("showSWF").innerHTML = edgeTrimCode;
		}
		else if (swfName == 'profileVideo')
		{
			var profileCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="445" height="415" id="profilemountVideo" align="middle"><param name="movie" value="' + swfHost + '/flash/profilemountVideo.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#373838" /><embed src="' + swfHost + '/flash/profilemountVideo.swf" quality="high" bgcolor="#373838" width="445" height="415" name="profilemountVideo" align="middle" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';
			
			//window.resizeTo(445 + 10, 415 + 50);
			resizeWindow(445, 415);
			document.bgcolor = "#373838";
			document.getElementById("showSWF").innerHTML = profileCode;
		}
	}

