/*** General functions ***/
var BrowserDetect = {
                init: function () {
                                this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
                                this.version = this.searchVersion(navigator.userAgent)
                                                || this.searchVersion(navigator.appVersion)
                                                || "an unknown version";
                                this.OS = this.searchString(this.dataOS) || "an unknown OS";
                },
                searchString: function (data) {
                                for (var i=0;i<data.length;i++)    {
                                                var dataString = data[i].string;
                                                var dataProp = data[i].prop;
                                                this.versionSearchString = data[i].versionSearch || data[i].identity;
                                                if (dataString) {
                                                                if (dataString.indexOf(data[i].subString) != -1)
                                                                                return data[i].identity;
                                                }
                                                else if (dataProp)
                                                                return data[i].identity;
                                }
                },
                searchVersion: function (dataString) {
                                var index = dataString.indexOf(this.versionSearchString);
                                if (index == -1) return;
                                return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
                },
                dataBrowser: [
                                {
                                                string: navigator.userAgent,
                                                subString: "Chrome",
                                                identity: "Chrome"
                                },
                                {              string: navigator.userAgent,
                                                subString: "OmniWeb",
                                                versionSearch: "OmniWeb/",
                                                identity: "OmniWeb"
                                },
                                {
                                                string: navigator.vendor,
                                                subString: "Apple",
                                                identity: "Safari",
                                                versionSearch: "Version"
                                },
                                {
                                                prop: window.opera,
                                                identity: "Opera"
                                },
                                {
                                                string: navigator.vendor,
                                                subString: "iCab",
                                                identity: "iCab"
                                },
                                {
                                                string: navigator.vendor,
                                                subString: "KDE",
                                                identity: "Konqueror"
                                },
                                {
                                                string: navigator.userAgent,
                                                subString: "Firefox",
                                                identity: "Firefox"
                                },
                                {
                                                string: navigator.vendor,
                                                subString: "Camino",
                                                identity: "Camino"
                                },
                                {                              // for newer Netscapes (6+)
                                                string: navigator.userAgent,
                                                subString: "Netscape",
                                                identity: "Netscape"
                                },
                                {
                                                string: navigator.userAgent,
                                                subString: "MSIE",
                                                identity: "Explorer",
                                                versionSearch: "MSIE"
                                },
                                {
                                                string: navigator.userAgent,
                                                subString: "Gecko",
                                                identity: "Mozilla",
                                                versionSearch: "rv"
                                },
                                {                              // for older Netscapes (4-)
                                                string: navigator.userAgent,
                                                subString: "Mozilla",
                                                identity: "Netscape",
                                                versionSearch: "Mozilla"
                                }
                ],
                dataOS : [
                                {
                                                string: navigator.platform,
                                                subString: "Win",
                                                identity: "Windows"
                                },
                                {
                                                string: navigator.platform,
                                                subString: "Mac",
                                                identity: "Mac"
                                },
                                {
                                                   string: navigator.userAgent,
                                                   subString: "iPhone",
                                                   identity: "iPhone/iPod"
                    },
                                {
                                                string: navigator.platform,
                                                subString: "Linux",
                                                identity: "Linux"
                                }
                ]

};
BrowserDetect.init();

	/* New Popup Window */
	var win= null;
	function opp_popup(mypage,myname,w,h,scroll){
	  var winl = (screen.width-w)/2;
	  var wint = (screen.height-h)/2;
	  var settings  ='height='+h+',';
		  settings +='width='+w+',';
		  settings +='top='+wint+',';
		  settings +='left='+winl+',';
		  settings +='scrollbars='+scroll+',';
		  settings +='resizable=yes';
		  if (mypage.indexOf("?") > 0)
		  {
			mypage += '&'
		  } else {
			mypage += '?'
		  }
		  mypage += 'pageurl=' + encode_url(document.URL);
		  mypage += '&pagetitle=' + escape(document.title);
	  win=window.open(mypage,myname,settings);
	  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
	}

	/* Encode URL */

	function encode_url(url){
		  var enc_url;
		  enc_url = url;
		  // Replace ALL '&' signs!, use regular expression
		  var rExp;
		  rExp = /&/gi;
		  // Replace characters
		  enc_url = enc_url.replace("?", "[[QM]]");
		  enc_url = enc_url.replace("=", "[[EQ]]");
		  enc_url = enc_url.replace(rExp, "[[AMP]]");
		  return enc_url;
	}


	/* Decode URL */

	function decode_url(url){
		  var dec_url;
		  dec_url = url;
		  // Replace ALL '&' signs!, use regular expression
		  var rExp;
		  rExp = /\[\[AMP\]\]/gi;
		  // Replace characters
		  dec_url = dec_url.replace("[[QM]]", "?");
		  dec_url = dec_url.replace("[[EQ]]", "=");
		  dec_url = dec_url.replace(rExp, "&");
		  return dec_url;
	}

