// --- Standard Macromedia Javascript functions ------------

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}	// EOF function MM_goToURL()

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
} // EOF MM_findObj(n, d)

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
} // EOF MM_showHideLayers()

function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
} // MM_swapImgRestore()

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
} // MM_swapImage()

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
} // MM_displayStatusMsg(msgStr)

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
} // EOF MM_callJS(jsStr)


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
} // EOF MM_reloadPage(init)

// -----------------------------------------------------------------
//  ============== Additional functions ============================

function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
  var obj=MM_findObj(objStr);
  if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}

// Date mechanism
// Date 1
function showDate()	{

dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
	now = new Date;
theHour = now.getHours();
theMinutes = now.getMinutes();
   ampm = "";

if (theMinutes > 9)	{
	theMinutes = theMinutes;
 }else{
	theMinutes = "0" + theMinutes;
} // end if


if (theHour > 0 && theHour < 13)	{
	theHour = theHour;
	ampm = "AM";
 	}else{
	theHour = theHour - 12;
	ampm = "PM"
} // end if


// Date 2
document.write(dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate() + " ");
document.write("&nbsp;&nbsp;");
document.write(theHour + ":" + theMinutes + ampm);

} // EOF ShowDate



//  ============== BJ's functions ============================

function addbookmark(){
	var bookmarkurl="http://www.bustamanteabogados.com";
	var bookmarktitle="Estudio Jurídico Bustamante";
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle);
} //EOF addbookmark()


function LTrim(str) {
     // We don't want to trim JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
      var whitespace = new String(" \t\n\r");

      var s = new String(str);

    if (whitespace.indexOf(s.charAt(0)) != -1) {
          // We have a string with leading blank(s)...
		 var j=0, i = s.length;
      // Iterate from the far left of string until we
      // don't have any more whitespace...
          while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;

 	// Get the substring from the first non-whitespace
     // character to the end of the string...
         s = s.substring(j, i);
         }
           return s;
    } // EOF LTrim()

function RTrim(str)   {
   // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
     var whitespace = new String(" \t\n\r");
 	var s = new String(str);

     if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
		var i = s.length - 1;       // Get length of string
	// Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        i--;

	// Get the substring from the front of the string to
	// where the last non-whitespace character is...
         s = s.substring(0, i+1);
    }
	return s;
 }	// eof RTrim()

function Trim(str)	{
	return RTrim(LTrim(str));
}	// EOF Trim()

//==== FORM CHECKS ==================

// Generic error message.
function errorMsg(msg, offendingBox)	{
	var words, testmsg; 
	
	words = "Sorry, but you have made the following error: \n";
	words += "_____________________________________________\n\n";
	words += msg + "\n\n";
	
	alert(words);
	offendingBox.focus();
	offendingBox.select();
	return false;

}	// End - errorMsg(msg, offendingBox)


// ================ NUMERIC section ================

// Check if something is numeric
function isNum(passedVal)	{
	if(passedVal =="")	{
		return false;
	}
	for (i=0; i<passedVal.length; i++)	{
		if (passedVal.charAt(i) < "0") 	{
			return false;
		}
		if (passedVal.charAt(i) > "9")	{
			return false;
		}
	}
	return true;
}	// End - isNum(passedVal)


// Check if the first character is a zero
function checkZero(thisBox)	{
//	var myBox; myBox = document.newvac_page1.salary;

	if (thisBox.value.charAt(0) == 0)	{
		errorMsg("You must enter a numeric value for Salary/Rate.", thisBox);
	   }else{
	   return;
	}
}	// End - checkZero(thisBox)


// only allow numeric entry
function keyCheck(eventObj, obj)
{
	var keyCode; 	var str=obj.value
	// Check For Browser Type
	if (document.all){ 
		keyCode=eventObj.keyCode
	}
	else{
		keyCode=eventObj.which
	}
	if(keyCode==46){ 
		if (str.indexOf(".")>0){
			return false
		}
	}
	if((keyCode<48 || keyCode >58)   &&   (keyCode != 46)){ // Allow only integers and decimal points
		return false
	}
	return true
}	// End - keyCheck(eventObj, obj)

