// JavaScript Document
function changelangue(dir) {
loc=window.location.href;
loc=loc.substring(loc.lastIndexOf('/'));
window.location='../'+dir+loc;
}


function pviiClassNew(obj, new_style) {
    obj.className = new_style;
}

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin,toprint) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4  

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
  if (toprint) {
	  newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop+",status=yes,menubar=yes");
	} else {
	  newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	}
  newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor);  
  if (!toprint) {
//    newWindow.document.write('" onBlur="self.close()" onClick="self.close()">');
    newWindow.document.write('>');
  }
  newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+'>'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	custom_print(newWindow);
	}
}

function JustSoPicWindowQT(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin,toprint) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4  

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onload="window.focus()');  
  if (toprint) {
		newWindow.document.write(';custom_print()"')
	}
  newWindow.document.write('"><table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<embed src="'+imageName+'" width="'+imageWidth+'" height="'+imageHeight+'" loop="false" autoplay="true" controller="true" playeveryframe="true" correction="full" kioskmode="true" targetcache="true" pluginspage="http://www.apple.com/quicktime/" enablejavascript="true"></embed>');
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}


function custom_print(win) {
    if (win.document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            win.document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            win.print();
        }
    } else {
        win.print();
    }
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}

function tmt_DivResize(theDiv,w,h){
    var fun = (document.getElementById) ? "tmt_findObj" : "MM_findObj";
	var obj = eval(fun+"(theDiv)");
	if(document.layers && obj)obj.resizeTo(w, h);
  	else{if(obj){if(obj.style){obj.style.width = w;obj.style.height = h;}}}
}

function MM_showHideLayers() { //v6.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; }
}

function showHideRow(obj, val, width) {
  if (val == true) {
	MM_changeProp(obj,'','style.overflow','visible','DIV');
	MM_showHideLayers(obj,'','show');
//    tmt_DivResize(obj,width,'200');
  } else {
	MM_showHideLayers(obj,'','hide');
    MM_changeProp(obj,'','style.overflow','hidden','DIV');
	tmt_DivResize(obj,width,'1');
  }
}

function textCounter(obj, maxlimit, objc) {
if ((obj = MM_findObj(obj)) != null) {
  if (obj.value.length > maxlimit)
    obj.value = obj.value.substring(0, maxlimit);
  else {
    if ((objc = MM_findObj(objc)) != null)
      objc.value = maxlimit - obj.value.length;
} } }

function choisir(obj1, id, obj2, nom) { // IM: v: 1.0
  if (obj1 != null) {
    if ((obj1 = MM_findObj(obj1, opener.document)) != null) {
      obj1.value = id; } }
  if (obj2 != null) {
    MM_swapImage(obj2, opener.document,nom,1);
  }
  self.close();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var win = window.open(theURL,winName,features);
  win.focus();
}

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;
}

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],a[i+1]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function IMClassNew(obj, new_style) {
  if ((obj = MM_findObj(obj)) != null)
    obj.className = new_style;
  if (smnu != null && new_style == '')
    IMClassNew(smnu,'hover');
}

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_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && (typeof IM_Mnu_D != 'undefined') && (typeof IM_Mnu_Do != 'undefined')) {MM_nbGroup('over',IM_Mnu_D,IM_Mnu_Do,'',1)}
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img; } 
		}
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
      if ((typeof IM_Mnu_D != 'undefined') && (typeof IM_Mnu_Do != 'undefined')) {MM_nbGroup('over',IM_Mnu_D,IM_Mnu_Do,'',1)}
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function addFav(l) {
  if (document.all) {
	if (l == 'fr') {
  	  window.external.AddFavorite('http://www.rocherperce.qc.ca', 'Office du Tourisme de Rocher-Percé');
	} else if (l == 'an'){
  	  window.external.AddFavorite('http://www.rocherperce.qc.ca', 'Office of Tourism of Rocher-Percé');
  } } else { 
	if (l == 'fr') {
      alert('Vous pouvez faire CTRL + D pour ajouter cette page dans vos signets, ou favoris.') }
	  else if (l == 'an'){
		  alert('You can press CTRL + D to add this page on your favorite list.')
		  }
} } 



function locateObject(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=locateObject(n,d.layers[i].document); return x;
}

function hideTooltip(object)
{
if (document.all)
{
	locateObject(object).style.visibility="hidden"
	locateObject(object).style.left = 1;
	locateObject(object).style.top = 1;
return false
}
else if (document.layers)
{
	locateObject(object).visibility="hide"
	locateObject(object).left = 1;
	locateObject(object).top = 1;
	return false
}
else
	return true
}