/*** Client side Error handling Functions ***/

  var ErrorMsg;
  var ErrorBln;
  var GoodCollection;
  var sFormFieldType;
  var iSizeW;
  var iSizeH;

  function chk_isempty(o,msg){
    if (o.value.length == 0) {
      Message(o," -- May not be empty.",msg);
	  ErrorFields(o);
    }
  }
  
  function chk_length_min(o,msg,lmin){
    if (o.value.length < lmin) 
    {
       Message(o," -- Must be at least " + lmin + " characters long.",msg);          
    }
  }
  
  function chk_length_min_max(o,msg,lmin,lmax){
    if ((o.value.length < lmin) || (o.value.length > lmax))
    {
       Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.",msg);          
    }
  }

   function chk_checkbox_validation(o,msg){
	alert('not inside'+ document.name);
    if (!o.checked)
    {
	   alert('inside');
       Message(o," -- Select the checkbox.",msg);          
    }
  }
  
 function chk_length_min_max1(o,msg,lmin,lmid,lmax){
    if ((o.value.length < lmin)|| (o.value.length > lmax)||((o.value.length > lmin) && (o.value.length < lmax) && !(o.value.length==lmid)))
    {
       Message(o," -- Must be at least " + lmin + " and  maximal " + lmax + " characters long.",msg);          
    }
  }

  function chk_email(o,msg){
   var bemailerror = false;
   var emailaddress = o.value;
   if (o.value.length > 0)
   {
    if (emailaddress.indexOf("@")<1)  {
		Message(o," -- E-mail address is invalid.",msg);
	} else {
		if (emailaddress.indexOf(".",emailaddress.indexOf("@")) < emailaddress.indexOf("@")) {
			Message(o," -- E-mail address is invalid.",msg);
		} else {
		  var allow = '@_-.abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
		  for (var c = 0; c < emailaddress.length; c++)
		  {
		   if(allow.indexOf(emailaddress.substr(c, 1)) == -1)
		   {
			//alert('Illegal character ' + stringToCheck.substr(c, 1));
			//Message(o," -- E-mail address is invalid.",msg);
			bemailerror = true;
		   }
		  }
		}
   
	  }
    }
	if (bemailerror == true) {
		Message(o," -- E-mail address is invalid.",msg);
	}
  }

  function chk_email_new(o,msg,e){
var ctrl = (document.all) ? event.ctrlKey:e.modifiers & Event.CONTROL_MASK; 
var msg = "Sorry, this functionality is disabled.";
if (document.all)
{
if (ctrl && code==86) //CTRL+V
{
alert(msg);
window.event.returnValue = false;
}
else if (ctrl && code==67) //CTRL+C (Copy)
{
alert(msg);
window.event.returnValue = false;
}
}
else {
if (ctrl==2) //CTRL key
{
alert(msg);
return false;
}
}

  }
  
  function chk_email_OLD(o,msg){
   var emailaddress = o.value;
   if (o.value.length > 0)
   {
    if (emailaddress.indexOf("@")<2)  {
		Message(o," -- E-mail address is invalid.",msg);
	} else {
		if (emailaddress.indexOf(".",emailaddress.indexOf("@")) < emailaddress.indexOf("@")) {
			Message(o," -- E-mail address is invalid.",msg);
		}
	}
   }
  }

  function chk_validint(o, msg,i)
  {
	   var stext = o.value;
	  var bvalidchar = 1; // 1 = true (good) ; 1 = false (bad)
	  //alert("Name : [" + o.name + "]\nValue : [" + o.value + "]\nLength : [" + stext.length + "]");
  	  for (var a = 0; a < stext.length; a++)	{
		var each_char = stext.charAt(a);
		var x = asc2(each_char,i);
			if (x == 1) {
				bvalidchar = 0;
			}
	  }
	  if (bvalidchar == 0)
	  {
		  Message(o," -- Invalid number entry.",msg); 
	  }	  
  }

  function asc2(each_char,i)	{
		
		if (i == 1) {
			var char_str = charSetStr3();
		}
		for (i = 0; i < char_str.length; i++) {
			if (each_char == char_str.substring(i, i+1)) {
				return 1;
			}
		}
	return 0;
}
  
function charSetStr3()	{
	var str = '!"#$%&' + "" + '()*+,/;:<=>?[\\]^_`{|}~@_-.abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	return str;
}

  function chk_compare(o,msg,checkfield){
	if (o.value != checkfield.value) 
    {
       Message(o," -- " + checkfield + " MUST match " + o.name + ".",msg);          
    }
  }

  function chk_validchar(o,msg,i) {
	  var stext = o.value;
	  var bvalidchar = 1; // 1 = true (good) ; 1 = false (bad)
	  //alert("Name : [" + o.name + "]\nValue : [" + o.value + "]\nLength : [" + stext.length + "]");
  	  for (var a = 0; a < stext.length; a++)	{
		var each_char = stext.charAt(a);
		var x = asc(each_char,i);
			if (x == 1) {
				bvalidchar = 0;
			}
	  }
	  if (bvalidchar == 0)
	  {
		  Message(o," -- Invalid character entry.",msg); 
	  }	  
  }
  
  function Chk_emailcmpr(e)
	{
	  document.oncontextmenu = function()
	    {
          return false;
        }
	       // if (document.layers)
			//{
	          // document.captureEvents( Event.MOUSEDOWN );
	          // document.onmousedown = function (evt){
      		   // if ( evt.which == 3  ) return false;
                 //};
          // }           
         var unicode=e.keyCode? e.keyCode : e.charCode
        
         if ( unicode == 86 || unicode == 67 ) 
           {
          
            window.clipboardData.setData("Text", " " );
             return false;
           }

  }
  var selectvalue;
  function chk_selectboxvalue(o,msg,except){
     selectvalue="";
	 selectvalue = o[o.selectedIndex].value;
	if (selectvalue == except) {
		Message(o," not selected -- This is a mandatory field.",msg); 
	}
  }
  function chk_selectbox(o,msg,except){
	var selectboxvalue = o[o.selectedIndex].value;
	if (selectboxvalue == except) {
		Message(o," not selected -- This is a mandatory field.",msg); 
	}
  }
  
  function chk_selectbox_date(o_day,o_month,o_year,msg,except){
	var selectboxvalue_day = o_day[o_day.selectedIndex].value;
	var selectboxvalue_month = o_month[o_month.selectedIndex].value;
	var selectboxvalue_year = o_year[o_year.selectedIndex].value;
	if ((selectboxvalue_day == except) || (selectboxvalue_month == except) || (selectboxvalue_year == except)) {
		Message(o_day," not selected -- This is a mandatory field.",msg); 
	}
  }
  
  function chk_radiobuttons(o,msg){
	  var oneChecked = false;
	  
	  for (i = 0; i < o.length; i++) {
		if (o[i].checked == true) {
			oneChecked = true;
			break;
		}
	  } 
	if (!oneChecked) {
		Message(o[1]," no radio button checked -- This is a mandatory field.",msg); 
	}
  }

