<!--
var HelpWindow = null;

function OpenHelpWindow(url,w,h) {
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	winstyle = 'width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',status=no,toolbar=no,menubar=no,scrollbars=yes,location=no';
	HelpWindow = window.open(url,'Help',winstyle);
}

function submitForm(WhatForm) {
	WhatForm.submit();
}

function submitAndValidateForm(WhatForm,WhatUrl) {
  if (validate_form()){
		WhatForm.action = WhatUrl;
		WhatForm.submit();
		return true;
  }
  else
  {
	return false;
  }
}


function trimAll(sString) 
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function validate_length(txtInput,minLength) {
	return (txtInput.length >= minLength); // returns false if empty
}

function validate_min_length(txtInput,minLength) {   
    if (txtInput == '')
    {
        return true
    }else
    {	
    txtInput = trimAll(txtInput)           
	return (txtInput.length >= minLength) // returns false if too short
    }
}

function validate_max_length(txtInput,maxLength) {       
    if (txtInput == '')
    {
        return true
    }else
      {
        txtInput = trimAll(txtInput)    
        return (txtInput.length <= maxLength); // returns false if too long
    }	
}

function validate_min_value(numInput,minValue) {
    if (numInput == '')
        {
        return true
        }
    else
    {                
       diff = parseFloat(numInput.replace(/,/,'.')) - parseFloat(minValue.replace(/,/,'.'))
       if (diff >= 0){
           return true
           }
       else
           {
           return false}
    }
}

function validate_max_value(numInput,maxValue) {
    if (numInput == '')
        {
        return true
        }
    else
        {
        diff = parseFloat(numInput.replace(/,/,'.')) - parseFloat(maxValue.replace(/,/,'.'))       
        if (diff <= 0){
           return true
           }
        else
           {
           return false}      
    }
}

function validate_Integer(numInput)
{   
    if (numInput.indexOf('.') != -1)
    {
        return false;
    }
    
    if (isNaN(numInput))
    {
        return false;
    }else
    {
        return true;
    }
}

function validate_Float(numInput)
{   
    if (numInput == '')
    {
        return true
    }else
    {
        re = /^([-]?)([0-9])*([,.][0-9]+)?$/  

	    return (re.test(numInput))    
    }

}

function validate_is_numeric(iValue) {
    if (iValue == '')
    {
        return true
    }else
    {
	re = /^(\d){1,}$/
	return (re.test(iValue))
    }
	
}

function validate_is_numericdecimal(iValue) {   //check if integer or decimal value, both are allowed for decimal values
    if (iValue == '')
    {
        return true
    }else
    {
	re1 = /^([-]?)([0-9])*([,.][0-9]+)?$/ 
	re2 = /^(\d){1,}$/	            
	if (re1.test(iValue) == false)          //if not decimal value
	    {
	      return (re2.test(iValue))         //check if integer
	       }
	else{
	      return (re1.test(iValue))
        }
    }
}

function validate_not_empty(text) {  	
	re = /\S/;
	return (re.test(text)) 
}

// use this function for validation of an email address list (addresses separated by comma)
function validate_email_list(strAddr) {
  arrAddr = strAddr.split(",")
  for (var countAddr=0; countAddr < arrAddr.length; countAddr++)
    {
      if (!validate_email(arrAddr[countAddr],1)) {
        return false;
      }
    }
  return true;
}

