﻿//Handle PopUP Box
	function ShowElement(id,yesno)
	{
	    var display="none";
	    var Element=document.getElementById(id);
	    if(Element!=null)
	    {
	        if(yesno){display="block";}
	        Element.style.display=display;
	    }
	}
    function ShowElement2(id,yesno)
	{
	    var display="hidden";
	    var Element=document.getElementById(id);
	    if(Element!=null)
	    {
	        if(yesno){display="visible";}
	        Element.style.visibility=display;
	    }
	}
	
	function loadPopUpBox(BoxID) {
	    ShowElement2("birthdaybox",false);
	    ShowElement2("videoPlayer",false);
		var iHigh = document.body.scrollTop + 100;
		var iWide = ((document.body.scrollWidth / 2) + (620 / 2) * -1);
		var iBiggerHeight = document.body.scrollHeight > screen.height ? document.body.scrollHeight : screen.height; 
		if(document.layers){
			
			document.layers['LeaveSiteTileBot'].width = '100%'; 
			document.layers['LeaveSiteTileBot'].height = iBiggerHeight;
			document.layers['LeaveSiteTileBot'].visibility = 'visible';
			document.layers[BoxID].visibility = 'visible';
		
		}else if(document.getElementById){
			document.getElementById('LeaveSiteTileBot').style.width = '100%'; 
			document.getElementById('LeaveSiteTileBot').style.height = iBiggerHeight + 'px'; 
			document.getElementById('LeaveSiteTileBot').style.visibility = 'visible'; 
			document.getElementById(BoxID).style.visibility = 'visible'; 
		}
		scroll(0,0);
	}
	
	function unloadPopUpBox(BoxID) {
		if(document.layers){
			document.layers['LeaveSiteTileBot'].visibility = 'hidden';
			document.layers[BoxID].visibility = 'hidden';
		
		}else if(document.getElementById){
			document.getElementById('LeaveSiteTileBot').style.visibility = 'hidden'; 
			document.getElementById(BoxID).style.visibility = 'hidden'; 
		}
		ShowElement2("birthdaybox",true);
		ShowElement2("videoPlayer",true);
	}


// Handle Leave-Site
var sLoc = '';	
	function loadLeaveSite(sLocation) {
	    ShowElement2("birthdaybox",false);
	    ShowElement2("videoPlayer",false);
		sLoc = sLocation;
		var iHigh = document.body.scrollTop + 100;
		var iWide = ((document.body.scrollWidth / 2) + (620 / 2) * -1);
		var iBiggerHeight = document.body.scrollHeight > screen.height ? document.body.scrollHeight : screen.height; 
		if(document.layers){
			
			document.layers['LeaveSiteTileBot'].width = '100%'; 
			document.layers['LeaveSiteTileBot'].height = iBiggerHeight;
			document.layers['LeaveSiteTileBot'].visibility = 'visible';
			document.layers['LeaveSitePopup'].visibility = 'visible';
		
		}else if(document.getElementById){
			document.getElementById('LeaveSiteTileBot').style.width = '100%'; 
			document.getElementById('LeaveSiteTileBot').style.height = iBiggerHeight + 'px'; 
			document.getElementById('LeaveSiteTileBot').style.visibility = 'visible'; 
			document.getElementById('LeaveSitePopup').style.visibility = 'visible'; 
		}
		scroll(0,0);
		TrackExitPopUpBox();
	}

	function unloadLeaveSite() {
		if(document.layers){
			document.layers['LeaveSiteTileBot'].visibility = 'hidden';
			document.layers['LeaveSitePopup'].visibility = 'hidden';
		
		}else if(document.getElementById){
			document.getElementById('LeaveSiteTileBot').style.visibility = 'hidden'; 
			document.getElementById('LeaveSitePopup').style.visibility = 'hidden'; 
		}
		ShowElement2("birthdaybox",true);
		ShowElement2("videoPlayer",true);
	}
	
	function leaveSite(){
		window.open(sLoc);
		unloadLeaveSite();
	}


//Custom Civic Gallery and Band Gallery Related Functions
function handleGalleryClick(which)
{
 thumbSelect(which);
 var picture=document.getElementById("cc-gallery-picture");
 var thumb=which.getElementsByTagName("img");
 picture.src=thumb[0].src.replace("-thumb","");
 TrackGalleryPhoto(picture.src);
}

function thumbSelect(which)
{
    var x=0;  
    var tbox=document.getElementById("cc-thumbs");
    var thumbs=tbox.getElementsByTagName("div");
    for(i=0;i<thumbs.length;i++)
    {
        if(thumbs[i]==which)
        {
            thumbs[i].style.border="2px solid #3DC6FF";
            CurrentPictureIndex=x;
            x++;
        }    
        else
        { 
            if(thumbs[i].className=="cc-gallery-thumb")
            {
                thumbs[i].style.border="2px solid #BB4F34";
                x++;
            }    
        }
    }
    CCGalleryLength=x;
}

function handleCCGalleryPrevNext(code)
{
    var tbox=document.getElementById("cc-thumbs");
    var thumbs=tbox.getElementsByTagName("div");
    CurrentPictureIndex+=code;
    if(CurrentPictureIndex<0)CurrentPictureIndex=CCGalleryLength-1;
    if(CurrentPictureIndex>CCGalleryLength-1)CurrentPictureIndex=0;
    handleGalleryClick(thumbs[CurrentPictureIndex]);  
}