function asc(each_char,i)	{
		
		if (i == 1) {
			var char_str = charSetStr2();
		} else {
			var char_str = charSetStr();
		}
		for (i = 0; i < char_str.length; i++) {
			if (each_char == char_str.substring(i, i+1)) {
				return 1;
			}
		}
	return 0;
}
	
function charSetStr()	{
	//*** REMOVED !,#,$,-,_,~ from check to allow a few more symbols in login name
	//*** Modified by Dennis van Heezik on 8th April 2003 - Verified with Harold Herksen and Michel Schipper
	var str = ' "%&' + "" + '()*+,/;:<=>?[\\]^`{|}';
	return str;
}

function charSetStr2()	{
	var str = '!"#$%&' + "" + '()*+,/;:<=>?[\\]^_`{|}~';
	// this one just doesn't have a space or hyphen
	return str;
}

  function Message(o,msgdefault,msgcustom){
	  //iValidationType = 2
      ErrorBln = true;
	  ErrorFields(o);
      if (msgcustom!=""){
		// Custom error message (HTML - v2.0)       
		//if (iValidationType == 2){
			// Custom error message (HTML - v2.0)
			// OLD, before JavaScript update!
			// ErrorMsg += msgcustom + "<br>";
		if (is.ie || is.ns5 || is.ns6) {
			oEmbeddedErrorBlock = document.getElementById("errortable");
		}
		else{
		}
		
		//If an errortable object exists then write error messages there, else show them in a popup
		if(oEmbeddedErrorBlock != null){
			ErrorMsg += "<tr>";
			ErrorMsg += "  <TD width='422' class='bodytext' colspan='100%'><div align='left' class='bodytext'>";
			ErrorMsg += msgcustom + "</div></TD>";
			ErrorMsg += "</tr>";
		}
		else{
			ErrorMsg += "<tr>";
			ErrorMsg += "  <td width='10' valign='top'><img src='/GARClass/definitions/opp/images/icon_bullet.gif' width='6' height'9'></td>";
			ErrorMsg += "  <td width='99%' valign='top'>" + msgcustom + "</td>";
			ErrorMsg += "</tr>";
		}
		//} else {
		//	ErrorMsg += msgcustom + "\n";
		//}    
      }
      else {
        // Default error message (alertbox)
		//if (iValidationType == 2){
			// Custom error message (HTML - v2.0)
			ErrorMsg += o.name + msgdefault + "<br>";
		//} else {
		//	ErrorMsg += o.name + msgdefault + "\n";
		//}
      }
  }


  function MessageRS(msgcustom){
	  //iValidationType = 2
      ErrorBln = true;
      if (msgcustom!=""){
		// Custom error message (HTML - v2.0)       
		//if (iValidationType == 2){
			// Custom error message (HTML - v2.0)
			// OLD, before JavaScript update!
			//ErrorMsg += msgcustom + "<br>";
				var oEmbeddedErrorBlock;
		if (is.ie || is.ns5 || is.ns6) {
			oEmbeddedErrorBlock = document.getElementById("errortable");
		}
		else{
		}
		
		//If an errortable object exists then write error messages there, else show them in a popup
		if(oEmbeddedErrorBlock != null){
			ErrorMsg += "<tr>";
			ErrorMsg += "  <TD width='422' class='bodytext' colspan='100%'><div align='left' class='bodytext'>";
			ErrorMsg += msgcustom + "</span></div></TD>";
			ErrorMsg += "</tr>";
		}
		else{
			ErrorMsg += "<tr>";
			ErrorMsg += "  <td width='10' valign='top'><img src='/GARClass/definitions/opp/images/icon_bullet.gif' width='6' height'9'></td>";
			ErrorMsg += "  <td width='99%' valign='top'>" + msgcustom + "</td>";
			ErrorMsg += "</tr>";
		}
		//} else {
		//	ErrorMsg += msgcustom + "\n";
		//} 
      }
  }

  function ErrorFields(o){
        try
	{
		ErrorCollection += o.name + ";|;";
	}
	catch(e)
	{
	}


  }

  function Clear_ErrorImages(GoodCollection) {
	  //alert("GoodCollection--->"+GoodCollection);
		if (GoodCollection != '' && GoodCollection != null) {
			var strBlankImage = IMAGE_BLANK;
			
			// Clear error images behind form field (show transparent)
			GoodCollection = GoodCollection.slice(0,-3);
			splitGood = GoodCollection.split(";|;");
			for (i=0; i<splitGood.length; i++){
				var o = document.getElementById("img_" + splitGood[i]);
				o.src = strBlankImage;
				//alert("o.src-->"+o.src);
			}
		}
  }



  function Chk_Errors(){
	
	// Set the bHTML boolean
	var bHTML 
	if ((is.ie || is.ns5 || is.ns6) && (iValidationType == 2)) {
		bHTML = true;
	} else {
		bHTML = false;
	}

	if (ErrorBln) 
    {	
		// iSizeH = determines the height divider element, which is passed on to the errorbox
		// iSizeW = determines the width divider element, which is passed on to the errorbox
		
		if (iValidationType == 2) { 
			// Registration Page, show larger error box!
			DispHTMLError(ErrorMsg,iSizeW,iSizeH);
		} else { 
			// Show default size error box!
			DispHTMLError(ErrorMsg,iSizeW,iSizeH);
		}

		/*
		if (bHTML == true)
		{
			// Build HTML error message (v2.0)
			hideErrorLayer();
			var HTMLErrorMsg
			HTMLErrorMsg = ErrorMsg;
			// Show HTML message


			// Replace characters and other HTML signs
			HTMLErrorMsg = HTMLErrorMsg.replace(/\[\[br\]\]/gi, "<br>");
			HTMLErrorMsg = HTMLErrorMsg.replace(/\[\[b\]\]/gi, "<b>");
			HTMLErrorMsg = HTMLErrorMsg.replace(/\[\[\/b\]\]/gi, "</b>");

			// Popup reminder implementation!
			HTMLErrorMsg = HTMLErrorMsg.replace(/\[\[popupreminder\]\]/gi, "<a href=# class=opp_regarea_error_text onClick=opp_popup('opp_popup_reminder.asp','reminder','500','220','no');return false>");
			HTMLErrorMsg = HTMLErrorMsg.replace(/\[\[\/popupreminder\]\]/gi, "</a>");

			// Strip off last <br> tag
			HTMLErrorMsg = HTMLErrorMsg.substr(0,HTMLErrorMsg.length-4);
			
			//alert('error!');

			showErrorLayer("opperrormessage", HTMLErrorMsg);
			
		} else {
		// Build ASCII error message
			//ErrorMsg = "______________________________________________________________________________\n" +
			//JS_FORM_ERROR + "\n\n" +
			//ErrorMsg + "____________________________________________________________________________" +
			//"\n" + JS_FORM_RESUBMIT + "\n" +
			//"\n" + JS_FORM_ENTRIES1 +
			//JS_FORM_ENTRIES2;
			// Show ASCII alert message
			//alert(ErrorMsg);
			//ErrorMsg = "<br>" + JS_FORM_ERROR + "<br><br>" + ErrorMsg + "<BR>" + JS_FORM_RESUBMIT + "<BR>" + JS_FORM_ENTRIES2;
			//ErrorMsg = "<br>" + JS_FORM_ERROR + "<br><br>" + ErrorMsg + "<BR>" + JS_FORM_RESUBMIT + "<BR>" + JS_FORM_ENTRIES2;
			DispHTMLError(ErrorMsg);
			//alert(ErrorMsg);

		}

		*/
		
		// Show error image behind form field
		if (ErrorCollection.length > 1) {
			
			var strErrImage = IMAGE_ERROR;
			ErrorCollection = ErrorCollection.slice(0,-3);
			
			splitError = ErrorCollection.split(";|;")
			
			for (i=0; i<splitError.length; i++){
				var o = document.getElementById("img_" + splitError[i]);
				//if (o)
				o.src = strErrImage;
			}

		}	

    } else {
		if (bHTML == true)
		{ 
		  //hideErrorLayer(); 
		}
	}

		//alert('End of CheckErrors!');
		//alert('boolean:' + ErrorBln);

  }

	function showErrorLayer(block, msg) {
		if (is.ie || is.ns5 || is.ns6) {

			document.getElementById(block).innerHTML = msg ;
			document.getElementById("myerrorblock").innerHTML = document.getElementById("myerrorcontainer").innerHTML ;
			document.getElementById("myerrorblock").style.display = "" ;

		}
		else {			
			// do nothing for Netscape 4.x
		}
	}

	function hideErrorLayer() {

		if (is.ie || is.ns5 || is.ns6) {
			document.getElementById("myerrorblock").innerHTML = "" ;
			document.getElementById("myerrorblock").style.display = "none" ;
		}
		else {			
			// do nothing for Netscape 4.x
		}
	}


	function showHelp(block, msg) {
		if (is.ie || is.ns5 || is.ns6) {
			
			// replace [ and ] tags with the necessary HTML tags: < and > 
			var regexp;
			var strnew;

			regexp1 = /\[/gi;
			regexp2 = /\]/gi;

			msg = msg.replace(regexp1, "<");
			msg = msg.replace(regexp2, ">");

			document.getElementById(block).innerHTML = msg;
		}
		else {			
			// do nothing for Netscape 4.x
		}
	}
	function hideHelp(block, msg) {
		if (is.ie || is.ns5) {
			document.getElementById(block).innerHTML = msg ;
		}
		else {
			// do nothing for Netscape 4.x
		}
	}

	// This function will be called on every page whenever an hash key is inserted inside the url (using the vhk variable)
	// This function will replace ALL HREFs on the page and extend them with a currently active hash keys (this is important for leaving them in the URL for
	// adding them to your favorites).
	function extendLinks(svarquery){
		// Fill the current domain automatically
		var currentdomain = document.domain;
		// Fill the query variable dynamically using ASP
		var query = svarquery;
		if (query=='')
		{query='svarqvp2=0'
		}
		query = query.toLowerCase();

		var current_href;
		var base_url;
		var orginal_query;
		var new_query;

		// Loop through the the links section
		for (l=0; l<document.links.length; l++)	{
			// Fill url variable and set all the HREFs to LowerCase
			current_href = document.links[l].href.toLowerCase();
			if ((current_href.indexOf(currentdomain) == 7) && (current_href.indexOf(query) <= 0) ){
				// Checks if the link contains a "?", it will ADD the new query in BETWEEN the old query and the new query
				if (current_href.indexOf('?') != -1) {
					base_url = current_href.substr(0,current_href.indexOf('?')+1);
					orginal_query = current_href.substr(current_href.indexOf('?')+1);
					new_query = base_url + query + "&" + orginal_query;
					current_href = new_query;
				}
				// Add new functionality to catch other extensions which do NOT need a modification in the link (e.g. .exe / .doc / .pdf
				else {
				  // Checks if the link contains .asp, it will ADD a "?" to the string AND the new query
				  if (current_href.indexOf('.asp') != -1) {
					  current_href = current_href + "?" + query;
				  } 
					else {
  					// Checks if the link contains NO PAGE (thus a slash on the end), it will ADD "index.asp?" to the string AND the new query
  					if (current_href.substr(current_href.length-1,current_href.length-1) == "/") {
  						current_href = current_href + "index.asp?" + query;
  					} 
						else {
  					  if ((current_href.substr(current_href.length-4,current_href.length-4) != ".asp") && (current_href.substr(current_href.length-4,current_href.length-4) != ".htm") &&
					  (current_href.substr(current_href.length-5,current_href.length-5) != ".html") &&
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".exe") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".doc") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".xls") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".swf") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".pdf") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".zip") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".sit") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".jpg") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".gif") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".mp3") && 