// ========== End of NUMERIC section




//===================== EMAIL section =================

function validEmail(email)	{
	var Email = email.value
	var invalidChars; invalidChars = " /:,;"
	var badChar;
	var atPos;
	var periodPos;
	
// see if it is empty
	if (Email == "")	{
		errorMsg("You have not entered an email address.", email);
	}
	
// see if it contains any of the invalid characters
	for (i=0; i<invalidChars.length; i++)	{
		badChar = invalidChars.charAt(i);
		if (Email.indexOf(badChar,0) > -1)	{
			errorMsg("The email address is not correctly formatted: \n\n You have entered an invalid character, probably one of the following:\n\n/ : , ;  or a blank space", email);
		}
	}

// see if it contains only one '@' and in the right place
	atPos = Email.indexOf("@",1);
	if (atPos == -1)	{
		errorMsg("The email address is not correctly formatted: \n\n The '@' character is missing", email);
	}

	if (Email.indexOf("@",atPos+1) > -1)	{
		errorMsg("The email address is not correctly formatted: \n\n There are too many '@' characters", email);
	}
	
// check for '.' at the right places
	periodPos = Email.indexOf(".",atPos);
	if (periodPos == -1) 	{
		errorMsg("The email address is not correctly formatted: \n\n The '.' is missing after the '@' character", email);
	}
	if (periodPos+3 > Email.length)	{
		errorMsg("The email address is not correctly formatted: \n\n The '.' may be in the wrong place...or\n\n the address may not be complete", email);
	}
	
	if(Email.indexOf("@.") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have not put any letters between the  '@' character and the '.'", email);
	}
		if(Email.indexOf(".@") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have not put any letters between the  '.' and the '@' character", email);
	}
		if(Email.indexOf("..") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have put two '.'s together", email);
	}
	
	return;	// if it gets this far, all is probably OK...
	
}	// End validEmail(email)
	
//===================== END of  EMAIL section =================


// ---------- Image management functions ------------

function getFileExt(filename)	{
	dotIsAt = filename.lastIndexOf(".");
	ext = filename.substring(dotIsAt+1,filename.length);
	if ((ext=="jpg")||(ext=="JPG")||(ext=="gif")||(ext=="GIF")){
		return true;
		}else{
		msg =  "\La imagen debe ser: '.JPG' or '.GIF'  \n\n";
		msg = msg + "                           "; 
		alert(msg);
		window.history.back();
	}	// End if 
}	//EOF getFileExt()

var blankImg;
blankImg = "../../List_images/nopic.gif";

var blankImg_aso;
blankImg_aso = "../../List_images/nopic_aso.gif";

function makeBlank_aso()	{
	document.all.frmChanges.img1.src = blankImg_aso;
	document.all.frmChanges.hidUseBlank1.value = 1;
	document.all.frmChanges.hidSave1.value = 1;
}
function makeBlank1()	{
	document.all.frmChanges.img1.src = blankImg;
	document.all.frmChanges.hidUseBlank1.value = 1;
	document.all.frmChanges.hidSave1.value = 1;
}
//----------------------------------------


function setImage1(filename)	{
	if (getFileExt(filename)){	// See above
		document.all.frmChanges.img1.src = filename;
		document.all.frmChanges.hidUseBlank1.value = 0;
		document.all.frmChanges.hidSave1.value = 1;
	} //End if getFileExt()
}	//EOF setImage1()


function Restore1(filename)	{
	img = "../../List_images/" + filename;
	document.all.frmChanges.img1.src = img;
	document.all.frmChanges.hidUseBlank1.value = 0;
	document.all.frmChanges.hidSave1.value = 0;
}

//============= EOF ==================

