// JavaScript Document


function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}

/* =========================================================================================================== */

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_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; }
}

/* customised version of the Macromedia OpenWindow Behaviour
This makes sure that the newly opened window is always 
at the front i.e focussed */


function MM_openBrWindow(theURL,winName,features) { //v2.0
  var wintwo = window.open(theURL,winName,features);
  wintwo.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_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_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]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
	  if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
	
MM_reloadPage(true);

/* 
function showPrintIcon() {
	if (window.print) {
		document.write("<a title=\"Print\" href=\"javascript:window.print();\" >" )
		document.write("<img src=../scripts//"images/print.gif/" alt=\"Print\" width=\"15\" height=\"15\" hspace=\"2\" vspace=\"1\" border=\"0\"><br>Print</a>")
	}
}


function showFavouriteIcon() {
	if (window.print) {
		document.write("<a title=\"Add to favorites\" ")
		document.write("href=\"javascript:window.external.AddFavorite(location.href,document.title);\" >")
		document.write("<img src=../scripts//"images/star.gif/" alt=\"Add to favorites\" width=\"15\" height=\"15\" hspace=\"2\" vspace=\"1\" border=\"0\"><br>Favorite</a>")
	}
}
*/


function showFirstLayer() {
	var i,m,layer,args=showOther.arguments;

/*  Go through all the layers in the arguments list and hide them
	then show the first one on the list.
*/
	
	MM_showHideLayers(args[0],'','show') ;
    for (i=1; i<(args.length-1); i=i+1) {
		MM_showHideLayers(args[i],'','hide') ;
	}
}



//document.MM_returnValue = true;


//========================================================== //
// Set the variable that show whish page is curreclt selected in the 
// left hand navigation menu.  If No page is selected at the monet,
// the variable should be set to [""]
//========================================================== //

var arr_LeftNavSelected = [""];

//========================================================== //
//========================================================== //

