$(document).ready(function(){
	$("a#openPopup").fancybox({
		'hideOnContentClick'	: false,
		'showCloseButton'		: false,
		'autoScale'				: false,
		'padding'				: 0,
		'margin'				: 0,
		'centerOnScroll'		: true
	});
	
	$("#nextProj").click(function(){
		//var newPnum=_projectNumbers.shift();
		//_projectNumbers.push(newPnum);
		if (_pNum == _projCounter)
			newPnum = 1;
		else
			newPnum = _pNum + 1;
		changePopUp(newPnum);
	});
			
});



function setVisible(obj)
{
       obj = document.getElementById(obj);
       obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
     }

function openFrameless(){
	setVisible("project_p");
	//grayOut(true);

         }

function placeIt(obj)
{
       obj = document.getElementById(obj);
       if (document.documentElement)
       {
               theLeft = document.documentElement.scrollLeft;
               theTop = document.documentElement.scrollTop;
       }
       else if (document.body)
       {
               theLeft = document.body.scrollLeft;
               theTop = document.body.scrollTop;
       }
       //theLeft += x;
       //theTop += y;
       obj.style.left = theLeft + 'px' ;
       obj.style.top = theTop + 'px' ;
       setTimeout("placeIt('project_p')",500);
}
//window.onscroll = setTimeout("placeIt('project_p')",500);

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
     }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
}
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}   



var animFunc = ["easeOutElastic", "easeInOutElastic" ];

$(window).load(function() {
// wait until all objects been loaded including images & flash

	// jQuery Shadow removed for now because we have better CSS solution, need to check support for all browser and if that the case throw this out
   //$("li a").dropShadow({left: -1, top: 1, opacity: 0.5, blur:1, color:"white"}); 
   //$("li a").dropShadow({left: -1, top: -1, opacity: 0.5, blur: 0}); 
	
	if (BrowserDetect.browser == "Firefox"){
		$("#slogan_title").css("top","0px");
		$("#slogan_title").animate({"right": "-=1280px"}, 5000);
	}	
	else{
		$("#slogan_title").animate({"right": "-=700px"}, 5000);
	}
	var x = Math.floor(Math.random() * animFunc.length);
	var randAnim = animFunc[x - 1];

   //$("#slogan").animate({right:"-200px"},5000, randAnim);
   
   //$("#slogan").effect("explode",{},15000, callback );
	//$("#slogan").typewriter();
	//$("#slogan").unscramble();
	//$('#slogan').jTypeWriter();
	//$('#slogan').jTypeWriter({duration:6.5,type:"words"});
	//$('#slogan').jTypeWriter({sequential:false, loop:true, loopDelay:5});
	//$('#slogan').jTypeWriter({sequential:false,loop:true});
	//$('#slogan').texteffects({ "texteffect": "unexplode", "speed": "slow", "delay": "3000" });

	
}); 


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



//callback function to bring a hidden box back
		function callback(){
			setTimeout(function(){
				$("#slogan:hidden").removeAttr('style').hide().fadeIn();
			}, 1000);
}

		

