$(document).ready( function(){
    var MEDIA_URL = $('meta[name="media_url"]').attr('content');
	ie6 = false;
    version = navigator.appVersion;
    num_version = version.match(/(\d)/g);
    if ( $.browser.msie) {
        if ( num_version[2] < 7){
			var url_pixel = MEDIA_URL + 'jscripts/jquery/ifixpng/pixel.gif';
            $.ifixpng(url_pixel);
            $('img[src$=.png]').ifixpng();
            $('input[src$=.png]').ifixpng();
			big_frame_url = MEDIA_URL + 'jscripts/jquery/bgiframe_2.1.1/jquery.bgiframe.min.js'
			var bigframe = $("<script>").attr("type", "text/javascript").attr("src", big_frame_url);
			$("head").append(bigframe);
			ie6 = true;
        }
    }

    $('h1').click(function(){
        window.location = '/';
    });

    $('input, textarea').focus(function(){
        $(this).select();
    })
    
	if($.fn.fancybox){
		$('a.fancy').fancybox({
    	    frameHeight:1000,
            padding:'5px'
	    });
	}
	
	$('a.nuevaVentana').click(function(){
        window.open(this.href);
        return false;
    });
    
    var openNL = false;    
	//if ($('#solicitudNLTTForm').hasClass('open')){
        //var openNL = true;
    //}
    //
    var hash = window.location.hash;
    if (hash=='#inscribirNL'){
        window.scrollTo(0, 0);
        var openNL = true;
    }
    var dialogoNL = $('#inscribirNL').dialog({
        width: 500,
        modal: true,
        autoOpen: openNL,
        resizable: false,
		bgiframe:ie6,
        title: $("div#inscribirNL h3").text()
    });
    $('a.inscribirNL').click(function(){
        dialogoNL.dialog('open');
        return false;
    });
    var dialogoRecomendar = $('#recomendarWeb').dialog({
        width: 500,
        modal: true,
        autoOpen: false,
        resizable: false,
		bgiframe:ie6,
        title: $("div#recomendarWeb h3").text()
    });
    $('a.recomendar_web').click(function(){
        dialogoRecomendar.dialog('open');
        return false;
    });
    
    $("link[rel=stylesheet]").eq(0).before('<link rel="stylesheet" type="text/css" href="' + MEDIA_URL + 'jscripts/jquery/jquery-ui-1.7.1.custom/css/custom-theme/jquery-ui-1.7.1.custom.css" />');
});