function showTooltip(object,e, tipContent, backcolor, bordercolor, textcolor, displaytime)
{
	window.clearTimeout(tipTimer)

	if (document.all)
		{
			locateObject(object).style.top=document.body.scrollTop+event.clientY+20

			locateObject(object).innerHTML='<table style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; border: '+bordercolor+'; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: '+backcolor+'" width="10" border="0" cellspacing="1" cellpadding="1"><tr><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table> '

			if ((e.x + locateObject(object).clientWidth) > (document.body.clientWidth + document.body.scrollLeft))
				{
					locateObject(object).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(object).clientWidth-10;
				}
			else
			{
			locateObject(object).style.left=document.body.scrollLeft+event.clientX
			}
		locateObject(object).style.visibility="visible"
		tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
		}
	else if (document.layers)
		{
		locateObject(object).document.write('<table width="10" border="0" cellspacing="1" cellpadding="1"><tr bgcolor="'+bordercolor+'"><td><table width="10" border="0" cellspacing="0" cellpadding="2"><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table></td></tr></table>')
		locateObject(object).document.close()
		locateObject(object).top=e.y+20

		if ((e.x + locateObject(object).clip.width) > (window.pageXOffset + window.innerWidth))
			{
				locateObject(object).left = window.innerWidth - locateObject(object).clip.width-10;
			}
		else
			{
			locateObject(object).left=e.x;
			}
		locateObject(object).visibility="show"
		tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
	}
	else
	{
		return true;
	}
}

function FDK_ValidateSelectionMade(FormElement,ErrorMsg)
{
  msg = "";

  var iPos = FormElement.selectedIndex;
  if ((iPos<=0 && FormElement.size<=1) || (iPos<0))
  {
    msg = ErrorMsg;
  }

  return msg;
}

