function check(c){
  var msg = ''
  var focus = false
  
  for (cta=0; cta<c.length; cta++){
    chk = c[cta].split('|')
    
    if(chk[1] == '='){
      if(trim(document.getElementById(chk[0]).value) == chk[2]){
        if(focus==false){
          document.getElementById(chk[0]).focus()
          focus=true
        }
        
        msg += chk[3] + '\r\n'
      }
    }else if(chk[1] == '<>'){
      if(trim(document.getElementById(chk[0]).value) != chk[2]){
        if(focus==false){
          document.getElementById(chk[0]).focus()
          focus=true
        }
                
        msg += chk[3] + '\r\n'
      }
    }else if(chk[1] == "<"){
      if(parseFloat(chk[0]) < parseFloat(chk[2])){
        msg += chk[3] + '\r\n'
      }
    }else if(chk[1] == ">"){
      if(parseFloat(chk[0]) > parseFloat(chk[2])){
        msg += chk[3] + '\r\n'
      }
    }else if(chk[1] == 'd'){
      if(isDate(document.getElementById(chk[0]).value) == false){
        if(focus==false){
          document.getElementById(chk[0]).focus()
          focus=true
        }
                
        msg += chk[3] + '\r\n'
      }
    }
  }
  
  if(msg != ''){
    alert(msg)
    return false
  }else{
    return true
  }

  return true
}

function isDate(sDate) {
  var dArr = sDate.split("/");
  var d = new Date(dArr[1] + "/" + dArr[0] + "/" + dArr[2]);
  return d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2];
}

validNum = new RegExp("[^0-9]")
validCodigo = new RegExp("[^a-zA-Z0-9_-]")
validPrecio = new RegExp("[^0-9,]")

function CheckChar(Tipo){
  if(event.keyCode==13){
    return true
  }
  
  if(Tipo=='Decimal' || Tipo=='DecimalNegativo'){
    if(event.keyCode==46){
      event.keyCode = 44
    }
  }
  
  var x = event.keyCode
  
  if(Tipo=='Codigo'){
    if(validCodigo.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Entero'){
    if(validNum.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='EnteroNegativo'){
    if(x==45&&document.getElementById(window.event.srcElement.name).value.length==0){
    }else if(validNum.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Decimal'){
    if(validPrecio.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }else{
      if(String.fromCharCode(x)==','){
        if(document.getElementById(window.event.srcElement.name).value.indexOf(',')!=-1){
          event.returnValue=false
        }
      }
    }
  }else if(Tipo=='DecimalNegativo'){
    if(x==45&&document.getElementById(window.event.srcElement.name).value.length==0){
    }else if(validPrecio.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }else{
      if(String.fromCharCode(x)==','){
        if(document.getElementById(window.event.srcElement.name).value.indexOf(',')!=-1){
          event.returnValue=false
        }
      }
    }
  }
}

function windowopen(theurl,winname,features,mywidth,myheight,iscenter){
  if(iscenter==true){
    var myleft = (screen.width-mywidth) / 2
    var mytop = (screen.height-myheight) / 2
    
    features=features+',left='+myleft+',top='+mytop;
  }
  
  window.open(theurl,winname,'width='+mywidth+',height='+myheight+features);
}


function trim(cadena){ 
  for(i=0; i<cadena.length; ){
    if(cadena.charAt(i)==" ")
      cadena=cadena.substring(i+1, cadena.length);
    else
      break;
  }
  
  for(i=cadena.length-1; i>=0; i=cadena.length-1){
    if(cadena.charAt(i)==" ")
      cadena=cadena.substring(0,i);
    else
      break;
  }
  
  return cadena;
}

function ajaxobj() {
  try {
    _ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      _ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      _ajaxobj = false;
    }
  }
  
  if (!_ajaxobj && typeof XMLHttpRequest!='undefined') {
    _ajaxobj = new XMLHttpRequest();
  }
    
  return _ajaxobj;
}

function mOvr(src) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = '#FFF5E5';
}
}

function mOut(src,color) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = color;
}
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
















var firstCall = true

function cambia(fSize, increment){
  if(firstCall==true){
    firstCall = false
	if(increment!='') cambia('13', '');
  }
  
  if(increment!=''){
    currentFontSize = parseInt(document.all('cuerpo').style.fontSize)
    fontIncrease = parseInt(increment)
    newFontSize = currentFontSize + fontIncrease
  }else if(fSize!='') newFontSize = parseInt(fSize);
  
  if (newFontSize > 15) newFontSize = 15;
  if (newFontSize < 11) newFontSize = 11;
  document.all('cuerpo').style.fontSize = newFontSize + "px";
}

function runSWF(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess, FullScreen) { 

var bgcolor_ie = '';
var transparent_ie = '<param name="wmode" value="transparent">\n';

var bgcolor_ns = '';
var transparent_ns = 'wmode="transparent"';

if(version!=""){
	var version_data=version;
}else{
	var version_data="6,0,0,0";
}

if(menu!=""){
	menu_data=menu;
}else{
	menu_data=false;
}

if(bgcolor!="" && bgcolor != null){
	var bgcolor_data = bgcolor;
	bgcolor_ie = '<param name="bgcolor" value='+bgcolor_data+'>\n';
	bgcolor_ns = 'bgcolor='+bgcolor_data;
	transparent_ie = '';
	transparent_ns = '';
}


if(id!=""){
	id_data=id;
}else{
	id_data="flashMovie";
}

if(quality!=""){
	quality_data=quality;
}else{
	quality_data="high";
}

if(allowScriptAccess!=""){
	allowScriptAccess_data=allowScriptAccess;
}else{
	allowScriptAccess_data="always";
}


if (FullScreen != '') {
	allowfullscreen_data_ie = '<param name="allowfullscreen" value=true>';
	allowfullscreen_data_ns = ' allowfullscreen=true';
} else {
	allowfullscreen_data_ie = "";
	allowfullscreen_data_ns = ""
}

var quality="high"; // calidad de visualización de la peli
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= '+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
document.write('<param name="movie" value='+archivo+'>\n');
document.write('<param name= "allowScriptAccess" value= '+allowScriptAccess_data+'>\n');
document.write('<param name="quality" value='+quality_data+'>\n');
document.write('<param name="FlashVars" value='+FlashVars+'>\n');
document.write(bgcolor_ie);
document.write(transparent_ie);
document.write(allowfullscreen_data_ie);

document.write('<param name="menu" value='+menu_data+' >\n');
document.write('<embed src='+archivo+' '+bgcolor_ns+' '+transparent_ns+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+allowfullscreen_data_ns+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+'></embed>');
document.write('</object>\n');
} 

