var popupTitle
var popupHeadline
var popupContent
var popupWindow

function openCasemasterFlash() {
	window.open('/flash/casemaster/index.html','popup','width=750,height=550');
	}
	
function navMouseAction(pageName, action) {
    //var d = document.getElementById("javascriptdebug");
    //d.innerHTML = pageName + ':' + action;
    try {
        homePageFlash(pageName, action);
    } 
        catch (e) {
    };
};

function leftnavOver(rowNumber){
	eval(rowNumber +"arrow").src="images/leftnav_doublearrow.gif";
	eval("nav" +rowNumber).style.backgroundColor='#DFDCD8';
	eval("nav" +rowNumber).style.cursor='hand';
	}

function Querystring()
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		name = temp.join(' ');

		temp = unescape(pair[1]).split('+');
		value = temp.join(' ');

		this[name]=value;
	}

	this.get=Querystring_get;
}

function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}

	return value;
}

function getQuerystringVar(varName) {
	var value = ""
	if (window.location.search.indexOf(varName + '=') != -1) {value = window.location.search.substring(window.location.search.indexOf(varName + '=') + varName.length + 1,(window.location.search+'&').indexOf('&',window.location.search.indexOf(varName + '=') + varName.length))}
	return value;
	}
	
function leftnavOut(rowNumber){
	eval(rowNumber +"arrow").src="images/leftnav_arrow.gif";
	eval("nav" +rowNumber).style.backgroundColor='';
	}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

function ImagePreloader(imgs,callback) {
	// store the callback
   this.callback = callback;
   // initialize internal state.
   this.nLoaded = 0;
   this.nProcessed = 0;
   this.aImages = new Array;
   // record the number of images.
   this.nImages = imgs.length;
   // for each image, call preload()
   this.preload = ImagePreloader.prototype.preload;
   this.onComplete = ImagePreloader.prototype.onComplete;
   for (var i=0; i < imgs.length; ++i) {
		this.preload(imgs[i].src)
		}
   }
 
ImagePreloader.prototype.preload = function(imgsrc) {
   // create new Image object and add to array
   var oImage = new Image;
   this.aImages.push(oImage);
   // set up event handlers for the Image object
   oImage.onload = ImagePreloader.prototype.onload;
   oImage.onerror = ImagePreloader.prototype.onerror;
   oImage.onabort = ImagePreloader.prototype.onabort;
   // assign pointer back to this.
   oImage.oImagePreloader = this;
   oImage.bLoaded = false;
   // assign the .src property of the Image object
   oImage.src = imgsrc;
	}
 
ImagePreloader.prototype.onComplete = function() {
   this.nProcessed++;
   if ( this.nProcessed == this.nImages ) {
      this.callback(this.aImages, this.nLoaded);
		}
	}

ImagePreloader.prototype.onload = function()
{
   this.bLoaded = true;
   this.oImagePreloader.nLoaded++;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function() {
   this.oImagePreloader.bError = true;
   this.oImagePreloader.onComplete();
   }

ImagePreloader.prototype.onabort = function()
{
   this.bAbort = true;
   this.oImagePreloader.onComplete();
}

function photoGalleryPopup(ID,Gallery,Action) {
	if (!Gallery) {Gallery=''}
	if (!Action) {Action=''}
	newWindow = window.open('photoPopup.aspx?ID=' + ID + '&Gallery=' + Gallery + '&action=' + Action,'caseStudy','top=45,left=80,width=775,height=540,menubar=yes,scrollbars=no',false);
	}
	
function emailContent(URL,Title) {
	if (!URL) {
		URL = escape(window.location);
	}
	if (!Title) {
		Title = escape(document.title);
	}
	window.location = 'mailto:?subject=' + Title + '&body=Look%20what%20I%20found%20on%20Marvin.com:%0A%0A' + Title + '%0A' + URL;
}
	
function popup(title,headline,querystring,content,height,width,action,bScrollbars) {
	var URL = 'popup.aspx' + querystring
	var scrollbars = 'no'
	if (bScrollbars) {scrollbars='yes'}
	if (action != '') {
		if (querystring == '') {
			URL += '?action=' + action
		}
		else {
			URL += '&action=' + action
		}
	}
	if ((window.navigator.userAgent.indexOf('Opera') < 0) && (popupWindow != null)) { popupWindow.close() }
	popupWindow = window.open(URL,'popup','top=45,left=80,width=' + width + ',height=' + height + ',menubar=yes,scrollbars='+scrollbars,false);
	popupTitle = title;
	popupHeadline = headline;
	popupContent = content;
}
	
function popupImage(title,headline,imgSrc,imgHeight,imgWidth) {
	popup(title,headline,'','<p align="center"><img src="' + imgSrc + '" border="0" width="' + imgWidth + '" height="' + imgHeight + '"></p>',imgHeight+80,imgWidth+58);
	}
	
function printPage() {
	var popupPrintEnabled = true;
		if ((popupPrintEnabled) && (window.location.pathname.indexOf('popup.aspx') == -1) && (window.location.pathname.indexOf('photoPopup.aspx') == -1)) {
			popup(document.title,document.title,window.location.search,'',520,780,'print',true);
		} 
		else {
			if (window.navigator.userAgent.indexOf('Netscape') > 0) {
				window.setTimeout(window.print,1);
			} 
			else {
				window.print();
			}
		}
	}
	
function popup_AboutLaminatedGlass() {
	popup('About Laminated Glass','About Laminated Glass','?page=popup_About_Laminated_Glass','',320,560,'','')
	}
	
function popup_StoolAndApron() {
	popup('What is a Stool and Apron?','What is a Stool and Apron?','?page=popup_Stool_and_Apron','',210,440,'','')
	}
	
function popup_AboutUltrex() {
	popup('About Ultrex','About Ultrex','?page=popup_About_Ultrex','',180,400,'','')
	}
	
function popup_AboutDirectGlazeAndInSashConstruction() {
	popup('About Direct Glaze and In-Sash Construction','About Direct Glaze and In-Sash Construction','?page=popup_About_Direct_Glaze_and_InSash_Construction','',515,515,'','')
	}
	
function popup_AboutASTMZones() {
	popup('About ASTM Zones','About ASTM Zones','?page=popup_About_ASTM_Zones','',380,450,'','')
	}
	
function popup_AboutFlurospar() {
	popup('About Marvin products and Flurospar','About Marvin products and Flurospar','?page=popup_About_Flurospar','',360,430,'','')
	}
	
function popup_AboutPVD() {
	popup('About PVD','About PVD','?page=popup_About_PVD','',320,560,'','')
	}
	
function popup_AboutEnergyPanels() {
	popup('Energy Panels','Energy Panels','?page=popup_Energy_Panels','',320,560,'','')
	}

function popup_AboutCombinationPanels() {
	popup('Storm and Screen Combination Panels','Storm and Screen Combination','?page=popup_Storm_Screen_Combination','',320,560,'','')
	}
	
function popup_AboutEnergyStar() {
	popup('About Energy Star','About Energy Star','?page=popup_AboutEnergyStar','',160,430,'','')
	}