function FDK_AddSelectionMadeValidation(FormName,FormElementName,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateSelectionMade("+FormElementName+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_StripChars(theFilter,theString)
{
	var strOut,i,curChar

	strOut = ""
	for (i=0;i < theString.length; i++)
	{		
		curChar = theString.charAt(i)
		if (theFilter.indexOf(curChar) < 0)	// if it's not in the filter, send it thru
			strOut += curChar		
	}	
	return strOut
}

function FDK_Trim(theString)
{
 var i,firstNonWhite

 if (FDK_StripChars(" \n\r\t",theString).length == 0 ) return ""

	i = -1
	while (1)
	{
		i++
		if (theString.charAt(i) != " ")
			break	
	}
	firstNonWhite = i
	//Count the spaces at the end
	i = theString.length
	while (1)
	{
		i--
		if (theString.charAt(i) != " ")
			break	
	}	

	return theString.substring(firstNonWhite,i + 1)

}

function FDK_ValidateRadio(RadioGroup,ErrorMsg)
{
	var msg = ErrorMsg;

    for (x=0;x<RadioGroup.length;x++)  {
		if (RadioGroup[x].checked)  {
			msg=""
		} 
	}
	return msg;
}

function FDK_AddRadioValidation(FormName,FormElementName,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateRadio("+FormElementName+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName + '[0]'),ValString,SetFocus)
}

function FDK_ValidateNumChars(FormElement,Required,Minimum,Maximum,StripSpaces,ErrorMsg)     {	
	var theString = FormElement.value;
	var MinLength = Minimum;
	var MaxLength = Maximum;
	var msgInvalid = ErrorMsg;

	if (FDK_StripChars(" \n\r",theString).length == 0 && !Required)	{
       return "";
    }
	
	theString = FDK_Trim(theString);

	if (StripSpaces)      {
		theString = FDK_StripChars(" \n\r",theString);
    }
		
	if (MinLength > 0 && theString.length < MinLength)     {
		return msgInvalid;
    }
		
	if (MaxLength > 0 && theString.length > MaxLength)      {
		return msgInvalid;
	}

	// we passed the tests
	FormElement.value = theString;

	return "";
}

function FDK_AddNumCharsValidation(FormName,FormElementName,Required,Minimum,Maximum,StripSpaces,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateNumChars("+FormElementName+","+Required+","+Minimum+","+Maximum+","+StripSpaces+","+ErrorMsg+")";
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_ValidateInternationalPhone(FormElement,Required,ErrorMsg)
{
	var msg = ""
	var theString = FormElement.value;
	
	var theLen = FDK_StripChars(" \n\t\r",theString).length
	if (theLen == 0)	
		if (!Required) return "";		
		else return ErrorMsg;

	theString = FDK_StripChars("+*() -./_\n\r",theString)		

	if (!FDK_AllInRange("0","9",theString) || theString.length < 6)
	{
		msg = ErrorMsg;
	}	

	return msg		
}

function FDK_reformat(s)
{
    var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < FDK_reformat.arguments.length; i++) {
       arg = FDK_reformat.arguments[i];
       if (i % 2 == 1) 
           resultString += arg;
       else 
       {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function FDK_AllInRange(x,y,theString)
{
	var i, curChar
	
	for (i=0; i < theString.length; i++)
	{
		curChar = theString.charAt(i)
		if (curChar < x || curChar > y) //the char is not in range
			return false
	}
	return true
}

function FDK_AddInternationalPhoneValidation(FormName,FormElementName,Required,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateInternationalPhone("+FormElementName+","+Required+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_ValidateNonBlank(FormElement,ErrorMsg)
{
  var msg = ErrorMsg;
  var val = FormElement.value;  

  if (!(FDK_StripChars(" \n\t\r",val).length == 0))
  {
     msg="";
  }

  return msg;
}

function FDK_AddNonBlankValidation(FormName,FormElementName,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateNonBlank("+FormElementName+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_ValidateEmail(FormElement,Required,ErrorMsg)
{
   var msg = "";
   var val = FormElement.value;
   var msgInvalid = ErrorMsg;

   var theLen = FDK_StripChars(" ",val).length
   if (theLen == 0)	     {
     if (!Required) return "";
     else return msgInvalid;
   }

   if (val.indexOf("@",0) < 0 || val.indexOf(".")<0) 
   {
      msg = msgInvalid;
   }
   return msg;
}

function FDK_AddEmailValidation(FormName,FormElementName,Required,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateEmail("+FormElementName+","+Required+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_ValidateURL(FormElement,Required,ErrorMsg)
{
   var msg = "";
   var val = FormElement.value;
   var msgInvalid = ErrorMsg;
   var i;
   var lcase ;   
   var protocols = "ftp://,http://,javascript:,file://,gopher://,https://,mailto:,rusrUsager://,shttp://,snews://,telnet://,tn3270://,wais://";
   var protos = protocols.split(",");

  	var theLen = FDK_StripChars(" ",val).length;
	  if (theLen == 0)	
		  if (!Required) return "";		
		  else return msgInvalid;


   lcase = FDK_Trim(val.toLowerCase());

   msg = msgInvalid;

   for (i = 0; i < protos.length; i++)
   {
	     if (lcase.indexOf(protos[i]) == 0 )
	     {		
         msg = ""
         FormElement.value=protos[i] + FDK_Trim(val).substring(protos[i].length,val.length)
		       break;
	     }
   }

   return msg;
}

function FDK_AddURLValidation(FormName,FormElementName,Required,SetFocus,ErrorMsg)  {
  var ValString = "FDK_ValidateURL("+FormElementName+","+Required+","+ErrorMsg+")"
  FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus)
}

function FDK_Validate(FormName, stopOnFailure, AutoSubmit, ErrorHeader)
{
 var theFormName = FormName;
 var theElementName = "";
 if (theFormName.indexOf(".")>=0)  
 {
   theElementName = theFormName.substring(theFormName.indexOf(".")+1)
   theFormName = theFormName.substring(0,theFormName.indexOf("."))
 }
 var ValidationCheck = eval("document."+theFormName+".ValidateForm")
 if (ValidationCheck)  
 {
  var theNameArray = eval(theFormName+"NameArray")
  var theValidationArray = eval(theFormName+"ValidationArray")
  var theFocusArray = eval(theFormName+"FocusArray")
  var ErrorMsg = "";
  var FocusSet = false;
  var i
  var msg
    
 
        // Go through the Validate Array that may or may not exist
        // and call the Validate function for all elements that have one.
  if (String(theNameArray)!="undefined")
  {
   for (i = 0; i < theNameArray.length; i ++)
   {
    msg="";
    if (theNameArray[i].name == theElementName || theElementName == "")
    {
      msg = eval(theValidationArray[i]);
    }
    if (msg != "")
    {
     ErrorMsg += "\n"+msg;                   
     if (stopOnFailure == "1") 
     {
       if (theFocusArray[i] && !FocusSet)  
      {
       FocusSet=true;
       theNameArray[i].focus();
      }
      alert(ErrorHeader+ErrorMsg);
      document.MM_returnValue = false; 
      break;
     }
     else  
     {
      if (theFocusArray[i] && !FocusSet)  
      {
       FocusSet=true;
       theNameArray[i].focus();
      }
     }
    }
   }
  }
  if (ErrorMsg!="" && stopOnFailure != "1") 
  {
   alert(ErrorHeader+ErrorMsg);
  }
  document.MM_returnValue = (ErrorMsg==""); 
  if (document.MM_returnValue && AutoSubmit)  
  {
   eval("document."+FormName+".submit()")
  }
 }
 eval(FormName+"NameArray.length = 0");
 eval(FormName+"ValidationArray.length = 0");
 eval(FormName+"FocusArray.length = 0");
 var TheRoot=eval("document."+FormName);
 TheRoot.ValidateForm = false;
}


function FDK_AddToValidateArray(FormName,FormElement,Validation,SetFocus)
{
    var TheRoot=eval("document."+FormName);
 
    if (!TheRoot.ValidateForm) 
    {
        TheRoot.ValidateForm = true;
        eval(FormName+"NameArray = new Array()")
        eval(FormName+"ValidationArray = new Array()")
        eval(FormName+"FocusArray = new Array()")
    }
    var ArrayIndex = eval(FormName+"NameArray.length");
    eval(FormName+"NameArray[ArrayIndex] = FormElement");
    eval(FormName+"ValidationArray[ArrayIndex] = Validation");
    eval(FormName+"FocusArray[ArrayIndex] = SetFocus");
 
}


