var fuente_usuario=0;

$(document).ready(function()
	{
		setUserDivContentFontSize();


	}
);

function openWindow(href,target,width,height)
{
    var w = window.open(href, target, "width="+width+",height="+height+",resizable=yes,scrollbars=0");
    if (!w)
   	{
   		return true;
   	}

    w.focus();

    //return w.closed;
}

function showScreenRes()
{
	 alert('Screen Resolution Is '+self.width+' by '+self.height);
}

function showWindowRes()
{
	// Simple Browser Check
	var moz = (document.getElementById && !document.all) ? 1 : 0;

	var width = (moz) ? window.innerWidth : document.body.clientWidth;
	var height = (moz) ? window.innerHeight : document.body.clientHeight;

	alert('Window Resolution Is '+width+' by '+height);
}

function resizeContent()
{
	var div = document.getElementById('content');

	var moz = (document.getElementById && !document.all) ? 1 : 0;

	var width = (moz) ? window.innerWidth : document.body.clientWidth;
	var height = (moz) ? window.innerHeight : document.body.clientHeight;

	showWindowRes();

	if (width > 900 || height > 650)
	{
		div.style.fontSize='12px';
		return;
	}
}

function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
	{
		var y = x.currentStyle[styleProp];
	}
	else if (window.getComputedStyle)
	{
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	}
	return y;
}

function setUserDivContentFontSize()
{
	//Recuperamos de cookie size de fuente y line-heigth
	var font_size = CNMGetCookie('dc_font_size');
	var line_height = CNMGetCookie('dc_line_height');

	//En caso de no existir-->nos vamos
	if (font_size == undefined)
	{
		return
	}

	if (line_height == undefined)
	{
		return
	}

	//Establecemos tamaños de div_content a los guardados en las cookies
	CNMSetFontSize('div_content',font_size);
	CNMSetLineHeight('div_content',line_height);
}


function increaseFontSize()
{
	CNMIncreaseFontSize('div_content',2);
	CNMIncreaseLineHeight('div_content',2);

	//Recuperamos y guardamos en cookie
	var new_font_size = CNMGetFontSize('div_content');
	CNMSetCookie('dc_font_size',new_font_size);

	//Recuperamos y guardamos en cookie
	var new_line_height = CNMGetLineHeight('div_content');
	CNMSetCookie('dc_line_height',new_line_height);
}

function decreaseFontSize()
{
	CNMDecreaseFontSize('div_content',2);
	CNMDecreaseLineHeight('div_content',2);

	//Recuperamos y guardamos en cookie
	var new_font_size = CNMGetFontSize('div_content');
	CNMSetCookie('dc_font_size',new_font_size);

	//Recuperamos y guardamos en cookie
	var new_line_height = CNMGetLineHeight('div_content');
	CNMSetCookie('dc_line_height',new_line_height);
}

function submitCNMForm(form_id, action_id, action_value)
{
	var sform=document.getElementById(form_id);
	var cnmaction=document.getElementById(action_id);

	cnmaction.value=action_value;

	sform.submit();
}



function check()
{
		//Chequeo de inputs text
	    var input_node_list = document.getElementsByTagName('input');

		for (var i = 0; i < input_node_list.length; i++)
		{
          var input_node = input_node_list[i];

          if (input_node.getAttribute('type') == 'text')
          {
          	var aid = input_node.getAttribute('id');
          	var eid = document.getElementById(aid);

          	if ($(eid).css("display") != 'none')
          	{

             	if (input_node.value.length == 0 )
              	{
              		showCheckAlert();
              		return false;
              	}
          	}
          }
      	}

      	//Chequeo de selects
	    var select_node_list = document.getElementsByTagName('select');

		for (var i = 0; i < select_node_list.length; i++)
		{
	        var select_node = select_node_list[i];
       		var indice = select_node.selectedIndex;
    		var texto = select_node.options[indice].text;

             if (texto == "..." )
             {
             	showCheckAlert();
             	return false;
             }
      	}

      	//Chequeo de inputs radio
	    var radio_node_list = document.getElementsByTagName('input');

		for (var i = 0; i < radio_node_list.length; i++)
		{
          var radio_node = radio_node_list[i];

          if (radio_node.getAttribute('type') == 'radio')
          {
          		var radio_node_name_list = document.getElementsByName(radio_node.name);
          		var selected=false;
          		for (var j = 0; j < radio_node_name_list.length; j++)
          		{
          			var radio_node_name = radio_node_name_list[j];
					selected=radio_node_name.checked;

					if (selected)
					{
						break;
					}
          		}

          		if (!selected)
          		{
          			showCheckAlert();
          			return false;
          		}
          }
      	}



		return true;
}

function showDescProf()
{
	document.getElementById('LDESCFUTPROF').style.display="block";
	document.getElementById('DESCFUTPROF').style.display="block";
}

function hideDescProf()
{
	document.getElementById('LDESCFUTPROF').style.display="none";
	document.getElementById('DESCFUTPROF').style.display="none";
}



/**
*
*
**/
function showGuardarForm()
{

	if (document.getElementById('print')!=null)
	{
		window.location='#print';
	}

	var window_props="x=200;y=200;w=400;h=180";
	CNMSubmitAjaxParams(null,'showGuardarForm', CNMMODALPOPUP, window_props);
}

function goGuardar(form)
{
	//Si guardar, submit normal , pues nos devolverá un binary
	form.submit();
	CNMHideModalPopUp();
}

function showRestaurarForm()
{
	var window_props="x=200;y=150;w=400;h=220";
	CNMSubmitAjaxParams(null,'showRestaurarForm', CNMMODALPOPUP, window_props);

}

function goRestaurar(form)
{
	//Si restaurar, CNMSubmitAjaxForm2, indicado para files
	//CNMSubmitAjaxForm2(form,CNMMODALPOPUP_BODY,null);
	//CNMSubmitAjaxForm2(form,"body");
	//CNMHideModalPopUp();
	form.submit();
	//window.location.reload();
}

function showGlosario()
{
	var w_props="height=600,width=800,resizable=1,scrollbars=1,left=100,top=50";
	CNMSubmitParams(null, "showGlosari", true, '', w_props);
}


