

function NewWindow(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2) - 40;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function debug_layout(show_back_color){
	
	var TagsToCheck = new Array()
	TagsToCheck[0] = 'TABLE';
	TagsToCheck[1] = 'TR';
	TagsToCheck[2] = 'TD';
	TagsToCheck[3] = 'UL';
	TagsToCheck[4] = 'LI';
	TagsToCheck[5] = 'A';
	TagsToCheck[6] = 'DIV';
	TagsToCheck[7] = 'FORM';
	TagsToCheck[8] = 'INPUT';
	TagsToCheck[9] = 'IMG';
	
	var DocElements;
	var BackColor;
	
	for (var a=0; a<TagsToCheck.length; a++){
	
	 	DocElements = document.getElementsByTagName(TagsToCheck[a]);
	 	
	 	BackColor = RandomColor();
		 document.write('<font color=' + BackColor + '>' + TagsToCheck[a] + ' x ' + DocElements.length +  '</font><br>');

		for (var b=0; b<DocElements.length; b++){
			 DocElements[b].style.border='1px solid #' + BackColor;
			 if(show_back_color){ DocElements[b].style.backgroundColor= BackColor;}
		}
	}	
}



function RandomColor() {

   var bg_red=Math.floor(256*Math.random());
   var bg_green=Math.floor(256*Math.random());
   var bg_blue=Math.floor(256*Math.random());
 
   var bg_RGB;

   bg_RGB=NumToHexString(bg_red);
   bg_RGB+=NumToHexString(bg_green);
   bg_RGB+=NumToHexString(bg_blue);

   return bg_RGB;
}



function NumToHexString(hexnumber) {
   var hexstring="";
   var hexchar;
   var hexones;
   var i=0;

   hexnumber=Math.floor(hexnumber);
   while (hexnumber != 0) {
       i++;
       hexones=hexnumber % 16;
       hexnumber -= hexones;
       hexnumber /= 16;

       if (hexones>9) {
	  if (hexones==10) hexchar="a";
	  if (hexones==11) hexchar="b";
	  if (hexones==12) hexchar="c";
	  if (hexones==13) hexchar="d";
	  if (hexones==14) hexchar="e";
	  if (hexones==15) hexchar="f";
       }
       else hexchar=hexones;

      hexstring = hexchar + hexstring;
   }

   for (;i<2;i++) {
      hexstring="0"+hexstring;
   }

   return hexstring;
}



function blurAnchors(){
  if(document.getElementsByTagName){
    var a = document.getElementsByTagName("a");
    for(var i = 0; i < a.length; i++){
      a[i].onfocus = function(){this.blur()};
    }
  }
}
window.onload = blurAnchors;

function validateMaillistForm()
{
	if ((document.forms['maillist'].elements['maillist_email'].value.indexOf('@') == -1) || (document.forms[maillist].elements['maillist_email'].value.indexOf('.') == -1)) {
		alert('The emailaddress is not valid');
		if (window.focus) document.forms['maillist'].elements['maillist_email'].focus()
		return false;
	}
	else
	{
	return true;	
	}
}

function validateFormField(FieldId)
{
	
	var FormField  = document.getElementById(FieldId);
	
	if (!FormField.value) {
		alert('Required Field');
		FormField.focus();
		return false;
	}
	else
	{
	return true;	
	}
}


function select_switchbox_options() {

	if (list_new){		
		for (i=0; i<m1.length; i++) { 
		m1.options[i].selected = true; 
		} 
	}

	if (list_del) {	
		for (i=0; i<m2.length; i++) { 
		m2.options[i].selected = true; 
		} 
	}
	
	return true;
}	

function switchbox_one2two() {
    
    m1len = m1.length ;
    for ( i=0; i<m1len ; i++){
        if (m1.options[i].selected == true ) {
            list_del = true;
            m2len = m2.length;
            m2.options[m2len]= new Option(m1.options[i].text,m1.options[i].value);
        }
    }

    for ( i = (m1len -1); i>=0; i--){
        if (m1.options[i].selected == true ) {
            m1.options[i] = null;
        }
    }
}

function switchbox_two2one() {
    
    m2len = m2.length ;
        for ( i=0; i<m2len ; i++){
            if (m2.options[i].selected == true ) {
                list_new = true;
                m1len = m1.length;
                m1.options[m1len]= new Option(m2.options[i].text,m2.options[i].value);
            }
        }
        for ( i=(m2len-1); i>=0; i--) {
            if (m2.options[i].selected == true ) {
                m2.options[i] = null;
            }
        }
}

function switch_objects(id1, id2){
		
		var pageobject1  = document.getElementById(id1);
		if(pageobject1){
		pageobject1.style.display='none';
		}
			
		var pageobject2  = document.getElementById(id2);
		if(pageobject2){
		pageobject2.style.display='inline';
		}
		
}