﻿	//addLoadEvent(setScreenClass); 
	//window.onresize = setScreenClass;
	//  Following transition classes will be declared:
	//
	//	classname		  screenwidth
	//	------------------------------------------
	//	eightbysix		  0px - 1000px			
	//	tentwentyfour	  >1000px				

	function setScreenClass(){
		var fmt = document.documentElement.clientWidth;
		var cls = (fmt<=975)?'eightbysix':(fmt>975)?'tentwentyfour':'tentwentyfour';
		document.body.className=cls;
		if(fmt<=975)
		{
		    fcnRelocateFeatures('FeaturesEightHundred');
		    fcnRelocateNav('HoverEightHundred');
		}
		else
		{
		    fcnRelocateFeatures('FeaturesTenHundred');
		    fcnRelocateNav('HoverTenHundred');
		}
		fmt=null;
		cls=null;
	};
	
//Script for home page hiding and showing content areas onclick functions
	
		if (document.images)
		{
		    ButtonImg = new Array (8);
		    ButtonImg[0]="images/mast_tab_find_on.gif";
		    ButtonImg[1]="images/mast_tab_find_off.gif";
		    ButtonImg[2]="images/mast_tab_tih_on.gif";
		    ButtonImg[3]= "images/mast_tab_tih_off.gif";
		    ButtonImg[4]= "images/mast_tab_collection_on.gif";
		    ButtonImg[5] = "images/mast_tab_collection_off.gif";
		    ButtonImg[6] = "images/mast_tab_story_on.gif";
		    ButtonImg[7] = "images/mast_tab_story_off.gif";
		}
	    else 
	    {
		    ButtonImg = new Array (8);
		    ButtonImg[0] = "";
		    ButtonImg[1] = "";
		    ButtonImg[2] = "";
		    ButtonImg[3] = "";
		    ButtonImg[4] = "";
		    ButtonImg[5] = "";
		    ButtonImg[6] = "";
		    ButtonImg[7] = "";
	    }
	
        function SwitchImg(ImgName,NewSrc) 
        { 
            document[ImgName].src=ButtonImg[NewSrc]; 
        } 

		function classchangeFind(newclassname){
			document.getElementById("name_search").className=newclassname;
		}
		function classchangeTIH(newclassname){
			document.getElementById("TIH").className=newclassname;
		}
		function classchangeCollection(newclassname){
			document.getElementById("Collection").className=newclassname;
		}
		function classchangeStory(newclassname){
			document.getElementById("Story").className=newclassname;
		}
		function classchangeFeatStory(newclassname){
			document.getElementById("SlideStory").className=newclassname;
		}
//		function classchangeFeatNews(newclassname){
//			document.getElementById("SlideNews").className=newclassname;
//		}
		function classchangeFeatContent(newclassname){
			document.getElementById("SlideContent").className=newclassname;
		}
		function classchangeFeatBirthday(newclassname){
			document.getElementById("SlideBirthday").className=newclassname;
		}
		function classchangeFeatQuote(newclassname){
			document.getElementById("SlideQuote").className=newclassname;
		}
		function classchangeFeatStory2(newclassname){
			document.getElementById("SlideStory2").className=newclassname;
		}
		function classchangeFeatNews2(newclassname){
			document.getElementById("SlideNews2").className=newclassname;
		}
		function classchangeFeatContent2(newclassname){
			document.getElementById("SlideContent2").className=newclassname;
		}
		function classchangeFeatBirthday2(newclassname){
			document.getElementById("SlideBirthday2").className=newclassname;
		}
		function classchangeFeatQuote2(newclassname){
			document.getElementById("SlideQuote2").className=newclassname;
		};

//Script for Vertical Sub Navigation
var menuids=new Array("submenu") //Enter id(s) of UL menus, separated by commas
var submenuoffset=-2 //Offset of submenus from main menu.

