// Capture XY mouse coordinates with jQuery
$(function(){
	$().mousemove(function(e){
		mouseX = e.pageX;
		mouseY = e.pageY;     	  
	}); 
})



// BEGIN Admin Login PopUp Div Control ---------------
$(document).ready(function(){

    /*$(document).pngFix(); */
	
   //When the link that triggers the message is clicked fade in overlay/msgbox
   $(".alert").click(function(){
	  $("#fuzz").css("height", $(document).height()).fadeIn();
	  $("#msgbox").css("top",$(window).scrollTop() + ($(window).height()/2) );
	  
      return true;
   });

   //When the message box is closed, fade out
   $(".close").click(function(){
      $("#fuzz").fadeOut();
	  
      return false;
   });


	// Setup FancyBox for Photo Gallery Items
	$('.gallery-item').fancybox({
		titlePosition: 'inside',
		padding: 35,
		changeFade: 500
	});
	
	// Setup FancyBox for Events
	$(".event-item").fancybox({
		'width'				: 550,
		'height'			: 450,
		'autoScale'			: false,
		'margin'			: 5,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'centerOnScroll'	: false,
		'padding'			: 35
	});
	
	
	// Setup FancyBox for Email-This-Page
	$(".email-item").fancybox({
		'width'				: 550,
		'height'			: 450,
		'autoScale'			: false,
		'margin'			: 5,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'centerOnScroll'	: false,
		'padding'			: 35
	});

});



// Adjust Position of the Back to Top Box
$(function () {
	$(window).scroll(function () {
		if ($(this).scrollTop() > 450) 
		{
			$('#toTop').fadeIn();
		} 
		else 
		{
			$('#toTop').fadeOut();
		}
	});
	$('#toTop').click(function () {
		$('body,html').animate({
			scrollTop: 0
		},
		800);
	});
});



//Adjust height of overlay to fill screen when browser gets resized
$(window).bind("resize", function(){
	$("#fuzz").css("height", $(document).height());
	$("#msgbox").css("top",$(window).scrollTop() + ($(window).height()/2) );
});

// END Login PopUp Div Control =========================


function Jump(obj,pageID)
{
	page = obj[obj.selectedIndex].value
	
	if(page != 0)
	{
		//alert(obj.selectedIndex)
		url = "../controlPanel/"+page + ".php?pageID="+pageID
		workerFrame.location.href = url
	}
}

function ShowRow(rowID)
{
    var chunk = document.getElementById(rowID).style
	var linkText = document.getElementById("l1")
    if(chunk.display == "")
	{
		chunk.display="none"
	}
	else
	{
		chunk.display=""
	}
}

var editWindow=""

function EditWindow(functionName,ID)
{
	
	if(editWindow == "" || editWindow.closed)
	{
		editWindow = window.open("../controlPanel/"+functionName+".php?ID=" + ID,"new","height=440,width=365,scrollbars=1")
	}
	else
	{ 
		editWindow.location.href = "../controlPanel/"+functionName+".php?ID=" + ID
		editWindow.focus()
	}
}

var passWindow=""

function PasswordWindow()
{
	
	if(passWindow == "" || passWindow.closed)
	{
		passWindow = window.open("../../forgotPassword.php","new","height=340,width=365,scrollbars=0")
	}
	else
	{ 
		passWindow.location.href = "../../forgotPassword.php"
		passWindow.focus()
	}
}



var galleryWin=""
var templateID = 1

function Gallery(parentID,pic,franchiseID)
{
	windowWidth = 865
	windowHeight = 670
	
	if(galleryWin == "" || galleryWin.closed)
	{
		galleryWin = window.open("../../photo.php?parentID="+parentID+"&pic="+pic+"&f="+franchiseID,"new","height="+windowHeight+",width="+windowWidth+",scrollbars=1,resizable=1")
	}
	else
	{ 
		galleryWin.location.href="../../photo.php?parentID="+parentID+"&pic="+pic+"&f="+franchiseID
		galleryWin.focus()
	}
}


function fontSize(dir)
{

	numSheets = document.styleSheets.length - 1
	
	if(myStyle = document.styleSheets[numSheets].rules[0])
	{
		var myStyle = document.styleSheets[numSheets].rules[0].style;
	}
	else
	{
		var myStyle = document.styleSheets[numSheets].cssRules[0].style;
	}
	var fFamily = myStyle.fontFamily;
	var fSize = parseInt(myStyle.fontSize);
	
	if(dir) myStyle.fontSize = (fSize + 2) + "px"
	else myStyle.fontSize = (fSize - 2) + "px"


	document.cookie = "fontSize="+parseInt(myStyle.fontSize)+"; expires=Thu, 2 Aug 2010 20:47:11 UTC; path=/"
}

var sendEmail=""

function sendEventEmailButton(ID)
{
	if(sendEmail == "" || sendEmail.closed)
	{
		sendEmail = window.open("/assets/sendEventEmailButton.php?ID="+ID,"new","height=420,width=405,scrollbars=0,resizeable=0")
	}
	else
	{ 
		sendEmail.location.href="/assets/sendEventEmailButton.php?ID="+ID
		sendEmail.focus()
	}
}

var controlWindow=""
function openControlPanel(url)
{
	if(controlWindow == "" || controlWindow.closed)
	{
		controlWindow = window.open(url,"new","height=600,width=900,scrollbars=1,resizable=1,toolbar=0,location=0,directories=0,menubar=0,copyhistory=0")
		controlWindow.focus()
	}
	else
	{ 
		controlWindow.location.href=url
		controlWindow.focus()
	}
}