(current_href.substr(current_href.length-4,current_href.length-4) != ".hqx") &&
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".ppt")) {
    						current_href = current_href + "/index.asp?" + query;
  					  }
					  }
				  }
				}
  			document.links[l].href = current_href;
			} 
		}
	}

	// The following function will check if the URL contains a specific reserved extension (exe/pdf/doc), this will return true if it does
	// Added by DvH on 22 Sept. 2004 to support .exe file downloads and prevent the ?svarqvp2=0 addition to the URL
	function checkUrl(myurl){
		var regExpUrl;
		regExpUrl = /^\S+\.(exe|pdf|doc)$/;

		if (regExpUrl.test(myurl)) {
			return true;
		} else { return false; }
	}

	// This function can be called on a page whenever an hash key is inserted inside the url (using the vhk variable)
	// This function will take the sequence of vhk variables (svarquery) and attach them to the passed-in URL (surl)
	function attachKeyToLink(svarquery, surl){
		// Fill the current domain automatically
		var currentdomain = document.domain;
		// Fill the query variable dynamically using ASP
		var query = svarquery;
		if (query=='')
		{query='svarqvp2=0'
		}
		query = query.toLowerCase();

		var current_href;
		var base_url;
		var orginal_query;
		var new_query;

		// Fill url variable and set all the passed-in url to LowerCase
		current_href = surl;

		//alert(current_href);

		// Validate type of URL, do not add functionality to reserved extions (e.g. downloads like exe files)
		//if (checkUrl(myurl)) {
			// skip this URL!
		//  } else { 
			// Continue with URL modifications

			if ((current_href.indexOf(currentdomain) != -1) && (current_href.indexOf(query) <= 0) ){
				// Checks if the link contains a "?", it will ADD the new query in BETWEEN the old query and the new query
				if (current_href.indexOf('?') != -1) {
					base_url = current_href.substr(0,current_href.indexOf('?')+1);
					orginal_query = current_href.substr(current_href.indexOf('?')+1);
					new_query = base_url + query + "&" + orginal_query;
					current_href = new_query;
				} else {
				  // Checks if the link contains .asp, it will ADD a "?" to the string AND the new query
				  if (current_href.indexOf('.asp') != -1) {
					  current_href = current_href + "?" + query;
				  } else {
					// Checks if the link contains NO PAGE (thus a slash on the end), it will ADD "index.asp?" to the string AND the new query
					if (current_href.substr(current_href.length-1,current_href.length-1) == "/") {
						current_href = current_href + "index.asp?" + query;
					} else {
					  if ((current_href.substr(current_href.length-4,current_href.length-4) != ".asp") && (current_href.substr(current_href.length-4,current_href.length-4) != ".htm") &&
					  (current_href.substr(current_href.length-5,current_href.length-5) != ".html") &&
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".exe") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".doc") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".xls") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".swf") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".pdf") && 
					  (current_href.substr(current_href.length-4,current_href.length-4) != ".mp3") && 

(current_href.substr(current_href.length-4,current_href.length-4) != ".zip") &&
(current_href.substr(current_href.length-4,current_href.length-4) != ".hqx") &&
(current_href.substr(current_href.length-4,current_href.length-4) != ".sit") &&					  (current_href.substr(current_href.length-4,current_href.length-4) != ".ppt")) {
						current_href = current_href + "/index.asp?" + query;
					  }
					}
				  }
				}
			  } 

		//  }
		
		// Return back the current_href contents to the caller //
		return current_href;
	}


	/* Repopulate selectboxes using RemoteScripting - written by Dennis van Heezik on 22th January 2004 */

	// Global variables for the selectBoxes and RemoteScripting

	var sCurrentType = "";
	var bCountrySelected = false;
	var bProfessionSelected = false;

	// Temporary placeholder for the selectionbox repopulation procedure
	var sSelected = "";

	
	// Three functions related to the processing popup window - by DvH on 13th April 2004
	// Use a file for displaying temporary window (e.g. /opp_popup_processing.asp)
	// Syntax - part 1: use the following on a button or link: onclick="showProcPopUp();setTimeout('doIt()',1000)"
	//					where doIt() stands for the function which performs the FULL action (kill the popup in part 2!)
	// Syntax - part 2: call hideProcPopUp(); at the END of your function
	function procPopUp(URL, pageid, action) {
		if (action == "open"){
			var w = "200"
			var h = "100"
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
			eval("page" + pageid + " = window." + action + "(URL, '" + pageid + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left = " + winl + ",top = " + wint + "');");
			} 
		if (action == "close"){
			eval("page" + pageid + "." + action + "();");
			}
	}

	function hideLoadingMsg() {
	  //procPopUp('/GARClass/definitions/opp/rs/opp_popup_processing.asp', 'processor', 'close');
	  
	  //DISABLED THE LOADING... MESSAGE ON 22ND JULY 2004, TO IMPLEMENT WIDER HELP TEXT COLUMN
	  //document.getElementById('helptext_' + sFormFieldType).innerHTML = ''
	}


	function showLoadingMsg(sType) {
	  //procPopUp('/GARClass/definitions/opp/rs/opp_popup_processing.asp?msg=' + msg, 'processor', 'open');
	  
	  //DISABLED THE LOADING... MESSAGE ON 22ND JULY 2004, TO IMPLEMENT WIDER HELP TEXT COLUMN
	  //document.getElementById('helptext_' + sType).innerHTML = JS_ADDITIONAL_FIELD1
	}
	// End of processing popup windows

	function showMore(sType,sRegAreaPath){
			//alert('hi!');


        
		// First check whether the selected value is from the "More..." element, if so, then continue, else do nothing!
			showLoadingMsg(sType);
			//alert(sType);
			//debugger
			sSelected = document.forms['userdets'].elements[sType].value;

			if (sType == 'country') {	
				bCountrySelected = true;
				//if (sSelected == "-1" || sSelected == "-99") {
				if (sSelected == "-1") {
					// More... or Select Countries has been selected
					sSelected = "0";
					getAllListData(sType, sSelected, sRegAreaPath);
				} else {
					clearSelectBox("profession");
					getAllListData("profession", sSelected, sRegAreaPath);
				}
			} else {
				if (sSelected == "-1"){
					if (sType == 'profession') {
						bProfessionSelected = true;
						clearSelectBox(sType);
						sSelected = "0";
						getAllListData(sType, sSelected, sRegAreaPath);
					} else {
						alert('cannot populate, no select box avaialable');
					}
				}
			}	
			sFormFieldType = sType;
			setTimeout('hideLoadingMsg()',1000);
			//hideLoadingMsg(sType)
	}

  function chk_length_min_change(o,msg,lmin,lmax){
   if(selectvalue=="16")
	  {
			if ((o.value.length =="6") || (o.value.length =="8" ) || (o.value.length =="11" ) )
			{
			   return true;          
			}
		  else
		    {
             Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.",msg);
		    }
	  }
	  else if (selectvalue=="95")
	  {
			if ((o.value.length =="8" ) || (o.value.length =="11" ) )
			{
			   return true;          
			}
			else
			 {
				 Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.",msg);
			 }
	  }
	  else
	  {
		  if ((o.value.length < lmin) || (o.value.length > lmax))
            {
               Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.",msg);          
            }

	  }
  }
  
  function chk_length_max_change(o,msg,lmin,lmax){
	  
    if(selectvalue=="16")
	  {
			if ((o.value.length =="6") || (o.value.length =="8" ) || (o.value.length =="11" ) )
			{
			   return true;          
			}
		  else
		    {
             Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.","Numéro INAMI ou code APB incorrect");
		    }
	  }
	  else if (selectvalue=="95")
	  {
			if ((o.value.length =="8" ) || (o.value.length =="11" ) )
			{
			   return true;          
			}
			else
			 {
				 Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.","Numéro INAMI ou code APB incorrect");
			 }
	  }
	  else
	  {
		  if ((o.value.length < lmin) || (o.value.length > lmax))
            {
               Message(o," -- Must be at least " + lmin + " and maximal " + lmax + " characters long.",msg);          
            }

	  }
  }



	function clearSelectBox(sType){
		var i
		var formLength
		// Possibility to case for different versions, not implemented yet.
		//case 'NS':
		//  document.forms['userdets'].elements[sType].length;
		//case 'IE':
		//  document.forms['userdets'][sType].length;
		formLength = document.forms['userdets'].elements[sType].length
		for(i=0;i<formLength;i++)
		{
			document.forms['userdets'].elements[sType].options[1] = null;
		}
	}

	function fillSelectBox(sType, arrList){

		// Start from position 1, not 0, because we would like to keep the header, e.g. "Select Country"
		// This is done by using i=2 and length+2, i-2 and i-1.

		var selectBox = document.forms['userdets'].elements[sType];
		var newList = arrList;

		for(i=2;i<newList.length+2;i+=2){
			// Check if a [[SELECTED]] is given back from the database, if so, set the option to the state "selected"
			if (newList[i-1].indexOf("[[SELECTED]]") != -1) {
				var sCurrentlySelected = newList[i-1]
				var rExp;
				rExp = /\[\[SELECTED\]\]/gi;
				sCurrentlySelected = sCurrentlySelected.replace(rExp, "");
				selectBox.options[i/2] = new Option(sCurrentlySelected,newList[i-2],true,true);
			} else {
				selectBox.options[i/2] = new Option(newList[i-1],newList[i-2],false,false);
			}
		}

		// Add a More... button to the profession list, if a country was selected.
		//if ((bCountrySelected == true) && (sSelected != "0")){
			//var selectBoxLength;
			//selectBoxLength = selectBox.length;
			//selectBox.options[selectBoxLength] = new Option('More...','-1',false,false);
		//}

		// Set all booleans back to false (until a new call is made!)
		bCountrySelected = false;
		bProfessionSelected = false;
	}


	function getAllListData(sType, sSelected, sRegAreaPath){
		sCurrentType = sType;
		//alert(sSelected);
		getRSListData(sType, sSelected, sRegAreaPath);
	}

	function getRSListData(sType, sSelected, sRegAreaPath) {
		var sSubmit
		sSubmit = sType + ";" + sSelected + ";" + sRegAreaPath
		jsrsPOST = false;
		var iResult = jsrsExecute("/GARClass/definitions/opp/rs/remoteScriptingJS.asp", getListDataCallback, "fncVBGetListData", sSubmit);
		
	}

	function getListDataCallback( returnstring ){
			
		var sResult
		sResult = returnstring

		//alert(sResult);

		var sOutput
		sOutput = "";

		var sList
		sList = ""


		var arrList = new Array();

		// Split the return string using the ;|; separator and create a string separated by a comma and strings between quotes
		splitString = sResult.split(";|;")
		for (i=0; i<splitString.length; i=i+2){
			arrList[i] = splitString[i]
			arrList[i+1] = splitString[i+1]
			
		}
		
		// Fill the selectBox
		//document.getElementById('getlistdata').innerHTML = arrList.length ;

		fillSelectBox(sCurrentType, arrList);
	}

	function validateLoginForm(iType,lSizeW,lSizeH) {
		Chk_Form(iType,lSizeW,lSizeH);
		if (ErrorBln) {
		  return false;
		}
	}
	function validateLoginForm_Cardio(iType,lSizeW,lSizeH) {
	Chk_Form(iType,lSizeW,lSizeH);

	if(is.ie)
	{
		document.getElementById("msgcontainer").style.marginLeft = '-710px';
		document.getElementById("msgcontainer").style.marginTop = '-600px';		
	}
	
	if (BrowserDetect.browser =="Explorer" && BrowserDetect.version == 7 )
	{
		document.getElementById("msgcontainer").style.marginLeft = '-710px';
		document.getElementById("msgcontainer").style.marginTop = '-120px';	
		document.getElementById("selectblocker").style.height = '160px';	
	}
	
		if (ErrorBln) {
		  return false;
		}
	}

	function validateLoginForm_Upgrade(iType,lSizeW,lSizeH) 
	{
	Chk_Form(iType,lSizeW,lSizeH);

	if(is.ns)
	{
		document.getElementById("msgcontainer").style.marginLeft = '-500px';
		document.getElementById("msgcontainer").style.marginTop = '200px';		
	}

	var oEmbeddedErrorBlock;
	if (ErrorBln) {
	  return false;
	}
	}

	// ----------------------------------------------------
	// FUNCTION INTRODUCED FOR THE DOCCHECK IMPLEMENTATION
	// ----------------------------------------------------
	function setFormValidationPage(iType,lSizeW,lSizeH)
	// Check if we have to post to DocCheck or to the regular VIP process page
	{
		if(document.userdets.validation[0].checked == true) {
		document.userdets.action = 'http://login.doccheck.com';
		document.userdets.name.value = document.userdets.username.value;
		return true;
		}
		if(document.userdets.validation[1].checked == true) {
		document.userdets.action = 'opp_login_process.asp';
			validateLoginForm(iType,lSizeW,lSizeH)
			if (ErrorBln) {
			  return false;
			}
		}
	}


  // ----------------------------------------------------------------------------------
  // GENERAL FUNCTIONS FOR REPOSITIONING AND HIDING OF CUSTOM, RICH HTML MESSAGES BOXES
  // ----------------------------------------------------------------------------------

	function DispHTMLError(ErrorMsg,lSizeW,lSizeH){

		var sMessage;
		var sMessageTitle;

		// Popup reminder link implementation!
		var sReplace1;
		var sReplace2;
		
		sReplace1 = "<a href=\"javascript:parent.opp_popup('" + JS_REG_AREA_URL + "authfiles/opp_popup_reminder.asp','reminder','600','220','no');\" class=\"opp_regarea_error_text\">";
		sReplace2 = "</a>";
		ErrorMsg = ErrorMsg.replace(/\[\[popupreminder\]\]/gi, sReplace1);
		ErrorMsg = ErrorMsg.replace(/\[\[\/popupreminder\]\]/gi, sReplace2);

		// replace [ and ] tags with the necessary HTML tags: < and > 
		var regexp;
		var strnew;

		regexp1 = /\[/gi;
		regexp2 = /\]/gi;

		ErrorMsg = ErrorMsg.replace(regexp1, "<");
		ErrorMsg = ErrorMsg.replace(regexp2, ">");

		var oEmbeddedErrorBlock;
		if (is.ie || is.ns5 || is.ns6) {
			oEmbeddedErrorBlock = document.getElementById("errortable");
		}
		else{
		}
		
		//If an errortable object exists then write error messages there, else show them in a popup
		if(oEmbeddedErrorBlock != null){
			var sErrorTable = "";
			sErrorTable += "<table cellSpacing='0' cellPadding='2' border='0'>";
			sErrorTable += "<tr><td width='13' class='validation'><img src='/GARClass/definitions/opp/images/imgs/error_image_exclamation.gif' width='8' height='11'></td>";
			sErrorTable += "<td width='404' height='24' class='validation'><strong>Please correct the following fields:</strong></td>";
			sErrorTable += "</tr></table>";
			sErrorTable += "<table width='94%'  border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>";
			sErrorTable += "<tr><td><table border=0 cellPadding=3 cellSpacing=0 bgcolor='#F5F9FC'>";
			sErrorTable += ErrorMsg
			sErrorTable += "</table></td></tr></table>";
			oEmbeddedErrorBlock.innerHTML = sErrorTable;
		}
		else{
			// Build HTML errorbox message 
			sMessage = "<table width='100%' cellpadding='0' cellspacing='0' border='0' class='PopUpText'>"
			sMessage = sMessage + "<tr><td height='5'><img src='/GARClass/definitions/opp/images/trans.gif' width='1' height'5'></td></tr>"
			sMessage = sMessage + "<tr><td width='100%'><b>"
			sMessage = sMessage + JS_FORM_ENTRIES1
			sMessage = sMessage + "</b></td></tr>"
			sMessage = sMessage + "<tr><td height='10'><img src='/GARClass/definitions/opp/images/trans.gif' width='1' height'10'></td></tr>"
			sMessage = sMessage + "<tr><td width='100%'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='PopUpText'>"
			sMessage = sMessage + ErrorMsg
			sMessage = sMessage + "</table></td></tr>"
			sMessage = sMessage + "<tr><td height='10'><img src='/GARClass/definitions/opp/images/trans.gif' width='1' height'10'></td></tr>"
			sMessage = sMessage + "<tr><td width='100%'><i>"
			sMessage = sMessage + JS_FORM_ENTRIES2
			sMessage = sMessage + "</i></td></tr>"
			sMessage = sMessage + "</table>"
		
			//sMessage = ErrorMsg;
			sMessageTitle = JS_FORM_ERROR;
			sMessageButtonText = " " + JS_FORM_RESUBMIT + " ";
			DispMsg(sMessage,sMessageTitle,lSizeW,lSizeH);
		}

	}

	
	var minWidth,minHeight;
	minWidth = 0;
	minHeight = 0;
	function RepMsg(lSizeW,lSizeH) {
		if (lSizeW == 0) lSizeW = 2;
		if (lSizeH == 0) lSizeH = 3;
		var oMsgBox=document.getElementById("msgcontainer");
		ns4 = (document.layers)? true:false;
		ie4 = (document.all)? true:false;
		winwidth = (ns4)? window.innerWidth : document.body.offsetWidth;
		//alert(document.body.offsetHeight);
		winheight = (ns4)? window.innerHeight : document.body.offsetHeight;
		if (winwidth < 300) minmsgwidth = ( winwidth * 0.9 );
		else minmsgwidth = 300;
		if (winheight < 150) minmsgheight = ( winheight * 0.9 );
		else minmsgheight = 150;
		msgwidth = (winwidth / lSizeW);
		msgheight = winheight / lSizeH; 
		if ( msgwidth < minmsgwidth ) msgwidth = minmsgwidth;
		if ( msgheight < minmsgheight ) msgheight = minmsgheight;
		msgleft = ( winwidth / 2 ) - ( msgwidth / 2 ); 
		msgtop = ( winheight / 2.5 ) - ( msgheight / 2 );
		if (oMsgBox != null)
		{
			oMsgBox.style.pixelTop = msgtop;
			oMsgBox.style.pixelLeft =  msgleft;
			oMsgBox.style.pixelWidth = msgwidth;
			oMsgBox.style.pixelHeight = msgheight;
		}
		if (document.getElementById("selectblocker") != null)
		{
			document.getElementById("selectblocker").style.pixelWidth = msgwidth;
			document.getElementById("selectblocker").style.pixelHeight = msgheight;			
		}
	}


	function CloseMsg(){
    var oMsgBox=document.getElementById("msgcontainer");
		oMsgBox.style.visibility = "hidden";
	}

    function DispMsg(sMessage,sMessageTitle,lSizeW,lSizeH){
		var oMsgBox=document.getElementById('msgcontainer');
		RepMsg(lSizeW,lSizeH);
        if(window.navigator.appName == "Microsoft Internet Explorer")
        {
			document.frames('selectblocker').document.all.MsgBody.innerHTML = sMessage;
			document.frames('selectblocker').document.all.MsgTitle.innerHTML = sMessageTitle;
			document.frames('selectblocker').document.all.MsgButtonText.value = sMessageButtonText;
        }
        else
        {
			document.getElementById('selectblocker').contentDocument.all.MsgBody.innerHTML = sMessage;
			document.getElementById('selectblocker').contentDocument.all.MsgTitle.innerHTML = sMessageTitle;
			document.getElementById('selectblocker').contentDocument.all.MsgButtonText.value = sMessageButtonText;
        }
		oMsgBox.style.visibility = 'visible';
		ie4 = (document.all)? true:false;
		if (ie4) oMsgBox.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#666666, Direction=135, Strength=5)';
		}

	function getElement(elementID)
	{
		return (document.getElementById) ? document.getElementById(elementID) : document.all[elementID];
		//return document.getElementById(elementID);
		
	}
	
	function clearErrorTable()
	{
		var elem;
		elem=document.getElementById("opp_error_control");
		elem.innerHTML="";
	}

/* End Client side Error handling Functions */