var t_DiglogX,t_DiglogY,t_DiglogW,t_DiglogH;
var t_DialogObject = null;
var regFlag = false;

function gid(id) {
return document.getElementById?document.getElementById(id):null;
}

function gname(name) {
return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}

function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.isOP = false;
this.isSF = false;
ua = navigator.userAgent.toLowerCase();
s = "opera";
if ((i = ua.indexOf(s)) >= 0) {
   this.isOP = true;return;
}
s = "msie";
if ((i = ua.indexOf(s)) >= 0) {
   this.isIE = true;return;
}
s = "netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
   this.isNS = true;return;
}
s = "gecko";
if ((i = ua.indexOf(s)) >= 0) {
   this.isNS = true;return;
}
s = "safari";
if ((i = ua.indexOf(s)) >= 0) {
   this.isSF = true;return;
}
}

function DialogLoc() {
  var dde = document.documentElement;

  var xScroll, yScroll;  
  if (window.innerHeight && window.scrollMaxY) {  
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }

  var ww , wh ;
  if (self.innerHeight) {  // all except Explorer
    ww = self.innerWidth;
    wh = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    ww = document.documentElement.clientWidth;
    wh = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    ww = document.body.clientWidth;
    wh = document.body.clientHeight;
  }  
  
  var bgX,bgY
  if (window.innerWidth) {
	 bgX = window.pageXOffset;
	 bgY = window.pageYOffset;
  } else {
     bgX = dde.scrollLeft;
	 bgY = dde.scrollTop;
  }
  t_DiglogX = ((ww - t_DiglogW)/2) + document.body.scrollLeft;
  t_DiglogY = ((wh - t_DiglogH)/2) + document.body.scrollTop;
  
}

function DialogShow(showdata,ow,oh,w,h) {

var objDialog = document.getElementById(showdata);
t_DialogObject = objDialog;

t_DiglogW = ow;
t_DiglogH = oh;

 

DialogLoc();
var oS = objDialog.style;
oS.display = "block";
oS.top = t_DiglogY + "px";
oS.left = t_DiglogX + "px";
oS.margin = "0px";
oS.padding = "0px";
oS.width = w + "px";
oS.height = h + "px";
oS.position = "absolute";
oS.zIndex = "230000";
oS.background = "#D7D7D7";
}

function DialogHide(id) {
	try
	{		
		//window.document.flashResize.wmode = "opaque";
		//window.document.flashResize.Lplay();
		if(!regFlag)
			ScreenClean();
		 
		if (t_DialogObject) 
		{
			t_DialogObject.style.display = "none";
			if (t_DialogObject.id=="HelpVideoContainer")
			{
				t_DialogObject.innerHTML = "";
			}
		}
		if (id != '' && id != 'undefined')
		{	
			var obj = document.getElementById(id);
			if(obj != null)
			{
				obj.style.display = "none";
				obj.style.innerHTML = "";
				regFlag = false;
			}	
		}
	
	}catch(e){}

}

function ScreenConvert() {
var browser = new Browser();
var objScreen = gid("ScreenOver");
if (!objScreen) var objScreen = document.createElement("div");
var oS = objScreen.style;
objScreen.id = "ScreenOver";
oS.display = "block";
oS.top = oS.left = oS.margin = oS.padding = "0px";

var wh;
if (window.innerHeight && window.scrollMaxY) {  
    wh = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    wh = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    wh = document.body.clientWidth ;
  }
  /*
	if(navigator.userAgent.toLowerCase().indexOf('msie 7.0')>=0)
	{
		var form1=document.getElementById('aspnetForm');
		if(form1){
		if(form1.scrollHeight)wh=form1.scrollHeight+35;}
	}
	*/
oS.width = "100%";
oS.height = wh+"px";
oS.position = "absolute";
oS.zIndex = "220000";
if ((!browser.isSF) && (!browser.isOP)) {
   oS.background ="#181818" ;
   } else {
   oS.background = "#F0F0F0";
}
oS.filter = "alpha(opacity=70)";
oS.opacity = 70/100;
oS.MozOpacity = 70/100;
document.body.appendChild(objScreen);
}



function ScreenClean() {
var objScreen = document.getElementById("ScreenOver");
if (objScreen) objScreen.style.display = "none";
}

//function Report(Type,ID)
function Report()
{
   try
   {
   	  window.document.flashResize.Lpause();
   }
   catch(e)
   {
   
   }
   ScreenConvert();
   DialogShow("DialogMove",377,164,377,164);

}
function addTag()
{
    var objDialog = document.getElementById("DialogMove");
    var allInput = objDialog.getElementsByTagName("INPUT");
    
    var objTagDiv = document.getElementById("tagTextBox");
    var allInputBox = objTagDiv.getElementsByTagName("INPUT");
    
    if (allInput[0].value.length>0)
    {
        allInputBox[0].value = allInput[0].value
	    return DialogHide();
	}
	else
	{
    	var objAlert = gid("divPopTagAlert");
    	var oS = objAlert.style;
    	oS.display = "block";
    	objAlert.innerHTML = "The form field is empty. Please enter your tag below and click \"Add Tag\" to continue.";
    	return false;
    }
}

function CloseTag()
{
	var objAlert = gid("divPopTagAlert");
	var oS = objAlert.style;
	oS.display = "none";
	objAlert.innerHTML = "";
	return DialogHide();
}


function ShowDialog(showdata,ow,oh,w,h){

   try
   {
   	  window.document.flashResize.Lpause();
   }
   catch(e)
   {   
   }
   
   ScreenConvert();
   DialogShow(showdata,ow,oh,w,h);

}

