/****************************************
*** Audronis.com Javascript Content   ***
*** Copyright, 2011 Tyris M. Audronis ***
****************************************\

/*******************************
*** Global Vairables Section ***
********************************/
var headerContext;
var headerCanvas;
var blurInInterval;
var currentHeaderBlur;

/*****************************
*** Generic Canvas Section ***
*****************************/

	/*** Test for canvas support ***/

		function canvasSupport(){
					return !!document.createElement('testCanvas').getContext;	
				}
		function canvasTest() {
			canvasSupport();
			alert(navigator.appName);
			if (!canvasSupport || navigator.appName == 'Microsoft Internet Explorer') {
				document.location="NoHTML5.php";	
			}
			
		}
		
		function parseShadow(shadows) {
			shadows = shadows.split(", ");
			var ret = [];
			for (var n = 0, length = shadows.length; n < length; n ++) {
				var shadow = shadows[n].split(" ");
				var type = shadow[0].replace(parseFloat(shadow[0]), "");
				if (type == "em") {
					var obj = {
						x: metrics.em * parseFloat(shadow[0]),
						y: metrics.em * parseFloat(shadow[1])
					};
				} else {
					var obj = {
						x: parseFloat(shadow[0]),
						y: parseFloat(shadow[1])
					};
				}
				if (shadow[3]) {
					obj.blur = parseFloat(shadow[2]);
					obj.color = shadow[3];
				} else {
					obj.blur = 0;
					obj.color = shadow[2];		
				}
				ret.push(obj);
			}
			return ret;
		};
		
		

/****************************
*** Header Canvas Section ***
****************************/
		
	/*** set up the Canvas ***/
		function headerSetup(){
			headerCanvas = document.getElementById("HTML5header");
			headerContext = headerCanvas.getContext("2d");
		}
	
	/*** Blur in the page title ***/
		function drawHeaderTitle(theSite, theTitle){
			headerContext.shadowColor = "rgba(100,100,100,10)";
			headerContext.shadowOffsetX = 5;
			headerContext.shadowOffsetY = 5;
			headerContext.shadowBlur = 8;
			headerContext.font = "70px Lucida Sans Unicode, Lucida Grande, _sans";
			headerContext.textBaseline = "top";
			headerContext.fillStyle = "rgba(0, 0, 0, 255)";
			headerContext.fillText(theSite, 40, 20);
			
			headerContext.shadowColor = "rgba(100,100,100,10)";
			headerContext.shadowOffsetX = 5;
			headerContext.shadowOffsetY = 5;
			headerContext.shadowBlur = 8;
			headerContext.font = "30px Lucida Sans Unicode, Lucida Grande, _sans";
			headerContext.textBaseline = "top";
			headerContext.fillStyle = "rgba(89, 27, 37, 255)";
			headerContext.fillText(theTitle, 45, 100);
			
			 
			//blurInInterval = setInterval(blurInHeader, 10);
			
		}
		
	/*** Do the actual blur animation ***/
		function blurInHeader(){
			currentHeaderBlur --;
			headerContext.shadowBlur = 0;
			currentAlpha = 255 - (5*currentHeaderBlur);
			headerContext.shadowColor = "rgba(0,0,0,255)";
			if(currentHeaderBlur <= 0){
				clearInterval(blurInInterval);	
			}
			headerContext.textBaseline = "top";
			headerContext.fillStyle = "rgba(0, 0, 0, 255)";
			headerContext.fillText(currentHeaderBlur, 40, 40);
		}
		
/**********************************
***  Navbar JS                  ***
**********************************/
function setNavbar(){
	(function($){  
	  
			//cache nav  
			var nav = $("#topNav");  
	  
			//add indicators and hovers to submenu parents  
			nav.find("li").each(function() {  
				if ($(this).find("ul").length > 0) {  
	  
					$("<span>").text("↓").appendTo($(this).children(":first"));  
	  
					//show subnav on hover  
					$(this).mouseenter(function() {  
						$(this).find("ul").stop(true, true).slideDown();  
					});  
	  
					//hide submenus on exit  
					$(this).mouseleave(function() {  
						$(this).find("ul").stop(true, true).slideUp();  
					});  
				}  
			});  
		})(jQuery); 
}
// Example: obj = findObj("image1");
function findMe(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];

  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);

  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

function tyFramePopup(theType, theSpecific){
	//alert($('thePopUp'));
	thePopUpThing = findMe("thePopUp");
	//alert(2);
	thePopUpFrame = findMe("popUpFrame");
	//alert(gotHere);
	if(theType == "slideShow"){
		thePopUpFrame.src = "mediaShows/Photography/photoSlideshow.php";
	}
	else if(theType=="video"){
		thePopUpFrame.src = "mediaShows/VideoPlayer/videoPlayer.php?name=" + theSpecific;
	}
	else if(theType=="audio"){
		thePopUpFrame.src = "mediaShows/AudioPlayer/audioPlayer.php?name=" + theSpecific;
	}
	$('thePopUp').fadeIn(500);
	theTop = $(window).scrollTop() + 50;
	if (theTop < 210){
		theTop = 210;	
	}
	$('#thePopUp').animate({width: '800', height: '526', top:theTop, left:'50'}, 1000);
	$("#PopUpFrame").animate({width: '800', height: '526'}, 1000);
	
}

function closePopUp(){
	thePopUpFrame = findMe("popUpFrame");
	thePopUpFrame.src="images/TyFrame.jpg";
	$('#thePopUp').animate({width: '1', height: '1', top:'210', left:'50'}, 1000);
	$('thePopUp').fadeOut(500);	
}
