$(document).ready(function() {
	Shadowbox.init({skipSetup: true});
	if($('#dejavu_box_content').length  > 0) {
		$('#dejavu_box_content').animate({opacity:0},2);
		var dejavu = function() {
			$('#dejavu_box_content').animate({opacity:1},1);
			write_swf({
				file:'player.swf',
				width:800,
				height:600,
				id:'dejavu_box_content',
				flashVars:$("#dejavu_box_content").attr('lang')
			});
		}
		setTimeout(dejavu,1);
	}
	if($("#portfolio").length > 0) {
		write_swf({
			file:'clientes.swf',
			width:750,
			height:500,
			id:'portfolio',
			flashVars: $("#portfolio").attr('lang')
		});
	}
	if($("#intro").length > 0) {
		write_swf({
			file:'intro.swf',
			width:415,
			height:116,
			id:'intro'
		});
	}
	
	if($("#box_wallpapers").length > 0) {write_swf({file:'wallpapers.swf',width:800,height:600,id:'box_wallpapers',flashVars:$("#box_wallpapers").attr('lang')});}	
	if($("#box_videos").length > 0) {write_swf({file:'videos.swf',width:800,height:500,id:'box_videos',flashVars:$("#box_videos").attr('lang')});}
	if($("#box_animaciones").length > 0) {write_swf({file:'animaciones.swf',width:800,height:600,id:'box_animaciones',flashVars:$("#box_animaciones").attr('lang')});}
	
	if($("#header_logo").length > 0) {
		write_swf({
			file:'top.swf',
			width:415,
			height:116,
			id:'header_logo'
		});
	}
	
	if($("#header_dejavu").length > 0) {
		write_swf({
			file:'cat.swf',
			width:102,
			height:116,
			id:'header_dejavu'
		});
	}	
	
	if($("#credits_subfooter").length > 0) {
		write_swf({
			file:'sub_footer.swf',
			width:720,
			height:75,
			id:'credits_subfooter'
		});
	}
	if($("#credits_footer").length > 0) {
		write_swf({
			file:'footer.swf',
			width:750,
			height:25,
			id:'credits_footer'
		});
	}	
	if($("#frm_contact").length > 0) {
		$('#frm_contact').validate();
		$(':text ,textarea').each(function() {
			$(this).addClass('input1');
			$(this).focus(
				function() {
					$(this).addClass('input1_hover');
				}
			);
			$(this).blur(
				function() {
					$(this).removeClass('input1_hover');
				}
			);
		});
	}
});

function display(gallery,content,type,width,height) {
    Shadowbox.open({
        title:      (title_items[gallery])?title_items[gallery]:'',
        type:       type,
        desc:			desc_items[gallery],
        content:    content,
        width:	width,
        height:	height
    });	
}

function write_swf(params) {
	if($("#"+params.id).length > 0) {
		var flashDial = new FlashObject(params.file, "xmdial", params.width, params.height, 8, "#000000", "high", "http://www.adobe.com/go/getflashplayer", "http://www.adobe.com/go/getflashplayer");
	    flashDial.addParam("wmode", "opaque");
	    if(typeof params.flashVars != 'undefined') {
	    	flashDial.addParam("flashVars", "lang="+params.flashVars);
	    }
	    flashDial.addParam("allowScriptAccess", "always");
	    flashDial.addParam("autoStart", "true");
	    flashDial.write(params.id);
	}
}