﻿function ShowBigImg(obj, PictureID, EventID, BigImgSrc, PictureTitle, FullImgSrc,Descriptions)
{	
    
    var PictureID   = nvl(obj.PictureID, PictureID) ;	
	var EventID     = nvl(obj.EventID, EventID);
	var BigImgSrc   = nvl(nvl(obj.BigImgSrc, BigImgSrc),"");
	var PictureTitle= nvl(obj.PictureTitle, PictureTitle);
	var FullImgSrc  = nvl(nvl(obj.FullImgSrc, FullImgSrc),"");
	var Descriptions= nvl(obj.Descriptions, Descriptions);
	/*
	alert(
	"PictureID="+PictureID+";"+
	"EventID="+EventID+";"+
	"BigImgSrc="+BigImgSrc+";"+
	"FullImgSrc="+FullImgSrc+";"+
	"Descriptions="+Descriptions+";"
	)
	*/	
	var oSBImage    = document.getElementById("SelectedBigImage");
	ShowSmallImg(obj);
	oSBImage.src			= BigImgSrc;
	oSBImage.alt			= PictureTitle;
	
	oSBImage.PictureID	    = PictureID;
	oSBImage.EventID	    = EventID;
	
	oSBImage.style.cursor	= "auto";
	oSBImage.FullImgSrc		= "";
	
	try{
		oSBImage.filters[0].Apply();
		oSBImage.filters[0].Play(duration=2);
	}catch(e){}
	
	oSBImage.onclick		= function() {};
	BottomDIV2.innerHTML	= "";
	
	if(!isnull(FullImgSrc))
	{   
	    var sSelectedBigImageFullImgPopUp		= "PopUpImg.asp?EventID="+EventID+
	                                               "&PictureID="+PictureID;
            
        var sSelectedBigImageFullPicture	= ""+
            "<a href='"+sSelectedBigImageFullImgPopUp+"' target=_blank "+
                " title='"+PictureTitle+"\n -------------------\n"+sZoomImgDesc+"' "+
                " onclick='javascript:ShowPopUpImg();return false;'>"+
                "<img src='img/zoom0.gif' width=15 height=15 style='vertical-align:middle;' border=0 alt='"+sZoomImgLink+"'>&nbsp;"+
                sZoomImgLink+
            "</a>";
					    
		oSBImage.style.cursor	= "hand";
		oSBImage.onclick		= function() {ShowPopUpImg()};
		oSBImage.FullImgSrc		= FullImgSrc;
		BottomDIV2.innerHTML	= sSelectedBigImageFullPicture;//"<a href='javascript:ShowPopUpImg()'>"+sZoomImgLink+"</a>"
		oSBImage.alt			+= "\n -------------------\n"+sZoomImgDesc;		
	}
	// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	BottomDIV3.innerHTML				= Descriptions;
	
	/*this.className						= "ShowedSmallImg";
	this.onmouseover					= function() {alert()};
	this.onmouseout						= function() {alert()};
	*/
	return true;
}
function FixWindowFeatures(iWidth, iHeight, bFullScreen)
{
	try
	{	
		var iW		= nvl(iWidth,800);
		var iH		= nvl(iHeight,600);
		
		var iLeft	= (screen.availWidth-iW)/2;
		var iTop	= (screen.availHeight-iH)/2;
		
		if(iLeft < 0 || iTop < 0)   bFullScreen =true;
		
		if(bFullScreen)
		{
			var iW		= screen.availWidth * 0.98;
			var iH		= screen.availHeight * 0.98;
		
			var iLeft	= 0;
			var iTop	= 0;
		}
		
		
		var sFeatures	= ""+
				"scrollbars=yes,toolbar=no,status=no,resizable=yes,"+
				"width="+iW+",height="+iH+",top="+iTop+"px,left="+iLeft+"px";		
		//alert("sFeatures="+sFeatures)
		return sFeatures;
	}
	catch(e)
	{
		window.status = "FixWindowFeatures()=>Error:" + e.description;
		return null;		
	}
}
function ShowPopUpImg(EventID, iPictureID, sSrc)
{
    try
    {
	    var sUrl        = "PopUpImg.asp?";
	    var sParam      = "";
	    if(parseInt("0"+EventID,10) > 0)
	    {
	        sParam      = "EventID="+parseInt("0"+EventID,10);
	        if(parseInt("0"+iPictureID,10) > 0)
	        {
	            sParam += "&PictureID="+parseInt("0"+iPictureID,10);
	        }
	    }
	    else
	    {
	        var oSBImage    = document.getElementById("SelectedBigImage");
	        sParam      = "EventID="+oSBImage.EventID+
                      "&PictureID="+oSBImage.PictureID;
                      
        }
        if(!isnull(sSrc))   sParam += "&src="+sSrc;
        
        sUrl    += sParam + "&Resize=1";
        
        var sFixWindowFeatures   = "scrollbars=auto,toolbar=no,status=no,resizable=yes,width=830,height=640";
        sFixWindowFeatures   = FixWindowFeatures(null, null, true);
        //sFixWindowFeatures   = 'fullscreen=yes, scrollbars=auto'
	    var win = window.open(sUrl, "FullImg", sFixWindowFeatures);
	    win.focus();
    }
    catch(e)
	{
		window.status = "ShowPopUpImg()=>Error:" + e.description;
		return null;		
	}
}