//Powered by Softery.com
//Ver: 3//
function FlashSolver() {
n=navigator;
nav=n.appVersion.toLowerCase();
if ((nav.indexOf('win')!=-1) || (nav.indexOf('nt')!=-1)) 
	{
	if (navigator.appName == "Microsoft Internet Explorer")
		{
		var tmpObject = document.getElementsByTagName('object');
		if (tmpObject && tmpObject.length) 
			{
			for (var i = 0; i < tmpObject.length; i++) 
				{
				if (tmpObject[i].getAttribute('classid').toLowerCase() == 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000') 
					{
					var ps = tmpObject[i].getElementsByTagName('param');
					if (ps && ps != null)
						{
						for (var j = 0; j < ps.length; j++) 
							{
							if (ps[j].getAttribute('name').toLowerCase() == 'flashvars') 
								{
								var variables = ps[j].getAttribute('value');
								break;
								}
							}
						}
					var obj = tmpObject[i].outerHTML + "\n";
					obj = obj.replace(/FLASHVARS" VALUE=""/i,'FLASHVARS" value="'+variables+'"');
					tmpObject[i].outerHTML = obj;
					}
				}
			tmpObject = null;
			}
		}
	}
}


window.onunload = function()
{
n=navigator;
nav=n.appVersion.toLowerCase();
if ((nav.indexOf('win')!=-1) || (nav.indexOf('nt')!=-1)) 
	{
	if (navigator.appName == "Microsoft Internet Explorer")
		{
		if (document.getElementsByTagName) 
			{
			var tmpObject = document.getElementsByTagName("object"); 
			for (i=0; i<tmpObject.length; i++)
				{
				tmpObject[i].outerHTML = ""; 
				}
			}
		}
	}
}


/* end of flashsolver */
/* ======================================================================= */


function writeCookie(cookieName, cookieValue, expiry) {
	var expDate = new Date();
	if(expiry) {
		expDate.setTime (expDate.getTime() + expiry);
		document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
	}
	else {
		document.cookie = cookieName + "=" + escape (cookieValue);
	}
}



function cookieThis(theInput) {
	alert("writing " + theInput.name + " = " + theInput.value + " to cookie")
//	window.status("writing " + theInput.name + " = " + theInput.value + " to cookie" ) ;
	writeCookie(theInput.name, theInput.value, 180) ;
}


function getImageSize(theImageArg,widthFieldArg,heightFieldArg,formNameArg) {
// Arguments are theImage Name, the Width Field Name and the height Field name 

var args	=	getImageSize.arguments
//if (args.length == 3 ) {
	var theImage 		= MM_findObj(theImageArg)
	var widthField 		= MM_findObj(widthFieldArg)
	var heightField 	= MM_findObj(heightFieldArg)
	
//	alert("widthField.value is '" + widthField + "'\nand image width is " +  theImage.width + "\nimage height is " + theImage.height)
	
	widthField.value = theImage.width ;

	heightField.value = theImage.height;

}


// This shows a preview of the picture to be included with the paragraph
// It also populates the width and height fields with the values taken 
// from the image.

/* replaced by the one below 


function changePreview(fileName,imageName,folder) { 
	if (fileName == "") { 
		imageObj.src = folder + "transpix.gif" ;
	}
	else {
		imageObj.src = folder + fileName ;
	}
}


*/

function changePreview(fileName,imageObjName,folderName) { 
	if (( imageObj=MM_findObj(imageObjName)) != null ) {		
		if ( fileName == "") { 
			fileName = "transpix.gif" ;
		}
		imageObj.src = folderName + fileName ;
	}
}


function changePreviewBackground(fileName,imageObjName,folderName) { 

	if ((imageObj=MM_findObj(imageObjName))!=null) {
		
//		alert("changing picture " + imageObjName + " to\n " + folderName + fileName)		  
		  
		if (fileName == "") { 
			fileName = "transpix.gif" ;
		}
		
		if (imageObj.style) {
			imageObj = imageObj.style ;
		}
		
//		imageObj.background = "url(" + folderName + fileName + ") center center no-repeat" ;
		imageObj.backgroundImage = "url(" + folderName + fileName + ")" ;
	}
}



function checkFileChars(field){
	var agt = navigator.userAgent.toLowerCase();
	var is_mac = (agt.indexOf("mac") != -1);
  	var is_ie = document.all;
	var is_ns6 = (!document.all && document.getElementById ? true : false);
	var fileURL = field.value;

//	window.alert("found " + field.name + " in form " + field.form.length )
//	window.alert("found formObj " +field.form.name )
	
	if (is_ie && is_mac) {
		begPos = fileURL.indexOf('/',1);
		if (begPos != -1) {
			fileURL = fileURL.substring(begPos+1,fileURL.length);
		}
	}

// loop through all the elements on the form and make sure the Submit button is visible
	var formname = field.form.name
	var formObj = MM_findObj(formname)
	
	for (j=0 ; j< formObj.length ; j++) { 
		obj = formObj.elements[j]
	
		if ( obj.type == "submit" ) {
			if (obj.style) { 
				obj=obj.style;
			}
			obj.visibility="visible";
		}
	}

	fileURL = 'file:///' + fileURL.replace(/:\\/gi,'|/').replace(/\\/gi,'/').replace(/:([^|])/gi,'/$1').replace(/"/gi,'').replace(/^\//,'');
	
	var fileParts = fileURL.split("/")
	
	var actualfilename = fileParts[fileParts.length-1]

//	window.alert("checking\n" + fileURL + "\n and actual file of " + actualfilename );
	
	var illegalchars = ",.~#:;+=-)(*&^%$£!'@|\<>/?¬"
	
	for ( i=0 ; i < illegalchars.length ; i++ ) {
		badChar = illegalchars.charAt(i) 
		
		if ( actualfilename.indexOf(badChar,0) > -1 ) {
			window.alert("File name cannot contain any of these characters:\n" + illegalchars )

			
			for (j=0 ; j< formObj.length ; j++) { 
				obj = formObj.elements[j]
//				alert( formObj.elements[j].name + " is type = " + formObj.elements[j].type )
			
				if ( obj.type == "submit" ) {
					if (obj.style) { 
						obj=obj.style;
					}
					obj.visibility="hidden";
					
					document.MM_returnValue = false;
					break 
					return false
				}	

			}
		}
	}
	document.MM_returnValue = true;
	return true
}


/* =================================================================== */


/* =================================================== */


/* 
var clickmessage="Right click disabled over images!"

function disableclick(e) {
if (document.all) {
	if (event.button==2 || event.button==3) {
		if (event.srcElement.tagName=="IMG"){
			window.alert(clickmessage);
			return false;
		}
	}
}
else if (document.layers) {
		if (e.which == 3) {
			window.alert(clickmessage);
			return false;
		}
	}
	else if (document.getElementById){
		if (e.which==3&&e.target.tagName=="IMG"){
			window.alert(clickmessage)
			return false
		}
	}
}

function locateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
	document.onmousedown=disableclick
else if (document.getElementById)
		document.onmouseup=disableclick
	else if (document.layers)
	locateimages()
	
*/
	
/* ================================================================== */
/* make left navigation pop-up */


var arr_NavTiers = [];
var itv_HideAll = "none";

/*
function to determine which left nav parent item is currently being viewed - 
please use at the top of each .asp page. 

on parent pages: set var arr_LeftNavSelected=[""]:
*/
function leftnav_SetSelected() {
	for(var i = 0;i<arr_LeftNavSelected.length;i++) {
		try {
			document.getElementById(arr_LeftNavSelected[i]).className = "toplinkselected";			
		}//end try
		catch(e) {
			return false;
		}//end catch
	}//end for
}//end function leftnav_SetSelected


function init() {
  if (!document.getElementById) return false;
  arr_MainNav = document.getElementById("leftnav").getElementsByTagName("a");
  for(i=0;i<arr_MainNav.length;i++) {
    if(arr_MainNav[i].parentNode.getElementsByTagName("ul").length>0) {
	  arr_MainNav[i].obj_SubNav = arr_MainNav[i].parentNode.getElementsByTagName("ul")[0];
	  if(arr_MainNav[i].className.indexOf("selected")>-1) {
	    arr_MainNav[i].className = (arr_MainNav[i].className!="toplinkselected") ? "parentnavselected" : "toplinkselected";
	  } else {
	    arr_MainNav[i].className = (arr_MainNav[i].className!="toplink") ? "parentnav" : "toplink";
	  }
	} else {
	  arr_MainNav[i].obj_SubNav = "none";
	}
	int_Temp = 0;
	obj_Temp = arr_MainNav[i];
	while(obj_Temp.id!="leftnav") {
	  obj_Temp = obj_Temp.parentNode;
	  int_Temp++;
	}
	arr_MainNav[i].origClass = arr_MainNav[i].className;
	arr_MainNav[i].int_NavTier = ((int_Temp-1)/2)-1;
	arr_MainNav[i].style.zIndex = arr_MainNav[i].int_NavTier * 10;
	arr_MainNav[i].onmouseover = new Function("showSub(this)");
	arr_MainNav[i].onmouseout = new Function("hideSub(this)");
		
	}
	/*make call to: function leftnav_SetSelected()*/
	leftnav_SetSelected();

}

// makes sub menu visible
function showSub(obj_Temp) {
  if(itv_HideAll!="none") {
    clearInterval(itv_HideAll);
	itv_HideAll = "none";
  }
  for(i=obj_Temp.int_NavTier;i<arr_NavTiers.length;i++) {
    if(arr_NavTiers[i]!="none") {
	  arr_NavTiers[i].obj_SubNav.className = "";
	  arr_NavTiers[i].className = arr_NavTiers[i].origClass;
	}
  }
  arr_NavTiers[obj_Temp.int_NavTier] = obj_Temp;
  if(obj_Temp.obj_SubNav!="none") {
  if(obj_Temp.locY==null) {
    if(navigator.platform=="Win32") {
	  if(obj_Temp.className.indexOf("toplink")>-1) {
        obj_Temp.obj_SubNav.style.top = (obj_Temp.offsetTop) + "px";
	  } else {
        obj_Temp.obj_SubNav.style.top = (obj_Temp.offsetTop) + "px";
	  }
    } else {
	  if(obj_Temp.className.indexOf("toplink")>-1) {
        obj_Temp.obj_SubNav.style.top = (navigator.userAgent.indexOf("MSIE")!=-1) ? (obj_Temp.offsetTop - 7) + "px" : (obj_Temp.offsetTop) + "px";
	  } else {
        obj_Temp.obj_SubNav.style.top = (navigator.userAgent.indexOf("MSIE")!=-1) ? (obj_Temp.offsetTop - 7) + "px" : (obj_Temp.offsetTop) + "px";
	  }
    }
	obj_Temp.locY = obj_Temp.obj_SubNav.style.top;
  }
  if(obj_Temp.className.indexOf("selected")==-1) {
    obj_Temp.className = obj_Temp.origClass + "active";
  }
  obj_Temp.obj_SubNav.className = "shownav";
  }
  leftnav_SetSelected();
}


// starts timer to hide current sub nav
function hideSub(obj_Temp) {
  if(itv_HideAll!="none") {
    clearInterval(itv_HideAll);
	itv_HideAll = "none";
  }
  itv_HideAll = setInterval("hideAll()",300);
  
  /*make call to: function leftnav_SetSelected()*/
  leftnav_SetSelected();
}


// clears all nav items when the mouse is off of the nav area
function hideAll() {
  for(i=0;i<arr_NavTiers.length;i++) {
    if(arr_NavTiers[i]!="none") {
	  arr_NavTiers[i].obj_SubNav.className = "";
	  arr_NavTiers[i].className = arr_NavTiers[i].origClass;
	  arr_NavTiers[i] = "none";
	}
  }
  
  /*make call to: function leftnav_SetSelected()*/
  leftnav_SetSelected();
}



