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_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_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_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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function cose_highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function cose_normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function comm_highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function comm_normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function reg_highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function reg_normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function mywd_highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function mywd_normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function drct_highlight_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_on";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_on";
}
function drct_normalize_heading(rowName)
{
    document.getElementById('main_heading_'+rowName).className = "cose_heading_off";
    document.getElementById('a_main_heading_'+rowName).className = "coseheading_off";
}

function bookmark(url, description)
{
	thisApplicationName = document.getElementById('applicationName').value;

	errormsg="Unfortunately, your browser cannot support this function - please use its internal bookmarking facility to complete the request."

	if (navigator.appName=='Microsoft Internet Explorer')
	{
		window.external.AddFavorite(url, description);
	}
	else
	{
		alert(errormsg);
	}
}


function setdefault(url)
{
	thisApplicationName = document.getElementById('applicationName').value;

	if (thisApplicationName=='Netscape') {
		errormsg = "Manual Instructions for Netscape Users\n";
		errormsg += "- In your browser, select the 'Edit' menu and choose 'Preferences'\n";
		errormsg += "- Select the 'Navigator' category\n";
		errormsg += "- Under 'When Navigator starts up', select 'Home Page'\n";
		errormsg += "- Under 'Home page', type 'www.weddingsday.co.uk' in the 'Location' box\n";
		errormsg += "- Click the 'OK' button\n";
	}else if (thisApplicationName=='Firefox'){	
		errormsg = "Manual Instructions for Firefox Users:\n";
		errormsg += "- In your browser, select the 'Tools' menu and choose 'Options'\n";
		errormsg += "- Select the 'General' category\n";
		errormsg += "- Type 'www.weddingsday.co.uk' in the 'Location' entry box under the 'Home Page' heading\n";
		errormsg += "- Click the OK button\n";
	}else if (thisApplicationName=='Opera'){
		errormsg = "Manual Instructions for Opera Users:\n";
		errormsg += "- In your browser, select the 'Tools' menu and choose 'Preferences'\n";
		errormsg += "- Select the 'General' category\n";
		errormsg += "- Type 'www.weddingsday.co.uk' in the 'Home page' entry box\n";
		errormsg += "- Click the OK button\n";
	}else{
		errormsg = "Please use your browser's Home Page setting facility to set the default page";
	}
	
	
	
	if (navigator.appName=='Microsoft Internet Explorer' && thisApplicationName!='Opera')
	{
		document.getElementById('top').style.behavior = 'url(#default#homepage)'; 
		document.getElementById('top').setHomePage(url);
	}
	else
	{
		alert(errormsg);
	}


}


// =======================================================================
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}


// To make the main iFrame height be the same as the height of the page loaded:
/* add this to the page to be loaded:
<script language="JavaScript" type="text/JavaScript">
function goSetHeight() {
  if (parent == window) return;
  else parent.setIframeHeight('iFrame_mainbody');
}
</script>

<body onload="goSetHeight()">
*/

function chkall(input1,input2)
{
    var objForm = document.forms[input1];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
        if (input2.checked == true)
        {
            if (objForm.elements[iCount].type == "checkbox")
            {
                objForm.elements[iCount].checked = true;
            }
        }
        else
        {
            if (objForm.elements[iCount].type == "checkbox")
            {
                objForm.elements[iCount].checked = false;
            }
        }
    }
}


function chkall_objName(input1,input2,input3)
{
    var objForm = document.forms[input1];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
        if (input2.checked == true)
        {
            if (objForm.elements[iCount].type == "checkbox" && objForm.elements[iCount].name == input3)
            {
                objForm.elements[iCount].checked = true;
            }
        }
        else
        {
            if (objForm.elements[iCount].type == "checkbox" && objForm.elements[iCount].name == input3)
            {
                objForm.elements[iCount].checked = false;
            }
        }
    }
}