function validate_email(addr,man,alertmsg) {

	var ErrMandatory = 'Email address is missing.';
	var ErrInvalidChars = 'Email address contains invalid characters.';
	var ErrInvalidGeneral = 'Email address is not valid.';
	
	if (addr == '' && man) {
	   if (alertmsg) alert(ErrMandatory);
	   return false;
	}

	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (alertmsg) alert(ErrInvalidChars);
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (alertmsg) alert(ErrInvalidChars);
		  return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if (atPos == -1 && addr != '') {
	   //if (alertmsg) alert('Email address must contain an @.');
	   if (alertmsg) alert(ErrInvalidGeneral);
	   return false;
	}
	if (atPos == 0 && addr != '') {
	   if (alertmsg) alert('Email address must not start with @.');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1 && addr != '') {
	   if (alertmsg) alert('Email address must contain only one @.');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1 && addr != '') {
	   if (alertmsg) alert('Email address must contain a period in the domain name.');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1 && addr != '') {
	   if (alertmsg) alert('Period must not immediately follow @ in email address.');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1 && addr != ''){
	   if (alertmsg) alert('Period must not immediately precede @ in email address.');
	   return false;
	}
	if (addr.indexOf('..',0) != -1 && addr != '') {
	   if (alertmsg) alert('Two periods must not be adjacent in email address.');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum' && addr != '') {
	   if (alertmsg) alert('Invalid primary domain in email address.');
	   return false;
	}
return true;
}

function validate_rb_cb(what) {
  iLength = what.length;
  if (!iLength) 
	{
	if (what.checked == true) 
		{
		  return true;
		}
		else
		{ 
		  return false;
		}
	}
	else;
	{
	  for (i=0; i<what.length; i++) {
		if (what[i].checked) {
		  return true;
		}
	  }
	  return false;
	}
}

function validate_check_no_spaces(formObj){
	var invalidChars = " ";
	for(var i = 0; i < invalidChars.length; i++){
		if(formObj.indexOf(invalidChars.charAt(i)) != -1){
		return false;
		}
	}
}

//NOT NEEDED! MOVED TO FUNCTION BELOW!
function validate_date(formObj){
    re = /^S*$|^[(1-2)]{1}[(9,0)]{1}[(0-9)]{1}[(0-9)]{1}[-][(0-1)]{1}[(0-9)]{1}[-][(0-3)]{1}[(0-9)]{1}$/;
	return (re.test(formObj)) 
	}
	
	
function IsValidDate(strDate)
{
		
	var intYear = strDate.substr(0 , 4);	// Year typed by user
	var intMonth = strDate.substr(5 , 2);	// Month typed by user
	
	if (strDate == ''){
        return true;
	}
	
    //Dateformat is YYYY-MM-DD
    if(!/^S*$|^[(1-2)]{1}[(9,0)]{1}[(0-9)]{1}[(0-9)]{1}[-][(0-1)]{1}[(0-9)]{1}[-][(0-3)]{1}[(0-9)]{1}$/.test(strDate)){
        return false;
        }
        
	// Month cant be bigger than 12
	if (strDate.substr(5 , 2) > 12) {
		return false; 
	}	
	
	// Month cant be smaller than 01
		if (strDate.substr(5 , 2) < 01) {
		return false; 
	}		
	
	if (intMonth == 0) {return false; }

	// Months with 30 days
	if (intMonth == 4 ||
		intMonth == 6 ||
		intMonth == 9 ||
		intMonth == 11) {
		if (strDate.substr(8, 2) > 30){return false;}
	}

	
	if (strDate.substr(8 , 2) == '00') {return false;}

	// Months with 31 days
	if (intMonth == 1 ||
		intMonth == 3 ||
		intMonth == 5 || 
		intMonth == 7 || 
		intMonth == 8 || 
		intMonth == 10 || 
		intMonth == 12) {
		if (strDate.substr(8 , 2) > 31){return false;}
	}
	
	// Day can't be smaller than 01
	if (strDate.substr(8 , 2) < 01){return false;}

	// February
	if (intMonth == 2) {
		if (strDate.substr(8 , 2) > 29){return false;}
	}
	
	return true;
	
}


function check_email(addr) {
  if(!/^.+@.+\..+$/.test(addr) && (addr != ""))
	return false;
  else;
	return true;
}

function check_email_man(addr) {
  if(!/^.+@.+\..+$/.test(addr))
	return false;
  else;
	return true;
}

function check_email_tmp(addr,man) {
  if (man) {
	if (!/^.+@.+\..+$/.test(addr))
      return false;
    }
  else;
    {
    if (!/^.+@.+\..+$/.test(addr) && (addr != ""))
	  return false;
    }
}

