window.$ = $telerik.$; 
function populateBanners() { var acronyms = document.getElementsByTagName("acronym"), ids = []; for (var i = 0, len = acronyms.length; i < len; i++) ids[ids.length] = acronyms[i].id.split("_BANNER_")[1]; if (ids.length && ids.length > 0) { var bannersiframe = document.createElement('iframe'); bannersiframe.id = 'bannersiframe'; bannersiframe.style.display = 'none'; bannersiframe.src = "BannersHandler.axd?mainID=" + nodeId + "&langID=" + langId + "&ids=" + ids.join(","); document.body.appendChild(bannersiframe); } }
function CreateFlashControl(DivID, WIDTH, HEIGHT, URL, WMODE, MENU) {
    var d = document.getElementById(DivID);
    FlObj = '<div class="BANNER Banner' + DivID +  '"><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=' + WIDTH + ' height=' + HEIGHT + '>';
    FlObj = FlObj + '<param name="movie" value=' + URL + '>';
    FlObj = FlObj + '<param name="wmode" value=' + WMODE + '>';
    FlObj = FlObj + '<param name="menu" value=' + MENU + '>';
    FlObj = FlObj + '<embed src=' + URL + '  wmode=' + WMODE + ' quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width=' + WIDTH + ' height=' + HEIGHT + '></embed></object></div>';
    d.innerHTML = FlObj; }
function clearf() { for (var i = 0; i < document.forms[0].elements.length; i++) { if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "textarea" || document.forms[0].elements[i].type == "password") document.forms[0].elements[i].value = ""; else if (document.forms[0].elements[i].type == "select-one") document.forms[0].elements[i].selectedIndex = 0; else if (document.forms[0].elements[i].type == "checkbox") document.forms[0].elements[i].checked = false; } }

function SetJS(location, tag) { var objRef = document.getElementById('__BANNER_' + location); objRef.innerHTML = '<div class="BANNER Banner' + location + '">' + tag + '</div>'; }