function HideDialog(showdata) {
		return  DialogHide();
}

// Show Slowly
 var ScreenConvertAnimation = function(obj, startOpacity, endOpacity, stepOpacity, playTimeSpan, callback) {
            this.element = obj;
            this.hashcode = "SCA" + ScreenConvertAnimation.__COUNT++;
            this.style = obj.style;
            this.callback = callback;
            eval("ScreenConvertAnimation.all." + this.hashcode + "=this");

            this.startOpacity = startOpacity;
            this.endOpacity = endOpacity;
            this.stepOpacity = stepOpacity;
            this.playTimeSpan = playTimeSpan;
            this.isPlaying = false;

            this.setOpactity = function(v) {
                this.currentOpacity = v;

                this.style.filter = "alpha(opacity=" + v + ")";
                this.style.opacity = v / 100;
                this.style.MozOpacity = v / 100;
            };
            this.setOpactity(this.startOpacity);
            this.currentOpacity = this.startOpacity;

            this.isPlayback = function() {
                return this.stepOpacity > 0 ? (this.currentOpacity < this.endOpacity) : (this.currentOpacity > this.endOpacity);
            };

            this.play = function() {
                if (this.isPlayback()) {
                    this.isPlaying = true;
                    this.setOpactity(this.currentOpacity + this.stepOpacity);
                    this.timer = setTimeout("ScreenConvertAnimation.all." + this.hashcode + ".play();", this.playTimeSpan);
                }
                else {
                    this.isPlaying = false;
                    clearTimeout(this.timer);
                    if (this.callback)
                        if (typeof (this.callback) == "function")
                            this.callback.apply();
                }
            }
        }
        ScreenConvertAnimation.all = {};
        ScreenConvertAnimation.__COUNT = 0;

	 function ShowModal(sectionValue)
	 {
		var objScreen = document.getElementById("basicModalContent2");
		var pnlWidth = 930;
		var pnlHeight = 548;

	 	if (!objScreen)
	 	{	 	
			objScreen = document.createElement("div");
			objScreen.setAttribute('id','basicModalContent2');
			objScreen.className='flashwhole';
			//objScreen.style.backgroundColor = '#D7D7D7';

			var objImage = new Image();
			objImage.src = sectionValue;
			objImage.className='originalImg';
			
			var objCloseLink = document.createElement("a");
			objCloseLink.href = "javascript:popupclose();";

			var objCloseImage = document.createElement("img");
			objCloseImage.src = "/SiteCollectionImages/FluorEconamine/close_button.jpg";
			objCloseImage.className='closeImg';

			objCloseLink.appendChild(objCloseImage);

			objScreen.appendChild(objImage);
			objScreen.appendChild(objCloseLink);
			document.body.appendChild(objScreen);
		}		
	 	ShowDialog('basicModalContent2',pnlWidth,pnlHeight,pnlWidth,pnlHeight);
	 	var fay=document.getElementById('ScreenOver');
		document.body.appendChild(document.getElementById('basicModalContent2'));
		var scaobj = new ScreenConvertAnimation(gid('ScreenOver'),0,70,10,1);	
	 	scaobj.play();
	 	
		var ww , wh ;
		  if (self.innerHeight) { 
		    ww = self.innerWidth;
		    wh = self.innerHeight;
		  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		    ww = document.documentElement.clientWidth;
		    wh = document.documentElement.clientHeight;
		  } else if (document.body) { // other Explorers
		    ww = document.body.clientWidth;
		    wh = document.body.clientHeight;
		  }  

		var dde = document.documentElement;
		 var bgX,bgY
		  if (window.innerWidth) {
			 bgX = window.pageXOffset;
			 bgY = window.pageYOffset;
		  } else {
		     bgX = dde.scrollLeft;
			 bgY = dde.scrollTop;
		  }
		  	  
		document.getElementById('basicModalContent2').style.top = ((wh - pnlHeight)/2) + document.body.scrollTop;
		//GenerateFlvPlayer();
	 }
 	function popupclose()
 	{
 		try
 		{	
	 		DialogHide('basicModalContent2');
	 	}catch(ex){} 	
	 		
 	}

jQuery(document).ready(function(){
	//For Econamine FG+ Process Section:/econamine/Pages/efgprocess.aspx
	jQuery('#linktext').attr('href',"javascript:if(typeof ShowModal!='undefined'){ShowModal('/SiteCollectionImages/FluorEconamine/original.jpg');}");
	jQuery('#smallimglink').attr('href',"javascript:if(typeof ShowModal!='undefined'){ShowModal('/SiteCollectionImages/FluorEconamine/original.jpg');}");
	//For Power Plant Applications Section:/econamine/Pages/powerplantapplications.aspx
	jQuery('#efgplusimglink').attr('href',"javascript:if(typeof ShowModal!='undefined'){ShowModal('/SiteCollectionImages/FluorEconamine/Econamine_FG_Plus_large.gif');}");
	jQuery('#efgpluslinktext').attr('href',"javascript:if(typeof ShowModal!='undefined'){ShowModal('/SiteCollectionImages/FluorEconamine/Econamine_FG_Plus_large.gif');}");
	if(jQuery.trim(window.location.href).toLowerCase().indexOf("/econamine/pages/paper.aspx")>=0){
		jQuery("#sitemap_allpapers_link").css("display","inline");
		/*var divTitle=document.getElementById("divContentTitleId");
   		if(divTitle){
   			document.title=divTitle.innerHTML.replace(/&amp;/g,'&');}*/	
	}
});
