var whitespace = " \t\n\r";

// Check or uncheck checkboxes
function ChkBoxSwitch(chkb,id,fgcol,bgcol){
if(document.getElementById){
	if(chkb.checked){
	document.getElementById(id).style.backgroundColor = fgcol;
	}else{
	document.getElementById(id).style.backgroundColor = bgcol;
}
}else{

}
}

// check or uncheck all checkboxes within one form
function CheckUncheckAll(till,checkvalue,bgcol,fgcol)
{
	if(document.getElementById(checkvalue).checked == false){
	
	
		for (i=0; i<till; i++){
		var bx = "box"+i;
		var tr = "darow"+i;
		var c = document.getElementById(bx);
		var d = document.getElementById(tr);
		d.style.backgroundColor = bgcol;
		c.checked = true;
		}
	var ret = "Uncheck all";
	}else{
	
	
		for (i=0; i<till; i++){
		var bx = "box"+i;
		var tr = "darow"+i;
		var c = document.getElementById(bx);
		var d = document.getElementById(tr);
		
			//Modulo 
			if(i%2){
			d.style.backgroundColor = "#ffffff";
			}else{
			d.style.backgroundColor = fgcol;
			}
		c.checked = false;
		}
		
	var ret = "Check all";
	}
return ret;
}




function Changegrfx(id,src)
{
document.getElementById(id).src = src;
}


function ShowHideDiv(id,style)
{
document.getElementById(id).style.visibility = style;
}


function MakePagePrintable()
{
document.getElementsById(redheader).style.visibility = 'hidden';
document.getElementsById(mainnavigation).style.visibility = 'hidden';
document.getElementsById(headernavigation).style.visibility = 'hidden';
}

// PopUpWindowGenerator

// url= zu öffnende url
// windowname = name des fensters
// breite = Breite des Fensters
// hoehe = Hoehe des Fensters
// scroll = Scrollbar (yes or no)
// rez = rezisable (yes or no)
// tool = Toolbar (yes or no)
// menu = Menubar (yes or no)
// horz = horizontale Ausrichtung (center or left or right)
// vert = vertikale Ausrichtung (top or middle or bottom)
function PopUpWindow(url,windowname,breite,hoehe,scroll,rez,tool,menu,loc,horz,vert)
{


var url;
var windowname;
var breite;
var hoehe;
var scroll;
var rez;
var tool;
var menu;
var loc;
var winl;
var wint;
var horz;
var vert;


// Berechnen von wint
if(vert=='top')
{
wint = 0;
}

if(vert=='middle')
{
wint = (screen.height - hoehe) / 2;
}

if(vert=='bottom')
{
wint = (screen.height - hoehe);
}
// Ende Berechnen von wint

		// Funktionsaufruf mit horz
		if(horz=='center')
		{
		winl = (screen.width - breite) / 2;
		popupwindow = 
		window.open(url,windowname, 'width='+breite+',height='+hoehe+',screenX='+winl+',screenY='+wint+',left='+winl+',top='+wint+',scrollbars='+scroll+',resizable='+rez+',toolbar='+tool+',menubar='+menu+',location='+loc);
		popupwindow.focus();
		}
		else
		{
			if(horz=='left')
			{
			winl = 0;
			popupwindow = 
			window.open(url,windowname, 'width='+breite+',height='+hoehe+',screenX='+winl+',screenY='+wint+',left='+winl+',top='+wint+',scrollbars='+scroll+',resizable='+rez+',toolbar='+tool+',menubar='+menu+',location='+loc);
			popupwindow.focus();
			
			}
			
			if(horz=='right')
			{
			winl = (screen.width - breite);
			popupwindow = 
			window.open(url,windowname, 'width='+breite+',height='+hoehe+',screenX='+winl+',screenY='+wint+',left='+winl+',top='+wint+',scrollbars='+scroll+',resizable='+rez+',toolbar='+tool+',menubar='+menu+',location='+loc);
			popupwindow.focus();
			
			}
		
		
		}
		// Ende Funktionsaufruf mit horz

// Funnktion schliessen
}



function clpSet(txt)
{
sel = document.selection.createRange();
window.clipboardData.setData("Text",txt);
}


function confirm_delete(x,y,url){
	var x;
	var y;
	var url;
	
	
	input_box=confirm("Are you sure you d'like to delete record  "+x+" ?");
		if (input_box==true)

		{ 
		// redirect when OK
		window.location = url; 
		}

		else
		{

		}

}


function confirmation_box(message,trueurl)
{
var message;
var trueurl;
	
	input_box = confirm(""+message+"")
	if(input_box==true)
	{
	window.location = trueurl; 
	}
	else
	{
	
	}



}


function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_findObj(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=MM_findObj(n,d.layers[i].document); return x;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function openWin(myWin, width, height) {
  win = open(myWin, "displayWindow", "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,width="+width+",height="+height);
  win.focus();
}

function openMaxWin(myWin) {
  win = open(myWin, "displayWindow", "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,width=800,height=600");
  maximize(win);
  win.focus();
}

function maximize(window) {
  window.moveTo(0,0);
  if (navigator.appName == "Microsoft Internet Explorer") {
    window.resizeTo(screen.availWidth,screen.availHeight);
  }
  else {
    window.innerWidth = screen.width;
    window.innerHeight = screen.height;
    window.screenX = 0;
    window.screenY = 0;
  }
}

// Function to setup PBS contact context
// for context sensitivity
//
// Page should set values for the two variables, which the
// contact handler knows how to interpret
var pbs_contactContext = null;
var pbs_contactContextParam = null;

function pbs_contact(baseUrl) {
  url = baseUrl;

  if (pbs_contactContext != null) {
    url += "?context=" + encodeURIComponent(pbs_contactContext);

    if (pbs_contactContextParam != null) {
      url += "&param=" + encodeURIComponent(pbs_contactContextParam);
    }
  }

	link = document.getElementById("contactLink");
	link.href = url;

	link = document.getElementById("enquiryLink1");
	if (link != null) {
	  link.href = url;
	}

	link = document.getElementById("enquiryLink2");
	if (link != null) {
	  link.href = url;
	}
}


// functions used by the S2K/coremotion flash applicaitons

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function DYO_admin_DoFSCommand(command, args) {
	var DYO_adminObj = isInternetExplorer ? document.all.DYO_admin : document.DYO_admin;
 if (command == "messagebox") {
 alert(args);
 }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub DYO_admin_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call DYO_admin_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function DYO_DoFSCommand(command, args) {
	var DYOObj = isInternetExplorer ? document.all.DYO : document.DYO;
 if (command == "messagebox") {
 alert(args);
 }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub DYO_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call DYO_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

