// For passing the submenu ID from the page and unhiding the submenu when the page loads
function show(id) {
	document.getElementById(id).style.display = "block";
}
// End

// For toggling the submenu on and off
function toggle(sub) { var el = document.getElementById(sub); var bWhich = (el.style.display == 'none' || el.style.display == ''); for (var i=0; i<submenus.length; ++i) submenus[i].style.display = 'none'; el.style.display = (bWhich) ? 'block' : 'none'; return false; } var divcoll = document.getElementsByTagName('div'), submenus = new Array(); onload = function() { for (var i=0; i<divcoll.length; ++i) if (divcoll.item(i).id && divcoll.item(i).id.indexOf('submenu') != -1) submenus[submenus.length] = divcoll.item(i); }
// End

// For cycling the featured images on the home page
function AdRotator(id, ads, height, width)
{
   this.id = id;
   this.ads = ads;
   this.index = 0;
   this.container = document.getElementById(id);

   this.anchorElement = document.createElement('a');
   this.imageElement = document.createElement('img');
   this.imageElement.setAttribute('height', height);   
   this.imageElement.setAttribute('width', width);
   this.anchorElement.appendChild(this.imageElement);
   this.container.appendChild(this.anchorElement);
   this.RotateAd();
}

AdRotator.prototype.RotateAd = function()
{
    var currentAd = this.NextAd();
    this.imageElement.setAttribute('src', currentAd.ImageUrl);
    this.imageElement.setAttribute('alt', currentAd.Alt);
    this.anchorElement.setAttribute('href', currentAd.LinkUrl);
	this.anchorElement.setAttribute('target', currentAd.Target);
    var thisObject = this;
    setTimeout(function() { thisObject.RotateAd(); }, currentAd.DisplayTime);
}

AdRotator.prototype.NextAd = function()
{
    var ad = this.ads[this.index];
    this.index ++;
    if (this.index == this.ads.length) this.index = 0;
    return ad;
} 


function DisplayFeaturePicturesCycle()
{
                var imgJson= "["; var IntervalSec= 9; 
                var Interval = IntervalSec * 1000;
                var s= document.getElementById ('ImageList');
                if (!s) return;
                var aL= s.getElementsByTagName("a");
                if (aL.length<1) return;
                
                for (var i=0; i<aL.length; i++)
                {
                                var img =aL[i].getElementsByTagName("img");
                                if (img.length ==1)
                                {
                                                if (i>0) imgJson += ",\n";
                                                //imgJson += '{"ImageUrl":"'+  img[0].src + '","Alt":"' + img[0].alt + '","LinkUrl":"' + aL[i].href + '","DisplayTime":"'+ Interval + '"}';
												
												imgJson += '{"ImageUrl":"'+  img[0].src + '","Alt":"' + img[0].alt + '","LinkUrl":"' + aL[i].href + '","Target":"' + aL[i].target + '","DisplayTime":"'+ Interval + '"}';


/*alert (img[0].alt);alert (img[0].height);alert (img[0].width);*/
                                }
                }
                imgJson += "]";
                
                var Json= eval("(" + imgJson + ")" );
                                
                new AdRotator('CyclingFeaturedPics', Json,       220, 600)


                

  }
// End

// For deselecting all checkbox when other checkboxes are selected and vice versa

function all_click(field,fieldAll) {
	if (fieldAll.checked==true) {
		for (i = 0; i < field.length; i++) {
		field[i].checked=false;
		}
	}
}

function rank_click(fieldAll) {
	fieldAll.checked=false;
}
// End

// For centering pop-up windows
/*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}
// End