ns = (document.layers)? true:false
ie = (document.all)? true:false


function checkForm(tipo){

	
	if(tipo == "productos"){
	
	var FieldCheck = new Array("ext_idprov","nombre","descripcion","stock","preciobase");
	TheForm = document.productos;
	diselement = "anadir";
	}else if(tipo == "proveedores"){
	var FieldCheck = new Array("proveedor","dominio","email","minpedido");
	TheForm = document.proveedores;
	diselement = "enviar";
	}


	for(i=0;i < FieldCheck.length;i++){
		var tmpvar = 1;

		eval("if(TheForm." + FieldCheck[i] + ".value ==\"\"){tmpvar = 0;alert(\"Debes rellenar este campo\");TheForm."+FieldCheck[i]+".focus();FieldCheck = FieldCheck.length;TheForm."+FieldCheck[i]+".className = 'CheckThisField'}else{TheForm."+FieldCheck[i]+".className = '';}");
	}
	if(typeof(tmpvar) != "undefined" && tmpvar != '0'){
	disableFormAlta(tipo,diselement);
	TheForm.submit();
	};


}

<!--
function DisplayImage(picURL,picWidth,picHeight){

newWindow=window.open(picURL,'newWin','toolbar=no,width='+picWidth+',height='+picHeight)
newWindow.window.status = "Cargando Fotografia";
newWindow.document.write('<html><head><\/head><body background="'+picURL+'" onload=self.status = \' \'><\/body><\/html>')

newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
newWindow.focus()
}
//-->

function confirmSubmit(){
	
	var agree=confirm("Are you sure you wish to continue?");
	if (agree){
		return true ;
	}else{
		return false ;
	}

		
}


function changeskin(thisobject){
	thisobject.form.submit();
	//show_props(thisobject,"objecto")
	}


function makeobj(){

	if(arguments.length %2 !=0){

		arguments.length[arguments.length] = "";
	}
	for(var i=0; i < arguments.length; i +=2){

		this[arguments[i]] = arguments[i + 1];
	}
	return this;
}

// HIDE ELEMENT


function ObjgetElement(name){

eval(" var f = document.all ? document.all." + name + ": document.getElementById('" + name + "');");
return f
}

function switchVisible(objectElement,visible){


if (document.layers)
    document.hide.visibility = hide ? 'hide' : 'show';
  else {
    g = ObjgetElement(objectElement);

   g.style.visibility = visible;
   // show_props(g.style, "g")



  }


}


function hideShowGods(nohide,hide,thiselement) {

  //show_props(thiselement, "g")
  if(ns){
  	visib = "show"
  	novisib = "hide"
	}
	else
	{
		visb = "visible"
		novisb = "hidden"

	};


(thiselement.checked == true)?(visibility = visb):(visibility = novisb)
 switchVisible(thiselement.value,visibility)
 switchVisible(hide,novisb)

disableFormAlta('altas','nbtcompe')
disableFormAlta('altas','nbtrazon')
disableFormAlta('altas','tipoproy')

if(thiselement.checked == true){

	  if(thiselement.value == "NBTganado"){
	  EnableFormAlta('altas','tipoproy')
	  document.altas.NBTperd.checked = false
	  }else{

	 EnableFormAlta('altas','nbtcompe')
	  EnableFormAlta('altas','nbtrazon')
	  document.altas.NBTganad.checked = false
	  }
 }

}

// HIDE ELEMENT


function disableFormAlta(formName,element){

var B_Obj = eval("document." + formName + "." + element)
B_Obj.disabled=true;
}
function EnableFormAlta(formName,element){

var B_Obj = eval("document." + formName + "." + element)
B_Obj.disabled=false;
}

function InitPageAlta(){

disableFormAlta('altas','vmpc')
disableFormAlta('altas','vapc')
disableFormAlta('altas','vmini')
disableFormAlta('altas','vaini')
disableFormAlta('altas','vmfin')
disableFormAlta('altas','vafin')
disableFormAlta('altas','vformaCon')
disableFormAlta('altas','vcliente')
disableFormAlta('altas','vsector')
disableFormAlta('altas','nbtcompe')
disableFormAlta('altas','nbtrazon')
disableFormAlta('altas','tipoproy')
return true
}

function show_props(obj, obj_name) {
          alert("");
		  var result = "";
		  for (var i in obj)
		  result += obj_name + "." + i + " = " + obj[i]+ "\n";

		  document.write(result);
}

	if(typeof mensaje != "undefined"){

	  Mensaje(mensaje);

	}

/*
	function checkForm(thisform)
	{
	  if(thisform.user.value == ""){
		alert("El campo usuario no puede estar vacio");
		return false
		  }
	  if(thisform.password.value == "" || thisform.repassword.value == ""){
		alert("El campo password no puede estar vacio");
		return false
		  }else if(thisform.password.value != thisform.repassword.value){
		  alert("Las Contraseņas no coinciden");
		return false
		  }
	  if(thisform.email.value == ""){
		alert("El campo email no puede estar vacio");
		return false
		  }


	  thisform.submit();
	  return true;

	}
*/
	function Mensaje(data)
	{

	  alert(data);
	}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function mainrefresh()
{
opener.location.reload(true)

}
