jQuery.noConflict();

function toggleClass ( object, className ) {
	realClass = object.className; 
	newClass = ' ' + realClass + ' '; 
	newClass = newClass.replace(' ' + className + ' ', ' ');
	if ( newClass == ' ' + realClass + ' ') {
		newClass = newClass + ' ' + className;
	}
	object.className = newClass;
}

function hrefToOnClick ( anchor, action ) {
	var href = anchor.href;
	anchor.href = "javascript: void(0);";
	anchor.onclick = action;
	
	return href;
}

function targetToPopup () {

	var linkNodes = document.getElementsByTagName( 'a' );
	for ( var i=0; i < linkNodes.length; i++ ) {
		var linkNode = linkNodes[ i ];
		if ( (target = linkNode.getAttribute( 'target' )) && (target != '_self')  ) {
	
			var href = linkNode.getAttribute( 'href' );
			linkNode.oldHref = href;
			linkNode.onclick = function() {
				window.open( this.oldHref, target, "width=700,height=520,scrollbars=yes" ).focus();
			}
			linkNode.removeAttribute( 'target' );
			linkNode.setAttribute( 'href' , 'javascript: void(0);');
		}
	}
}


jQuery(function($){
	
	function videoOverlay() {
		var videoPlayer = flowplayer("video", "flash/flowplayer-3.2.2.swf");

		$("body").append($(".overlay"));
		
		$("#videoControl").overlay({
			expose: {
				color: '#000',
				loadSpeed: 200,
				opacity: 0.9
			},
			
		    onLoad: function() { 
				videoPlayer.load(); 
		    }, 
		     
		    onClose: function() { 
		    	videoPlayer.unload(); 
		    } 
		});
	}
	
	targetToPopup(); 
	videoOverlay();
});

