function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos,LeftPosition,TopPosition){
//if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null)
{//LeftPosition=0;TopPosition=20
}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
//win=window.open(mypage,myname,"width='400',height='300',top='100',left='100',scrollbars='yes',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
}


function OpenWindowRight(mypage,w){
var w,h,scroll,pos,myname
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
h=screen.height-10
LeftPosition=screen.width-w-15
TopPosition=0
//LeftPosition=0;TopPosition=20
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
//win=window.open(mypage,myname,"width='400',height='300',top='100',left='100',scrollbars='yes',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
}

function OpenWindowRight2(mypage,w,h){
var w,h,scroll,pos,myname
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
h=h
LeftPosition=screen.width-w-15
TopPosition=0
//LeftPosition=0;TopPosition=20
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
//win=window.open(mypage,myname,"width='400',height='300',top='100',left='100',scrollbars='yes',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
}


function expandingWindow(website) {
var windowprops='width=100,height=100,scrollbars=yes,status=yes,resizable=yes'
//var heightspeed = 2; // vertical scrolling speed (higher = slower)
//var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
var heightspeed = 5; // vertical scrolling speed (higher = slower)
var widthspeed = 10;  // horizontal scrolling speed (higher = slower)

var leftdist = 10;    // distance to left edge of window
var topdist = 10;     // distance to top edge of window

if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
var winwidth = window.screen.availWidth - leftdist;
var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
sizer.resizeTo("1", sizeheight);
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
sizer.resizeTo(sizewidth, sizeheight);
sizer.location = website;
}
else
window.open(website,'mywindow');
}

var winheight=100
var winsize=100
var x=5

function openwindow(thelocation){
temploc=thelocation
if (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){
window.open(thelocation)
return
}
win2=window.open("","","scrollbars")
//win2.moveTo(0,0)
//alert(screen.width);
win2.moveTo(screen.width-400,0)
win2.resizeTo(100,100)
go2()
}
function go2(){
if (winheight>=screen.availHeight-3)
x=0
win2.resizeBy(5,x)
winheight+=20
winsize+=20
if (winsize>=screen.width-50){
//	alert(screen.width)
//alert(winsize)
win2.location=temploc
winheight=100
winsize=100
x=5
return
}
setTimeout("go2()",30)
}


function soloCaracteresValidos(){
	if((event.keyCode == 60)||(event.keyCode == 62)||(event.keyCode == 39)||(event.keyCode == 35)){
		event.keyCode = 0;
	}

}



function checkemail(varemail){
var str=varemail
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
testresults=false
}
return (testresults)
}



function Salto(Destino) { //v3.0
	if (ValidarDatos()==true)
	{
		document.form1.txtDestino.value=Destino;
		document.form1.submit();
	}
}



function checkchars(objeto,maxlength){
//change max length to determine below
if (objeto.value.length>maxlength)
{
	alert(objeto.value.length + "c Max. length: "+  maxlength  + " characters!")
}
}

function checknumber(mynumb){
var x=mynumb
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
	testresult=true
else
{
//	alert("Porfavor introduzca una fecha de nacimiento válida!")
	testresult=false
}
return (testresult)
}



//INICIO FUNCIONES PARA FRAMES
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library ()
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe", "FrameDatosFichero","FrameTituloFichero","FrameDatosConductor","FrameInfracciones","FrameDetalleInfracciones"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller


function CerrarIframe(frameid){
debugger
var currentfr=document.getElementById(frameid)
if (currentfr.height==0)
	resizeIframe(frameid);
else
{
	if (currentfr && !window.opera){
	currentfr.style.display="block"
	if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
	currentfr.height = 0; 
	else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
	currentfr.height = 0;
	}
}
}

function CargarYAbrir(iframeid, url){
var currentfr=document.getElementById(iframeid)
if (document.getElementById(iframeid).src!='')
	CerrarIframe(iframeid);
else
	loadintoIframe(iframeid, url);
}

//FIN FUNCIONES PARA FRAMES


function checknumber(x){
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
//alert("Por favor inserte un número válido!")
testresult=false
}
return (testresult)
}


function checkdate(input){
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
var returnval=false
if (!validformat.test(input))
alert("Fecha con formato incorrecto")
else{ //Detailed check for valid date ranges
var dayfield=input.split("/")[0]
var monthfield=input.split("/")[1]
var yearfield=input.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Fecha con formato incorrecto o fecha inexistente")
else
returnval=true
}
return returnval
}



function checkdates(input1,input2){
var validformat1=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
var validformat2=/^\d{1}\/\d{1}\/\d{4}$/ //Basic check for format validity
var validformat3=/^\d{2}\/\d{1}\/\d{4}$/ //Basic check for format validity
var validformat4=/^\d{1}\/\d{2}\/\d{4}$/ //Basic check for format validity
var returnval=false
if (!validformat1.test(input1) && !validformat2.test(input1) && !validformat3.test(input1) && !validformat4.test(input1))
	alert("Fecha con formato incorrecto")
else
{ //Detailed check for valid date ranges
	var dayfield=input1.split("/")[0]
	var monthfield=input1.split("/")[1]
	var yearfield=input1.split("/")[2]
	var dayobj = new Date(yearfield, monthfield-1, dayfield)
	if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
	alert("Fecha con formato incorrecto o fecha inexistente")
	else
	{
		if (!validformat1.test(input2) && !validformat2.test(input2) && !validformat3.test(input2) && !validformat4.test(input2))
			alert("Fecha con formato incorrecto")
		else
		{ //Detailed check for valid date ranges
			var dayfield=input2.split("/")[0]
			var monthfield=input2.split("/")[1]
			var yearfield=input2.split("/")[2]
			var dayobj = new Date(yearfield, monthfield-1, dayfield)
			if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
			alert("Fecha con formato incorrecto o fecha inexistente")
			else
			returnval=true
		}
	}
}
return returnval
}
function makeArray(n){
	this.length=n;
	for (var i=1; i <=n; i++)
	this[i]	= null;
	return this;
}
/*
var winheight=100
var winsize=100
var x=20

function openwindow(thelocation){
temploc=thelocation
if (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){
window.open(thelocation)
return
}
win2=window.open("","","scrollbars,resizable=YES,status=YES")
win2.moveTo(400,0)
win2.resizeTo(100,100)
go2()
}
function go2(){
if (winheight>=screen.availHeight-3)
x=0
win2.resizeBy(20,x)
winheight+=20
winsize+=20
if (winsize>=(screen.width-400)-20){
//if (winsize>=500-10){
win2.location=temploc
winheight=100
winsize=100
x=20
return
}
setTimeout("go2()",5)
}

*/

		
		
// can this be a good way?
function isNull(anode){
if (anode.toString()=='undefined'){ return true;} //bscontact
else{
if (anode.toString()=='NULL'){ return true;} //cosmo
else{
return false;
}
}
}
		