function reloadPage(file,target) {
    if (target != '')
        target.window.location.href = file;
    else
        window.location.href = file;
}

function checkAll(formObj) {
	var chkStatus = formObj.selectAll.checked

	for (var i=0;i<formObj.elements.length;i++){
	var e = formObj.elements[i];
		if (e.name != 'selectAll')
			e.checked = chkStatus
	}
}

function IsAnyCheckboxSelected(formObj) {
	var bChecked = false

	for(var i = 0; i < formObj.elements.length; i++){
		if(formObj.elements[i].type == "checkbox"){
			if(formObj.elements[i].checked){
				return true;
			}
		}
	}
}

function SelectAll(cbfield,hfield)
{
	var bAllChecked = hfield.value

	if(bAllChecked == "false")
	{

	for (i=0;i<cbfield.length;i++)
	{
		cbfield[i].checked = true
	}
	hfield.value = "true"
	
	}
	else
	{

	for (i=0;i<cbfield.length;i++)
	{
		cbfield[i].checked = false
	}
	hfield.value = "false"
	}
}

// value for the "blank" Option used to end the list:
//
var blankText = "                    ";

// move selected items from one list to the other
//
function selMove( sFrom, sTo, doAll )
{
    // go through forwards, moving items to the "to" list:
    var ix;
    // where we start putting new values...
    toLoc = sTo.options.length - 1;

    for ( ix = 0; ix < sFrom.options.length; ++ix )
    {
        sopt = sFrom.options[ix];
        if ( ( sopt.value != 0 ) && ( doAll || sopt.selected ) )
        {
            // replace or append our new option...
            sTo.options[toLoc] = new Option( sopt.text, sopt.value );
            ++toLoc; 
        }
        // tack a new "blank" option onto end, to act
        // as a minimum width for the Select list:
        sTo.options[toLoc] = new Option( blankText, 0 ); // 0 value item?
    }
    // then go backwards, removing selected options
    for ( ix = sFrom.options.length - 1; ix >= 0; --ix )
    {
        sopt = sFrom.options[ix];
        if ( ( sopt.value != 0 ) && ( doAll || sopt.selected ) )
        {
            sFrom.options[ix] = null;
        }
    }
}

function forceSelect( which )
{
    var ix;
    for ( ix = 0; ix < which.options.length; ++ix )
    {
        sopt = which.options[ix];
        if ( sopt.value != 0 ) // if not the dummy item
        {
            sopt.selected = true;
        } else {
            sopt.selected = false; // ensure dummy not selected
        }
    }
}

function hLayer(namn, varde) {        //view or hide the tooltip
  if (document.all) {				//for ie
    document.all[namn].style.visibility=varde;
  }
  else if (document.layers) {			//for netscape
    document.layers[namn].visibility=varde;         
  }
}

var namn;
var varde;
var mu = 0;

function setactiveitem(itemnamn, itemvarde) {
  //namn = itemnamn;
  //varde = itemvarde;
}

function tooltip(e, namn, varde) {        //view or hide the tooltip
  if (document.all) {				//for ie
    document.all[namn].style.left=event.x-12;
    document.all[namn].style.top=event.y-40;
    document.all[namn].style.visibility=varde;

  }
  else if (document.layers) {			//for netscape
    document.layers[namn].left=e.pageX-12;
    document.layers[namn].top=e.pageY-40;
    document.layers[namn].visibility=varde;         
  }
}

// Function used to trim content of a form element
function TrimFormFieldInput(field, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
}

//Status bar
function on(txt) {
	parent.self.status = txt
}

function off() {
	parent.self.status = ""
}

//function IsValidDate(value) NOT NEEDED! MOVED TO FUNCTION ABOVE!!
//{
 
 // Applies to date format YYYY-MM-DD
 //var rExp = /^S*$|^[(1-2)]{1}[(9,0)]{1}[(0-9)]{1}[(0-9)]{1}[-][(0-1)]{1}[(0-9)]{1}[-][(0-3)]{1}[(0-9)]{1}$/;
  
 //return (rExp.test(value))


//}  
//-->
