$.fn._blank = function() {

	function clickHandler(e) {

		if (e.ctrlKey || e.shiftKey || e.metaKey)
			return;

		var w = window.open(this.href, '_blank', 'top=0,left=0,width=230,height=350');
		if (w && !w.closed) {
			w.focus();
			e.preventDefault();
		}
	}

	this
		.filter('a[@href]')
		.bind('click', clickHandler);

	return this;

}

function addFlash() {
   var params = {
   	quality: "high",
   	scale: "noscale",
   	wmode: "window",
   	allowscriptaccess: "always",
   	bgcolor: "#000000",
   	allowFullScreen: 'true'
   };
   var flashvars = {
   };
   var attributes = {id:"flash"};
   swfobject.embedSWF("media/swf/dedoce.swf", "flash", "600", "300", "10.0.0", "media/swf/expressinstall.swf", flashvars, params, attributes);
}


addFlash();


function menu() {
   var pos = new Array('-126px 0', '-260px 0', '-389px 0', '-517px 0');
   
   $('#menu li a').each(function() {
      var i = $(this).parent().attr('id').substring(1,2);
      
      if($(this).attr('class') == 'activo'){
         activo = pos[i];
         $(this).parent().parent().css('background-position', activo);
      }
      
       $(this).hover(
         function () {
            $(this).parent().parent().css('background-position', pos[i]);
         }, 
         function () {
            $(this).parent().parent().css('background-position', activo);
         }
       );
       
   });
}



$('document').ready(function(){

   menu();

   $("a[rel*='external']").click(function(){
        this.target = "_blank";
    });

   $('a.reel').click(function(){
      var src = location.href+"/portafolio";
      $.modal('<iframe src="' + src + '" height="300" width="600" style="border:0" frameborder="0" scrolling="no">', {
         onOpen: function (dialog) {
         	         dialog.overlay.fadeIn('slow', function () {
                        dialog.data.hide();
                        dialog.container.fadeIn('slow', function () {
                           dialog.data.show();
                        });
      		         });
      		      }
         ,
         onClose: function (dialog) {
         	         dialog.container.fadeOut('slow', function () {
                        dialog.data.hide();
                        dialog.overlay.fadeOut('slow', function () {
                           $.modal.close();
                        });
      		         });
      		      }
         ,
         overlayCss: {backgroundColor:"#000"},
         opacity:100,
         containerCss:{
         		backgroundColor:"#000",
         		borderColor:"#000",
         		height:300,
         		padding:0,
         		width:600
         	},
          closeHTML: "<a href='#'>x</a>"
      
      });
      return false;
   
   });   
   
   
});