function setListeners() {
    inputList = document.getElementsByTagName("INPUT"); for (i = 0; i < inputList.length; i++) {
        if (inputList[i].attachEvent) inputList[i].attachEvent("onpropertychange", restoreStyles); else if (inputList[i].addEventListener) inputList[i].addEventListener("propertychange", restoreStyles, false); else
            inputList[i].onpropertychange = restoreStyles; inputList[i].style.backgroundColor = "";
    } selectList = document.getElementsByTagName("SELECT"); for (i = 0; i < selectList.length; i++) {
        if (selectList[i].attachEvent) selectList[i].attachEvent("onpropertychange", restoreStyles); else if (selectList[i].addEventListener) selectList[i].addEventListener("propertychange", restoreStyles, false); else
            selectList[i].onpropertychange = restoreStyles; selectList[i].style.backgroundColor = "";
    }
}
function restoreStyles() { if (event.srcElement.style.backgroundColor != "") event.srcElement.style.backgroundColor = ""; }
function SetFlashJS(location, d, s, tag, width, height) { CreateFlashControl('__BANNER_' + location, width, height, tag, 'Transparent', ''); }
function showPicture(src) { window.open('ImageView.aspx?img=' + src, 'picture', 'scrollbar:no statusbar:no'); }
function createBookmarkLink() { if (window.sidebar) window.sidebar.addPanel(document.title, location.href, ''); else if (window.external) window.external.AddFavorite(location.href, document.title); else if (window.opera && window.print) return true; }
function attachLinkEvent() {
    var links = getElementsByClassName('newwindow', 'A', null);
    for (var i = 0; i < links.length; i++)
        links[i].onclick = function() {
            window.open('imageview.aspx?img=' + this.href, 'newimage', 'scroll=no', false);
            return false;
        }
    }

			 
			 
			 
             $(document).ready(function() {
                setListeners();
                populateBanners();
                
                
                
                if ('#TickerArea'){startTicker()}
                $("#hp #productsTabs li:first").addClass("selected");
                $("#mediaCenterPage #productsTabs li:first").addClass("selected");
                
                // alert("hi");
                $('#GoboImages li img').click(function () { 
                $('.maingovoimage').hide().css("opacity","0");
                $('.maingovoimage').attr('src', $(this).attr('longdesc'));
                $('.maingovoimage').show().animate({ opacity: 1}, 400 );
   
                });
                
                $('#productMoreImages li img').click(function () { 
                $('.mainproductimage').hide().css("opacity","0");
                $('.mainproductimage').attr('src', $(this).attr('longdesc'));
                $('.mainproductimage').show().animate({ opacity: 1}, 400 );
   
                });
                
                $('a.closed').click(function () { 
                   
                   if ($(this).is('.closed')) {
                   
                   
                   $(this).addClass("opened");
                   $(this).removeClass("closed");
                   $(this).html('Close');
                   $(this).parent().parent().find(".managerExtentedTXT").show("fast");
                   }
                   
                   else if ($(this).is('.opened')) {
                   
                   $(this).addClass("closed");
                   $(this).removeClass("opened");
                   $(this).html('Open');
                   $(this).parent().parent().find(".managerExtentedTXT").hide("fast");
                   }
                   
                   
                   return false;
                   
                  
                });
                
             $('#mask').height($(document).height());
             
             
                $('.toplogin').click(function () {
                    $('#loginpopup').show("fast");
                    $('#mask').show();
                    return false;
                })
                
                 $('#mask').click(function () {
                    $('#loginpopup').hide("fast");
                    $(this).hide();
                    return false;
                })
                
                initPrint();
        $("div#PrintPage").bind("click", function() {
            
            var url = window.document.URL;
            var mypage = window.open(url, 'printwindow', 'width=800,height=600,scrollbars=yes',true);

            return false;


        });
        
        
        $("#NextTicker").bind("click", function() {
            
            
            nextTicker();

            return false;


        });
        
        $("#PrevTicker").bind("click", function() {
            
            
            prevTicker();

            return false;


        });
               


             });
             
             
             $('body').bind('click', function(e){
                //depending on the browser, either srcElement or 
                //originalTarget will be populated with the first
                //element that intercepted the click before it bubbled up
                var originalElement = e.srcElement;
                if(!originalElement){originalElement=e.originalTarget;}                                                 
//                alert(originalElement.id);
//                alert(originalElement.tagName);
                
                if ((originalElement.tagName == "FORM") || (originalElement.tagName == "BODY") ){
                    $('#loginpopup').hide("fast");
                    $('#mask').hide();
                    return false;
                }
       
                });
                
        function initPrint() {
        var url = window.document.URL;
        // alert(window.name);
        if (window.name=='printwindow') {
            
            bg2Image("#branding");
            var elements = '#topArea,#innerBanner,#leftBar,#rightBar,#PrintPage,#SharePage,#breadcrumbs,#RTbottomlinks,.stripLink,.openClose';
            
            hideEmAll(elements);
            $(".TopStrip").removeClass("TopStrip");
            $("body").attr("id","Printing");
            
            
            window.print();
            
        }
    
    }

    function bg2Image(elem) {

        var source = $(elem).css("background-image");
        // 
        if (source) {
            source = source.split('"').join('');
            // alert(source);
            source = source.substring(4, source.length - 1);
            $(elem).replaceWith("<img id='logo' alt='' src='" + source + "'/>");
        }
    }
       function li2Image(elem) {
        if($(elem)){
            var source = $(elem).css("background-image");
            $(elem).css("background-image","none");
            if (source) {
                source = source.substring(4, source.length - 1);
                $(elem).prepend("<img id='logo' alt='' src='" + source + "'/>");
                
            }
        }
    }
    function hideEmAll(elemnts) {
        var elemArr = elemnts.split(",");

        for (var i = 0; i < elemArr.length; i++) {
            $(elemArr[i]).hide();
        
        }
 }
    
    var currentTicker = -1;
    
    var runTicker = true;
    
    function startTicker(){
        
        if (runTicker == false) {return}
        
        currentTicker++;
        // alert(currentTicker + " / " + TickerLength);
        if (currentTicker == TickerLength) currentTicker = 0;
        
        showTicker();
        setTimeout("startTicker()" ,6000);
    }
    
    function nextTicker(){
    
        currentTicker++;
        if (currentTicker == TickerLength) currentTicker = 0;
        
        showTicker();
        runTicker = false;
    }
    
    function prevTicker(){
    
        currentTicker--;
        if (currentTicker < 0) currentTicker = TickerLength-1;
        
        showTicker();
        runTicker = false;
    }
    
    function showTicker(){
        $("#newsTicker li").stop().hide();
        $("#newsTicker li.Ticker_" + currentTicker).show("slow");
    }

    

