var server = new getConf();

var localhost 	= server.documentroot;
var appPath 	= server.apppath;

var uri 		= window.location.href;
var total_url	= localhost + appPath;
var length_url	= total_url.length;
var tmpLayer 	= uri.substr(length_url,10000);
var lang 		= tmpLayer.split("/");

var loader = new Image();
	loader.src = localhost + appPath + 'basic/img/loaders/ajax-longbar.gif';

$(document).ready(function() {
	//loadAjaxMenu();
	loadAjaxRelated();
	execForm();
	
	startPlayer();
	//$("div.items").playlist(localhost + appPath + "basic/test/FlowPlayerLight.swf", {initialScale:'scale', controlsOverVideo: 'ease'}, {loop:false});
	$("div.playlist").scrollable({size:2, horizontal: true });
			// setup scrolling
			//$("div.playlist").scrollable({size:2});	
			
});

function startPlayer(){
	// Flowplayer configuration (less buttons and wicked background color) 
var playerConfig = { 
   controlBarBackgroundColor: '0x99cddc', 
   initialScale:'scale',
   controlsOverVideo: 'ease',
   controlBarGloss:'high',
   allowScriptAccess: "always"
} 
  

 
   // variable that holds the player API. it is initially null 
   var flowplayer = null;  
	
	$('.items a').click(
						  
	function(){
		playerConfig.videoFile = this.href;
		$('#player').empty();
		if (flowplayer == null) { 
			flowplayer = flashembed("player",  {src: localhost + appPath + "basic/test/FlowPlayerLight.swf", bgcolor:'#6F7485'}, {config: playerConfig});
		
		 } else {     
            	//flowplayer.setConfig(playerConfig);  
				
				flowplayer = flashembed("player",  {src: localhost + appPath + "basic/test/FlowPlayerLight.swf", bgcolor:'#6F7485'}, {config: playerConfig});
         }
		 
		 return false;
	})
	
	//$('#player').click(function(){ $('.items a:eq(1)').click() });

}

function loadAjaxMenu(){

	var loaderHTML = '<div id="loader">Loading...&nbsp;&nbsp;&nbsp;<img src="' + loader.src + '" alt="Loading" /></div>';
	$('#tabs a').click(

		function (){

			if(this.href == localhost + appPath+'home'){ return true };

			var a = $(this);
			$('#tabs span').attr('class', '');
			a.children().attr('class', 'current');

			$('#content_main').html(loaderHTML);

			//if(locationlocalhost + appPath+'home')
			$('#content').load( a.attr('href')+' #brd','',
				function(){	loadAjaxRelated(); }
			);
			return false;
		});
}

function loadAjaxRelated(){
	loadAjaxCategoryLinks();
	loadAjaxLayers('more');

}

function loadAjaxCategoryLinks(){
	$('.content_category a').click(function (){ var href = this.href; $('#content').load( href+' #brd','', function(){ loadAjaxLayers('more'); }); return false; });
}

function loadAjaxLayers(selector){
	$("a."+selector).each(function(){
		this.href = this.href+'#content';
		this.onclick = function() {
			hs.minWidth = 915;
			return hs.htmlExpand(this, { objectType: 'ajax', preserveContent: true } );
		}
	});
}

hs.registerOverlay({
	thumbnailId: null,
	overlayId: 'controlbar',
	position: 'top right',
	hideOnMouseOut: false
});

hs.Expander.prototype.onAfterExpand = function () {
	$('.highslide-body a').click(function(){
		//this.href = this.href+'#content';
		$('.highslide-body').load(this.href+' #content_wrap');
		return false;
	});
										
										
				
	
/*	
	$('#content_side a').each(function(){ 
		this.href = this.href+'#content';
		this.onclick = function() { 
			return hs.htmlExpand(this, { objectType: 'ajax', preserveContent: true } );
		}
	});	
	*/
}

hs.Expander.prototype.printHtml = function () {
	var pw = window.open("about:blank", "_new");
	pw.document.open();
	pw.document.write(this.getHtmlPrintPage());
	pw.document.close();
	return false;
};

hs.graphicsDir = localhost + appPath +'basic/js/highslide/graphics/';
hs.restoreCursor = 'zoomout.cur'; // necessary for preload
hs.expandSteps = 10; // number of steps in zoom. Each step lasts for duration/step milliseconds.
hs.expandDuration = 250; // milliseconds
hs.restoreSteps = 10;
hs.restoreDuration = 250;
hs.marginLeft = 15;
hs.marginRight = 15;
hs.marginTop = 15;
hs.marginBottom = 15;
hs.zIndexCounter = 1001; // adjust to other absolutely positioned elements
hs.restoreTitle = 'Click to close image; click and drag to move. Use arrow keys for next and previous.';
hs.loadingText = 'Loading...';
hs.loadingTitle = 'Click para cancelar';
hs.loadingOpacity = 0.75;
hs.focusTitle = 'Click to bring to front';
hs.allowMultipleInstances= false;
hs.numberOfImagesToPreload = 5;
hs.captionSlideSpeed = 1; // set to 0 to disable slide in effect
hs.padToMinWidth = true; // pad the popup width to make room for wide caption
hs.outlineWhileAnimating = 2; // 0 = never; 1 = always; 2 = HTML only
hs.outlineStartOffset = 3; // ends at 10
hs.fullExpandTitle = 'Expand to actual size';
hs.fullExpandPosition = 'bottom right';
hs.fullExpandOpacity = 1;
hs.showCredits = false; // you can set this to false if you want
hs.creditsText = '';
hs.creditsHref = '';
hs.creditsTitle = '';
hs.enableKeyListener = true;

// HTML extension
hs.previousText = 'Previous';
hs.nextText = 'Next';
hs.moveText = '[ Mover Ventana ]';
hs.closeText = '[ Cerrar ]';
hs.closeTitle = 'Click para cerrar';
hs.resizeTitle = 'Resize';
hs.allowWidthReduction = false;
hs.allowHeightReduction = true;
hs.preserveContent = true; // Preserve changes made to the content and position of HTML popups.
hs.objectLoadTime = 'before'; // Load iframes 'before' or 'after' expansion.
hs.cacheAjax = true; // Cache ajax popups for instant display. Can be overridden for each popup.

// These settings can also be overridden inline for each image
hs.captionId = null;
hs.spaceForCaption = 30; // leaves space below images with captions
hs.slideshowGroup = null; // defines groups for next/previous links and keystrokes
hs.minWidth= 200;
hs.minHeight= 200;
hs.allowSizeReduction= true; // allow the image to reduce to fit client size. If false; this overrides minWidth and minHeight
hs.outlineType = 'rounded-white'; // set null to disable outlines
hs.wrapperClassName = 'highslide-wrapper'; // for enhanced css-control
hs.captionEval = 'this.thumb.title';