/* Fnciones javascript.
*/
var vistaprevia = 0;
var num =1;
var xxUA=navigator.userAgent.toLowerCase();
var ima_estrellaselect = new Image;
ima_estrellaselect.src="faceimage/estrella_select20x20.gif";
var ima_estrellaunselect = new Image;
ima_estrellaunselect.src="faceimage/estrella_unselect20x20.gif";
function formHandler(form){
var URL = form.site.options[form.site.selectedIndex].value;
window.location.href = URL;
}

function cambiar_color_over(celda){
	celda.style.color="#ff0000";
} 
function cambiar_color_out(celda){
	//celda.style.backgroundColor="#ffffff";
	celda.style.color="#0165aa";
} 

function Cambio_sitio_over(obj,cual){
	document.getElementById("contact_img1").style.background = "url(faceimage/frente_site_151x101.gif)";
	document.images[obj].src=ima_estrellaselect.src;
	if( cual == 1 ){
		document.getElementById("contact_img2").style.background = "url(faceimage/dir_site1_151x101.gif)";
	}
	else{
		document.getElementById("contact_img2").style.background = "url(faceimage/dir_site2_151x101.gif)";
	}
}
function Cambio_sitio_out(obj,cual){
	document.images[obj].src=ima_estrellaunselect.src;
	if( cual == 1 ){
		document.getElementById("contact_img2").style.background = "url(faceimage/dir_site1_151x101.gif)";
		document.getElementById("contact_img1").style.background = "url(faceimage/frente_site1_151x101.gif)";
	}
	else{
		document.getElementById("contact_img2").style.background = "url(faceimage/dir_site2_151x101.gif)";
		document.getElementById("contact_img1").style.background = "url(faceimage/frente_site2_151x101.gif)";
	}
}

// CALLBACK, CALLED WHEN A DAY IS CLICKED
function cb(date)
{
  document.getElementById("date").value=date;
  document.getElementById("bod").style.visibility="hidden";
}
function cb2(date)
{
  document.getElementById("date2").value=date;
  document.getElementById("bod2").style.visibility="hidden";
}

function LoadDe()
{  // CREATES THE CALENDAR
  //   Calendar( <starting year>, <ending year> );
  var cal = new Calendar(2006,2010);

  // SET THE CALLBACK, NOT NEEDED.. BUT USEFUL
  cal.callback = cb;

  // SET THE SELECTED DATE
  cal.setSelectedDate(Date());

  // PUTS THE CALENDAR ON THE DESIRED ELEMENT
if( num < 2 ){  document.getElementById("bod").appendChild(cal.get()); num = 8;}
    document.getElementById("bod").style.visibility="visible";
	document.getElementById("bod").style.Left=0;
	document.getElementById("bod").style.Top=0;
}
function LoadHasta()
{  // CREATES THE CALENDAR
  //   Calendar( <starting year>, <ending year> );
  var cal = new Calendar(2006,2010);

  // SET THE CALLBACK, NOT NEEDED.. BUT USEFUL
  cal.callback = cb2;

  // SET THE SELECTED DATE
  cal.setSelectedDate(Date());

  // PUTS THE CALENDAR ON THE DESIRED ELEMENT
if( num < 2 ){  document.getElementById("bod2").appendChild(cal.get()); num = 8;}
    document.getElementById("bod2").style.visibility="visible";
	document.getElementById("bod2").style.Left=0;
	document.getElementById("bod2").style.Top=0;
}

function HabilitarCampos(formu){
var fo = document.getElementById(formu);
if(fo.actualizarseccion.checked){
	fo.nombreseccion_mod.disabled=false;
	fo.descripcionseccion_mod.disabled=false;
	fo.seccion_estado_mod.disabled=false;
}
else{
	fo.nombreseccion_mod.disabled=true;
	fo.descripcionseccion_mod.disabled=true;
	fo.seccion_estado_mod.disabled=true;
}
}
function HabilitarCamposMarca(formu){
var fo = document.getElementById(formu);
if(fo.actualizarmarca.checked){
	fo.nombremarca_mod.disabled=false;
	fo.descripcionmarca_mod.disabled=false;
	fo.marca_estado_mod.disabled=false;
}
else{
	fo.nombremarca_mod.disabled=true;
	fo.descripcionmarca_mod.disabled=true;
	fo.marca_estado_mod.disabled=true;
}
}
function HabilitarCamposModelo(formu){
var fo = document.getElementById(formu);
if(fo.actualizarmodelo.checked){
	fo.modelo_estado_mod.disabled=false;
	fo.nombremodelo_mod.disabled=false;
	fo.descripcionmodelo_mod.disabled=false;
}
else{
	fo.modelo_estado_mod.disabled=true;
	fo.nombremodelo_mod.disabled=true;
	fo.descripcionmodelo_mod.disabled=true;
}
}

