﻿// JScript File

function showDiv(pass,image) { 

document.getElementById('imgMain').src = image

var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if (divs[i].id.indexOf('MyDiv') > -1)
{
if(divs[i].id.match(pass)){//if they are 'see' divs 
if (document.getElementById) // DOM3 = IE5, NS6 
divs[i].style.visibility="visible";// show/hide 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'visible'; 
else // IE 4 
document.all.divs[i].visibility = 'visible'; 
} else { 
if (document.getElementById) 
divs[i].style.visibility="hidden"; 
else 
if (document.layers) // Netscape 4 
document.divs[i].visibility = 'hidden'; 
else // IE 4 
document.all.divs[i].visibility = 'hidden'; 
}
} 
} 
} 

//function DisplayFlash_index()
//{
//    document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="416">')
//    document.write ('<param name="movie" value="../images/index.swf">')
//    document.write ('<param name="quality" value="high">')
//    document.write ('<embed src="../images/index.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="416"></embed>')
//    document.write ('</object>')
//}

//function DisplayFlash_accessory_1704()
//{
//    document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="400">')
//    document.write ('<param name="movie" value="../flash/ColourWheel_1704.swf">')
//    document.write ('<param name="quality" value="high">')
//    document.write ('<embed src="../images/ColourWheel_1704.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="400"></embed>')
//    document.write ('</object>')
//}

//function DisplayFlash_map()
//{
////    document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="400">')
////    document.write ('<param name="movie" value="../flash/map.swf">')
////    document.write ('<param name="quality" value="high">')
////    document.write ('<embed src="../images/map.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="400"></embed>')
////    document.write ('</object>')

//    document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="400">')
//    document.write ('<param name="allowScriptAccess" value="sameDomain" />')    
//    document.write ('<param name="movie" value="../flash/map.swf">')
//    document.write ('<param name="loop" value="false" />')
//    document.write ('<param name="menu" value="false" />')
//    document.write ('<param name="quality" value="high" />')
//    document.write ('<param name="bgcolor" value="#ffffff" />')
//    document.write ('<embed src="../flash/map.swf" loop="false" menu="false" quality="high" bgcolor="#ffffff" width="780" height="400%" name="map" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />') 
//    document.write ('</object>')
//}

function PleaseWait()
{
    document.getElementById("tblMain").style.display='none'
    document.getElementById("tblPleaseWait").style.display='block'
    
    setTimeout("UpdateImg('imgPleaseWait','../images/please_wait.gif');",50)   
}
function UpdateImg(ctrl,imgsrc)
{
    var img = document.getElementById(ctrl);
    img.src = imgsrc;
}

function OpenLargeImage(url)
{
    window.open(url, 'LargeImage', 'toolbar=0,location=0,statusbar=0,menubar=0,width=800,height=600')
}

function FillHiddenLocation(sel,txt)
{
    var selectedValue = sel.options[sel.selectedIndex].value;
    document.forms[0].elements[txt].value = selectedValue;
}

function LocationLookup(parentId, value, name)
{
    this.parentId = parentId;
    this.value = value;
    this.name = name;
}

function BusinessTypeLookup(parentId, value, name)
{
    this.parentId = parentId;
    this.value = value;
    this.name = name;
}

function changedLocation(sel,target)
{
    var second = document.forms[0].elements[target];
    if (!second)
    {
        return; //error
    }
    
    var selectedValue = sel.options[sel.selectedIndex].value;
    second.options.length = 0;
    
    for (var i = 0; i < LocationLookups.length; ++i)
    {
        var LocationLookup = LocationLookups[i];
        if (LocationLookup.parentId == selectedValue)
        {
            var option = document.createElement('OPTION');
            option.value = LocationLookup.value;
            option.innerHTML = LocationLookup.name;
            second.appendChild(option);
        }
    }
}

function changedBusinessType(sel,target)
{
    var second = document.forms[0].elements[target];
    if (!second)
    {
        return; //error
    }
    
    var selectedValue = sel.options[sel.selectedIndex].value;
    second.options.length = 0;
    
    for (var i = 0; i < BusinessTypeLookups.length; ++i)
    {
        var BusinessTypeLookup = BusinessTypeLookups[i];
        if (BusinessTypeLookup.parentId == selectedValue)
        {
            var option = document.createElement('OPTION');
            option.value = BusinessTypeLookup.value;
            option.innerHTML = BusinessTypeLookup.name;
            second.appendChild(option);
        }
    }
}


function tvwOneSelected(event) 
{
    var obj = event.srcElement || event.target ; 
    var treeNodeFound = false; 
    var checkedState
    
    if (obj.tagName == "INPUT" && obj.type == "checkbox") 
    { 
        var treeNode = obj; 
        checkedState = treeNode.checked;
                
        //untick all checkboxes
        var elem = document.forms[0].elements;
        var str = ""
        for(var i = 0; i < elem.length; i++)
        {
            if (elem[i].type == 'checkbox')
            {
                elem[i].checked = false;
            }
        }
        obj.checked = true
    }
}

function checkTerms(sender, args)
{
    if (document.all.ctl00_cph1_wiz_radAgree.checked)
    {
        args.IsValid = true;      
    }
    else
    {
        args.IsValid = false;
        return;      
    }
}


function StartTimer(timer_box)
{
    if (document.getElementById(timer_box).value == '')
    {
        d = new Date()
        document.getElementById(timer_box).value = d
    }
}
function StopTimer(timer_box)
{
    d = new Date()
    document.getElementById(timer_box).value = d
}


function DisableEnter()
{

    if (window.event.keyCode == 13) 
    {
        event.returnValue=false; 
        event.cancel = true;
    }
}

function noPostBack(sNewFormAction,sTarget)
{
    if (sTarget != 'undefined')
    {
        document.forms[0].target = sTarget;
    }
    
    document.forms[0].action = sNewFormAction;
    document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
}


//function sstchur_SmartScroller_GetCoords()
//  {
//    var scrollX, scrollY;
//    if (document.all)
//    {
//      if (!document.documentElement.scrollLeft)
//        scrollX = document.body.scrollLeft;
//      else
//        scrollX = document.documentElement.scrollLeft;

//      if (!document.documentElement.scrollTop)
//        scrollY = document.body.scrollTop;
//      else
//        scrollY = document.documentElement.scrollTop;
//    }
//    else
//    {
//      scrollX = window.pageXOffset;
//      scrollY = window.pageYOffset;
//    }
//    document.forms[0].ctl00_scrollLeft.value = scrollX;
//    document.forms[0].ctl00_scrollTop.value = scrollY;
//  }


//  function sstchur_SmartScroller_Scroll()
//  {
//  
//    var x = document.forms[0].ctl00_scrollLeft.value;
//    var y = document.forms[0].ctl00_scrollTop.value;
//    window.scrollTo(x, y);
//  }

//  
//  window.onload = sstchur_SmartScroller_Scroll;
//  window.onscroll = sstchur_SmartScroller_GetCoords;
//  window.onclick = sstchur_SmartScroller_GetCoords;
//  window.onkeypress = sstchur_SmartScroller_GetCoords;


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_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_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];}
}
