/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
//function toggleDisp() {
//    for (var i=0;i<arguments.length;i++){
//        var d = $(arguments[i]);
//        if (d.style.display == 'none')
//        {
//            window.document.getElementById(d).className = 'tabContentActive';
//            alert("d.className");
//        }
//        else
//        {
//            window.document.getElementById(d).className = 'tabContent';
//            alert("d.className");
//        }
//            
//    }
//}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate)
{
//    if ($('tabContent'+num).style.display == 'none')
//    {
//        for (var i=1;i<=numelems;i++)
//        {
//            if ((opennum == null) || (opennum != i))
//            {
//            /*
//                var temph = 'tabHeader'+i;
//                var h = $(temph);
//                if (!h)
//                {
//                    var h = $('tabHeaderActive');
//                    h.id = temph;
//                    alert(h.innerHTML);
//                }
//            */
//                var tempc = 'tabContent'+i;
//                var c = $(tempc);
//                if(c.style.display != 'none')
//                {
//                    if (animate || typeof animate == 'undefined')
//                        Effect.toggle(tempc,'appear',{duration:0.5, queue:{scope:'menus', limit: 3}});
//                    else
//                        toggleDisp(tempc);
//                }
//            }
//        }
//        
///*
//        var h = $('tabHeader'+num);
//        
//        if (h)
//        {
//            h.className = 'activeTab';
//        }

//        h.blur();
//*/
//        var c = $('tabContent'+num);
//        c.style.marginTop = '2px';
//        if (animate || typeof animate == 'undefined')
//        {
//        
//            Effect.toggle('tabContent'+num,'appear',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
//        }
//        else
//        {
//            toggleDisp('tabContent'+num);
//        }
//    }
    
    changeStyleBodyText(num,numelems);
    
    changeStyle(num,numelems);
}

function changeStyle(i,listLength)
{
    for(var x=0; x<listLength; x++)
    {
        var headerName = 'tabHeader'+(x+1)
        if(x == i-1)
        {
            window.document.getElementById(headerName).className = 'activeTab';
        }
        else
        {
            window.document.getElementById(headerName).className = 'none';
        }
    }
}

function changeStyleBodyText(i,listLength)
{
    for(var x=0; x<listLength; x++)
    {
        var contentID = 'tabContent'+(x+1)
        if(x == i-1)
        {
            window.document.getElementById(contentID).className = 'tabContentActive';
        }
        else
        {
            window.document.getElementById(contentID).className = 'tabContent';
        }
    }
}

function loadStyleSheet(countryPref) {
    var cssFile;
    var imageSrc;
    //alert(countryPref);
    switch (countryPref) {
        case "USA":
            //alert("in usa");
            cssFile = "/css/usa.css";
            imageSrc = "/images/flag-usa.gif";
            break;
        case "ROI":
            //alert("in roi");
            cssFile = "/css/roi.css";
            imageSrc = "/images/flag-ire.gif";
            break;
        case "EU":
            //alert("in roi");
            cssFile = "/css/eu.css";
            imageSrc = "/images/flag-europe.gif";
            break;
        default:
            //alert("in def");
            cssFile = "/css/uk.css";
            imageSrc = "/images/flag-uk.gif";
            break;
    }

    $('selectLocation').getFirst('img').set('src', imageSrc);
    var newCSS = new Asset.css(cssFile, { type: 'text/css', media: 'screen, projection' });
}