function createcssmenu(){
    for (var i=0; i<menuids.length; i++){
        if(!!document.getElementById(menuids[i]))
        {
              var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
                for (var t=0; t<ultags.length; t++){
                var spanref=document.createElement("span")
		            spanref.className="arrowdiv"
		            spanref.innerHTML="&nbsp;&nbsp;"
		            var objLink=ultags[t].parentNode.getElementsByTagName("a")[0]
		            var arSpns=objLink.getElementsByTagName("span");
		            for(var intCount=0;intCount<arSpns.length;intCount++)
		            {
		                objLink.removeChild(arSpns[intCount]);
		            }
		            objLink.appendChild(spanref)
		            arSpns=null;
		            objLink=null;
		            purge(ultags[t])
                ultags[t].parentNode.onmouseover=function(){fcnResizeUL(this);};
                ultags[t].parentNode.onmouseout=function(){
                this.getElementsByTagName("ul")[0].style.display="none"
                }
                spanref=null;
                }
                ultags=null;
        }
    }
}

function fcnResizeUL(objCaller){
    objCaller.getElementsByTagName("ul")[0].style.left=objCaller.parentNode.offsetWidth+submenuoffset+"px";
    objCaller.getElementsByTagName("ul")[0].style.display="block";
    }

function fcnRelocateNav(strObjMoveToId)
{
    var objElement=document.getElementById(strObjMoveToId);
    if(!!objElement)
    {
        var objHover=document.getElementById('secondary_nav');
        var objNewHover=objHover.cloneNode(true);
        purge(objHover);
        objHover.parentNode.removeChild(objHover);
        objElement.insertBefore(objNewHover,objElement.firstChild);
        createcssmenu();
        objHover=null;
        objNewHover=null;
    }
    objElement=null;
}

function fcnRelocateFeatures(strObjMoveToId)
{
    var objElement=document.getElementById(strObjMoveToId);
    if(!!objElement)
    {
        var objFeatures=document.getElementById('FeatureSlides');
        var objNewFeatures=objFeatures.cloneNode(true);
        purge(objFeatures);
        objFeatures.parentNode.removeChild(objFeatures);
        objElement.insertBefore(objNewFeatures,objElement.firstChild);
        objFeatures=null;
        objNewFeatures=null;
    }
    objElement=null;
}

function fcnRelocateFeatureSlidesNav(strObjMoveToId, objInvoker)
{
    var objElement = document.getElementById(strObjMoveToId);
    if(!!objElement)
    {
        var objNav = document.getElementById('FeatureSlidesNav');
        for(var intCount=0;intCount<objInvoker.parentNode.childNodes.length;intCount++)
        {
            if(!!objInvoker.parentNode.childNodes[intCount].className)
            {
                objInvoker.parentNode.childNodes[intCount].className = '';
            }
        }
        objInvoker.className='current';
        var objNavMove = objNav.cloneNode(true);
        purge(objNav);
        objNav.parentNode.removeChild(objNav);
        objNavMove.id='FeatureSlidesNav';
        objElement.insertBefore(objNavMove,objElement.firstChild);
        objNavMove=null;
        objNav=null;
    }
    objElement=null;
}

function fcnRotateFeatures()
{
    var arFeaturesLinks=null;
    if(!!document.getElementById('FeatureSlidesNav'))
    {
        arFeaturesLinks=document.getElementById('FeatureSlidesNav').getElementsByTagName('a');
        var intIndex=-1;
        for(var intCount=0;intCount<arFeaturesLinks.length&&intIndex==-1;intCount++)
        {
            if(arFeaturesLinks[intCount].className=='current')
            {
                intIndex = intCount;
            }
        }
        intIndex++;
        if(intIndex==arFeaturesLinks.length)
        {
            intIndex=0;
        }
        arFeaturesLinks[intIndex].onclick();
        arFeaturesLinks=null;
        intIndex=null;
    }
}

function purge(d) {
    var a = d.attributes, i, l, n;
    if (a) {
        l = a.length;
        for (i = 0; i < l; i += 1) {
            n = a[i].name;
            if (typeof d[n] === 'function') {
                d[n] = null;
            }
        }
    }
    a = d.childNodes;
    if (a) {
        l = a.length;
        for (i = 0; i < l; i += 1) {
            purge(d.childNodes[i]);
        }
    }
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

if (window.addEventListener)
window.addEventListener("load", createcssmenu, false);
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu);