function HabilitarCamposAno(formu){
var fo = document.getElementById(formu);
if(fo.actualizarmodelo.checked){
	fo.nombremodelo_mod.disabled=false;
	fo.descripcionmodelo_mod.disabled=false;
}
else{
	fo.nombremodelo_mod.disabled=true;
	fo.descripcionmodelo_mod.disabled=true;
}
}

function HabilitarCamposPais(formu){
var fo = document.getElementById(formu);
if(fo.actualizarpais.checked){
	fo.nombrepais_mod.disabled=false;
	fo.descripcionpais_mod.disabled=false;
}
else{
	fo.nombrepais_mod.disabled=true;
	fo.descripcionpais_mod.disabled=true;
}
}

function HabilitarCamposLugar(formu){
var fo = document.getElementById(formu);
if(fo.actualizarlugar.checked){
	fo.nombrelugar_mod.disabled=false;
	fo.descripcionlugar_mod.disabled=false;
}
else{
	fo.nombrelugar_mod.disabled=true;
	fo.descripcionlugar_mod.disabled=true;
}
}
function HabilitarCamposLote(formu){
var fo = document.getElementById(formu);
if(fo.actualizarlote.checked){
	fo.nombrelote_mod.disabled=false;
	fo.descripcionlote_mod.disabled=false;
	fo.lote_estado_mod.disabled=false;
}
else{
	fo.nombrelote_mod.disabled=true;
	fo.descripcionlote_mod.disabled=true;
	fo.lote_estado_mod.disabled=true;
}
}

function HabilitarCamposnuevoarticulo(formu){
var fo = document.getElementById(formu);
if(fo.actualizarnuevoarticulo.checked){
	fo.nombrenuevoarticulo_mod.disabled=false;
	fo.descripcionnuevoarticulo_mod.disabled=false;
	fo.nuevoarticulo_estado_mod.disabled=false;
}
else{
	fo.nombrenuevoarticulo_mod.disabled=true;
	fo.descripcionnuevoarticulo_mod.disabled=true;
	fo.nuevoarticulo_estado_mod.disabled=true;
}
}
function AumentarImagen(divv,valor){ 

	patron1 = /.gif$/;
	patron2 = /.jpg$/;
	patron3 = /.jpeg$/;
	patron4 = /.GIF$/;
	patron5 = /.JPG$/;
	patron6 = /.JPEG$/;
	if( valor !="" && valor != " " )
	if ( !patron1.test(valor) && !patron2.test(valor) && !patron3.test(valor) && !patron4.test(valor) && !patron5.test(valor) && !patron6.test(valor) )
		alert("Solo se permiten archivos de imagen con las extensiones: jpeg,jpg y/o gif");
	if (document.all && xUA.indexOf('msie')!=-1){
	 document.getElementById(divv).style.visibility ="hidden";
	 document.getElementById(divv).style.visibility ="visible";}
}
function MostrarVistaPrevia(objima,objfile){
	var ele = document.getElementById(objima);
	var dir = document.getElementById(objfile);
	alert("aca:"+dir.imagenuevoarticulo1.value);
	ele.src = 'file:///'+dir.imagenuevoarticulo1.value;
		

}

function muestraReloj()
{ 
// Compruebo si se puede ejecutar el script en el navegador del usuario
if (!document.layers && !document.all && !document.getElementById) return;
// Obtengo la hora actual y la divido en sus partes
var fechacompleta = new Date();
var horas = fechacompleta.getHours();
var minutos = fechacompleta.getMinutes();
var segundos = fechacompleta.getSeconds();
var mt = "AM";
// Pongo el formato 12 horas
if (horas > 12) {
mt = "PM";
horas = horas - 12;
}
if (horas == 0) horas = 12;
// Pongo minutos y segundos con dos dígitos
if (minutos <= 9) minutos = "0" + minutos;
if (segundos <= 9) segundos = "0" + segundos;
// En la variable 'cadenareloj' puedes cambiar los colores y el tipo de fuente
cadenareloj = "<font size='1' face='verdana' ><b>" + horas + ":" + minutos + ":" + segundos + " " + mt + "</b></font>";
// Escribo el reloj de una manera u otra, según el navegador del usuario
if (document.layers) {
document.layers.spanreloj.document.write(cadenareloj);
document.layers.spanreloj.document.close();

}
else if (document.all){ spanreloj.innerHTML = cadenareloj;

}
else if (document.getElementById){ document.getElementById("spanreloj").innerHTML = cadenareloj;

}
// Ejecuto la función con un intervalo de un segundo
setTimeout("muestraReloj()", 1000);
}