﻿/* Popup script - Richard Wison of Waxwing Ltd 2/10/2007 */
/*
The commented out xmlhttp element at the top is for IE, please leave. 
The timer can be set under NotificationTimeout. All functions are explained below.
*/

//set timer in seconds
var NotificationTimeout = 300;

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}


function ShowPopup()
{
	var objTest = document.getElementById("test")
	// objTest.style.left = "400px";
	document.getElementById("popup1").style.visibility = 'visible';
    // document.getElementById("popup2").style.visibility = 'visible';
   
    var ScrollTop = document.body.scrollTop;

    if (ScrollTop == 0)
    {
        if (window.pageYOffset)
            ScrollTop = window.pageYOffset;
        else
            ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    } 
    
   // alert(ScrollTop + "ello" + window.pageYOffset);
   
   
   version=0;
    if (navigator.appVersion.indexOf("MSIE")!=-1)
    {
        temp=navigator.appVersion.split("MSIE");
        version=parseFloat(temp[1]);
        if (version<7.0) 
        {
            
        }
    }
    
    if(ScrollTop <140)
		ScrollTop = 140;
    
    document.getElementById("popup1").style.top = ScrollTop + "px";
    //alert(document.getElementById("popup1").style.top);
    //document.all.popup2.style.marginTop = ScrollTop;
    
   
}

function HidePopup()
{
   document.getElementById("popup1").style.visibility = 'hidden';
   // document.getElementById("popup2").style.visibility = 'hidden';
}

function ShowHistoryImage(imageid) 
{
    if(imageid!="25")
    {
	    xmlhttp.open("GET", "History.aspx?imageid=" + imageid, true);
	    xmlhttp.onreadystatechange=function()
	    {
		    if (xmlhttp.readyState==4)
		    {
			    SetPopup(xmlhttp.responseText);
		    }
	    }
	    xmlhttp.send(null);	
	}
	else
	{
		window.open("PDFs/history/25.pdf","mywindow");
	}
}

function SetPopup(strContent)
{
     document.getElementById("popup1").innerHTML = strContent;
     ShowPopup();
}

function ShowTeam(teammemberid) 
{
    xmlhttp.open("GET", "History.aspx?teammemberid=" + teammemberid, true);
    xmlhttp.onreadystatechange=function()
    {
	    if (xmlhttp.readyState==4)
	    {
		    SetPopup(xmlhttp.responseText);
	    }
    }
    xmlhttp.send(null);	
}


function ShowImage(strTitle, strImage, strDescription)
{
	if(strImage == "images/history/400/25.jpg")
	{
		window.open("PDFs/history/25.pdf","mywindow");
	}
	else
	{
		strBody = "<div id=\"popupInner\"><div id=\"closepopup\"><a href=\"javascript:HidePopup()\"><img src=\"images/close.gif\" alt=\"Close popup\" title=\"Close popup\" border=\"0\"></a><p>" + strTitle + "</p></div>";
		strBody += "<a href=\"javascript:HidePopup()\"><img src=\"" + strImage + "\" alt=\"" + strTitle + "\" border=\"0\" title=\"Click image to close\" /></a>";
		strBody += "<p>" + strDescription + "</p></div>";
		document.getElementById("popup1").innerHTML = strBody;
		ShowPopup();
	}
}