function chkall_objNameprefix(input1,input2,input3)
{
    prefix_length=input3.length;
	var objForm = document.forms[input1];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
        if (input2.checked == true)
        {
            if (objForm.elements[iCount].type == "checkbox" && objForm.elements[iCount].name.substr(0,prefix_length) == input3)
            {
                objForm.elements[iCount].checked = true;
            }
        }
        else
        {
            if (objForm.elements[iCount].type == "checkbox" && objForm.elements[iCount].name.substr(0,prefix_length) == input3)
            {
                objForm.elements[iCount].checked = false;
            }
        }
    }
}


function swapSupplierSign(signid, detailid) {
	var thisObj=document.getElementById(signid).src;
	switch (thisObj.substring(thisObj.length-8,thisObj.length)){
		case 'inus.png':
			document.getElementById(signid).src = "../../images/sign_plus.png";
			document.getElementById(detailid).style.display='none';
			return(false);
		case 'plus.png':
			document.getElementById(signid).src = "../../images/sign_minus.png";
			document.getElementById(detailid).style.display='';
			return(false);
	}
}


// codes from http://www.quirksmode.org/js/findpos.html
function findPos(obj) { // find the position of the div object
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function shlv3(lv2_id, onoff){

	currentStatus_P=document.getElementById('bltimg_'+lv2_id).src.search(/_p.png/);
	currentStatus_M=document.getElementById('bltimg_'+lv2_id).src.search(/_m.png/);

	leftWhole = document.anchors; 
    leftLen = leftWhole.length;

	if (currentStatus_M>0) { // minus (expanded) originally, need to become folded
		document.getElementById('bltimg_'+lv2_id).src="/images/cose_button_small"+onoff+"_p.png";
		for (var leftCount = 0; leftCount < leftLen; leftCount++){
			if (leftWhole[leftCount].name.substr(0,lv2_id.length+5) == 'el3_'+lv2_id+'_'){ // if this is the A tag, we need to know what its name is
				document.getElementById('tr'+leftWhole[leftCount].name).style.display='none';
			}
		}
	}else if(currentStatus_P>0){ // plus (folded) originally, need to become expanded
		document.getElementById('bltimg_'+lv2_id).src="/images/cose_button_small"+onoff+"_m.png";
		for (var leftCount = 0; leftCount < leftLen; leftCount++){
			if (leftWhole[leftCount].name.substr(0,lv2_id.length+5) == 'el3_'+lv2_id+'_'){ // if this is the A tag, we need to know what its name is
				document.getElementById('tr'+leftWhole[leftCount].name).style.display='';
			}
		}
	}

	dispGG();
	dispGGL();
	dispGGRI();
	
}

function shlv4(lv3_id, onoff){
	sh=document.getElementById('l4t['+lv3_id+']').style.display;
	if(sh==''){
		document.getElementById('l3bi_'+lv3_id).src="/images/cose_button_small"+onoff+"_p.png";		
		document.getElementById('l4t['+lv3_id+']').style.display='none';
	}else{
		document.getElementById('l3bi_'+lv3_id).src="/images/cose_button_small"+onoff+"_m.png";
		
		document.getElementById('l4t['+lv3_id+']').style.display='';
	}
	dispGG();
	dispGGL();
	dispGGRI();	
}

function shlv5(lv4_id, onoff){
	sh=document.getElementById('l5t['+lv4_id+']').style.display;
	if(sh==''){
		document.getElementById('l4bi_'+lv4_id).src="/images/cose_button_small"+onoff+"_p.png";		
		document.getElementById('l5t['+lv4_id+']').style.display='none';
	}else{
		document.getElementById('l4bi_'+lv4_id).src="/images/cose_button_small"+onoff+"_m.png";
		document.getElementById('l5t['+lv4_id+']').style.display='';
	}
	dispGG();
	dispGGL();
	dispGGRI();	
}


// replace(/^\s*|\s*$/g,""); // .replace(/^\s*|\s*$/g,"") is like "TRIM" command in the normal programming language. trim() function simply isn't provided by javascript.

// ===============================================================================