function TopBarOnOver(sImageID, sType)
{
    try
    {        
        var oOverImage    = document.getElementById(sImageID);
        //alert(oOverImage.src)
	    if(sType == "ON_OVER")
	    {
		    //obj.className	= 'SelectedTopBarTD';
		    //document.all[obj.td_img_id].src = "img/icon_on.gif";
		    oOverImage.src = "img/icon_on.gif";
	    }
	    else
	    {
		    //obj.className	= 'TopBarTD';
		    //document.all[obj.td_img_id].src = "img/icon_off.gif";
		    oOverImage.src = "img/icon_off.gif";
	    }
	}
	catch(e){}		
}
function ShowPage(obj)
{
	window.location = obj.Url
}
function ShowEvent(obj, bShowBigImg, iPictureID)
{
	// getting events array and reset all objects
	var arrEvents	= (""+document.all["NavigationTable"].arrEvents).split(",");		
	for(i=0;i<arrEvents.length;i++)
	{
		document.all["tbl_"+arrEvents[i]].style.display = "none";
		var oldObj			= document.all["td_"+arrEvents[i]];
		oldObj.className	= "SideNavigationTD";
		oldObj.onmouseover	= function() {this.className='SelectedSideNavigationTD'};
		oldObj.onmouseout	= function() {this.className='SideNavigationTD'};
	}
	
	var iActiveEvent =  document.all.ActiveEvent.value
	document.all.ActiveEvent.value = obj.EventID;
	document.all["tbl_"+iActiveEvent].style.display = "none";
	document.all["tbl_"+obj.EventID].style.display	= "block";
	
	if(parseInt("0"+obj.ExistFullImg,10))
	{
	   // ShowPopUpImg(obj.EventID)
	   
	   var sPopUpUrl		= "PopUpImg.asp?EventID="+obj.EventID;
	   var sPopUpUrlLink    = ""+
	        "<a href='"+sPopUpUrl+"' target=_blank "+
                " title='"+sSlideShow+"' "+
                " onclick='javascript:ShowPopUpImg("+obj.EventID+");return false;'>"+
                "<img src='img/zoom.gif' width='14' height='14' style='vertical-align:middle;' border=0 alt='"+sSlideShow+"'>&nbsp;"+
                sSlideShow+
            "</a>"; 
	   BottomDIV1.innerHTML	= sPopUpUrlLink;
	}
	BottomDIV3.innerHTML	= obj.EventDesc;
	
	obj.className		= "SelectedSideNavigationTD";
	obj.onmouseover		= "SelectedSideNavigationTD";
	obj.onmouseout		= "SelectedSideNavigationTD";
	
	var arrTDImages	= (""+document.all["tbl_"+obj.EventID].arrTDImages).split(",");
	var sEventDesc	=  document.all["td_"+obj.EventID].EventDesc;
	var oTDImg      = null;
	
	for(i=0;i<arrTDImages.length;i++)
	{
	    bShowBigImg	= false;
	    oTDImg      = document.getElementById(arrTDImages[i]);
	    if(parseInt("0"+iPictureID,10) > 0 && oTDImg.PictureID == parseInt("0"+iPictureID,10))
	    {
	     
	        bShowBigImg = true;
	    }
	    else if(bShowBigImg && i==0)
	    {   
		    bShowBigImg = true;		    
		}
		
		ShowSmallImg(oTDImg, sEventDesc, bShowBigImg);
	}
}
function ShowSmallImg(obj, sEventDesc, bShowBigImg)
{
	//alert("ShowSmallImg=>"+obj.SmallImgID+";"+obj.SmallImgSrc)
	//alert(document.all[obj.SmallImgID].src)
	//document.all[obj.SmallImgID][0].src = obj.SmallImgSrc;
	try
	{
	    if(parseInt("0"+obj.loaded,10) == 0)
	    {	
		    document.all[obj.SmallImgID].src        = obj.SmallImgSrc;
		    document.all[obj.SmallImgID].className  = "SmallImg";
		    if(document.all[obj.SmallImgID].alt == "" || document.all[obj.SmallImgID].alt == null)
		    {
			    document.all[obj.SmallImgID].alt	= sEventDesc;
			    obj.Descriptions					= sEventDesc;				
		    }	
		    obj.loaded	= 1; //loaded
	    }
    	
	    if(bShowBigImg)
		    ShowBigImg(obj)
	}
	catch(e)
	{
	    window.status   = e.description;
	}
}

