
var $j = jQuery.noConflict();

$j.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $j.getUrlVars()[name];
  }
});

$j(	function(){
	
	// Flowplayer+Fancybox setup
	flowplayer("a.player", "/Websites/tcmw/templates/TC_Layout/flowplayer/flowplayer-3.1.2.swf", {

	clip: {
		// track start event for this clip
		onStart: function(clip) {
			
			_gaq.push(['_trackEvent', "Videos", "Play", clip.url]);
			
		},

		// track pause event for this clip. time (in seconds) is also tracked
		onPause: function(clip) {
			
			_gaq.push(['_trackEvent', "Videos", "Pause", clip.url, parseInt(this.getTime())]);
						
		},

		// track stop event for this clip. time is also tracked
		onStop: function(clip) {
			
			_gaq.push(['_trackEvent', "Videos", "Stop", clip.url, parseInt(this.getTime())]);
			
		},

		// track finish event for this clip
		onFinish: function(clip) {
			
			_gaq.push(['_trackEvent', "Videos", "Finish", clip.url]);
			
			
		}
	}
});
	$j('a.vid').fancybox({
		
		'overlayOpacity'	:	.8,
		'overlayColor' : "#000",
		
	});	
	
	
			
	//Vertical Sliding rollovers
	$j('div.hpP').hover(function(){
					$j(".hpPwrap", this).stop().animate({top:'0px'},{queue:false,duration:300});
				}, function() {
					$j(".hpPwrap", this).stop().animate({top:'100px'},{queue:false,duration:300});
	});
	
	
	//If load in url
	var load = $j.getUrlVar('load');
	if(load == "1"){
	$j('a.webgenius').trigger('click');
	}

});
// Flash call to fancybox+flowplayer
function rethinkVideo(){$j('a.rethink').trigger('click'); }



//Newslettersignup redirect
function change_parent_url(url)
        {
	    document.location=url;
        }
