<!--
/////////////////////////////////////////////////
// Written by Paul Lo, organized on 8/27/08
/////////////////////////////////////////////////

/////////////////////////////////////////////////
// JQuery Section - predefined
/////////////////////////////////////////////////
var $j = jQuery;
$j(document).ready(function()
{  

   //---------------Master Page----------------------
   // controls tabs that should slide
   $j("a[rel='master_overlay_tab']").click(function()
   {
      var tab = $j("#" + this.id + "_content");
      var commonPanel = $j("#defaultPanesShadowWrapper");
      var contentDisplay = $j(tab).css("display");

      if(contentDisplay == "none")
      {
         $j(tab).siblings().hide();
         //$j(this).siblings().removeClass('on');
         $j("a[rel='master_overlay_tab']").removeClass('on');
         $(this).addClassName('on');
         commonPanel.slideDown(500, function()
         {
            tab.css({display:"block"});
         });
      }
      else
      {
         $(this).removeClassName('on');
         tab.css({display:"none"});
         commonPanel.slideUp(250);
      }
   });
   
   // close the slided down window on top nav
   $j("#closeButton").click(function()
   {
      $j("div[rel='overlay_content']").css({display:"none"});
      $j("a[rel='master_overlay_tab']").removeClass("on");
      $j("#defaultPanesShadowWrapper").slideUp(250);
   });
   
   // controls resource section on product page
   $j("ul[rel='product_top_resources'] > li").click(function()
   {
      if($j(this).hasClass("disable"))
         return false;
   
      var commonpanel = $j("#tabWrapper");
      var rel = $j(this).attr("rel");
      var content = $j("div[rel='" + rel + "_content']");
      var bottomResources = $j("#dlinktv,#findRetailers");
      
      // to open
      if(content.css("display") == "none")
      {
         //content.siblings().removeClass('on');
         $j(this).addClass("on");
         $j(this).siblings().removeClass("on");
         bottomResources.removeClass("on");
         content.siblings().css({display:"none"});
         //$j("*[group='product_info']").css({display:"none"});
         
         //***** testing for dlink tv
         if($j("#opening") != null)
         {
             $j("#opening").fadeOut(800, function()
             {
                DLinkTV.defaultToIntro('openingContainer');
             });
         }
         //*****
         
         commonpanel.slideDown(250, function()
         {
            content.fadeIn(300);
            //content.css({display:"block"});
         });
      }
      else
      {
         // to close
         content.fadeOut(150, function()
         {
            commonpanel.slideUp(250, function()
            {
               //***** testing
               if($j("#opening") != null)
               {
                   $j("#opening").fadeIn(300, function()
                   {
                      DLinkTV.updateMovieSrcLink(321,"openingContainer");
                   });
               }
               //***** 
            });
         });
         $j(this).removeClass("on");
         //dlinktv.removeClass("on");
      }

      DLinkTV.defaultToIntro('tvContainer');
   });
   
   $j("a.biz-category-listItem").mouseover(function()
   {
      if($j(":animated").length > 0)
         return;
   
      // change to content parent's parent instead of ID
      //var sub = $j("#subcategory_pane");
      var group = $j(this).attr("name");
      $j("a.biz-category-listItem[name='" + group + "']").removeClass("on");
      
      /*$j("a.biz-category-listItem").each(function(i)
      {
         if($j(this).attr("name") == group)
         {
            $j(this).removeClass("on");
         }
      });*/
      
      // don't stay on
      //$j(this).addClass('on');
      if(typeof($j(this).attr("rel")) != 'undefined' && $j(this).attr("rel").length > 0)
      {
			var content = $j("#" + $j(this).attr("rel"));
			// sub pane
			var sub = $j(this).parents("div.double-panes-left:first").siblings("div.double-panes-right:first");
			//alert(sub.length);
			//var sub = content.parent().parent();
			//alert(content.length);
			if(content.length == 0) // no sub content?
			{
			   if(sub.hasClass('open'))
			   {
					// close all
					sub.children(":nth-child(2)").fadeOut(200, function()
					{
					   sub.animate({backgroundPosition:"-365px 0"},300, function()
						{
							sub.removeClass('open');
					   });
					});
					
					sub.children(":nth-child(2)").children().each(function()
					{
					   $j(this).css("display", "none");
					});
					/*sub.children(":nth-child(2)").children().each(function()
					{
						$j(this).fadeOut(200, function()
						{
						   sub.animate({backgroundPosition:"-365px 0"},300, function()
							{
								sub.removeClass('open');
						   });
						});
					});*/
			   }
			}
			else
			{
			   if(content.css("display") != "block") // not the same one selected
				{
					if(typeof(content.css("display")) == "undefined")
					{
						// hides all sub section if this element doesn't have a sub
						//var rightSec = $j(this).parents("div.double-panes-left").siblings("div.double-panes-right");
						//var rightContent = rightSec.children(":nth-child(2)");
						var rightContent = sub.children(":nth-child(2)");
						rightContent.children().each(function()
						{
							$j(this).css("display", "none");
						});
						
						// close right panel if no sub items
					}
					else
					{
						//var open = false;
						content.parent().children().each(function()
						{
							$j(this).css("display", "none");
						});
				      
						if(!sub.hasClass('open'))
						{
							sub.addClass('open');
							sub.animate({backgroundPosition:"-184px 0"},500, function()
							{
								content.parent().fadeIn(300, function()
								{
								});
							});
						}
						/*else
						{
							content.css("display", "block");
						}*/
						content.css("display", "block");
					}
				}   
			}
      }
   });
   
   $j("#dlinktv").click(function()
   {
      if($j(this).hasClass("disable"))
         return false;
      
      var commonpanel = $j("#tabWrapper");
      var content = $j("div[rel='" + this.id + "_content']");
      
      if(content.css("display") == "none")
      {
         content.siblings().css({display:"none"});
         $j(this).addClass("on");
         
         // bottom resource nav
         $j(this).siblings().removeClass("on");
         // top resource nav
         $j("ul[rel='product_top_resources'] > li").removeClass("on");
         
         //***** testing
         openingHide();
         //*****
         
         commonpanel.slideDown(250, function()
         {
            content.fadeIn(300);
            //content.css({display:"block"});
         });
      }
      else
      {
         content.fadeOut(150, function()
         {
            DLinkTV.defaultToIntro('tvContainer');
            commonpanel.slideUp(250, function()
            {
               //***** testing
               openingShow();
               //*****
            });
         });
         
         $j(this).removeClass("on");
      }
   });
   
   $j("#findRetailers").click(function()
   {
      //ContentOverlay.Open();
      //ContentOverlay.HideSiblings("productKBSection");
      var frame = $j("#retailerFrame");
      
      if(frame != null & frame.get(0).src.length == 0)
      {
         var src = $j(this).attr("rel"); // trigger link
         if(typeof(src) != 'undefined' && src.length > 0)
            frame.attr("src", src);
      }
      ContentOverlay.ShowGeneralSection("productRetailerSection");
   });
   
   $j("select.ddl-link").change(function()
   {
      var url = $j(this).attr("rel");
      var val = this.options[this.selectedIndex].value;
      
      if(val != null && val != -1)
      {
         location.href = url + val;
      }
   });
   
   //**********************************************
   // product selector link
   // rel = url, a.productSelectorLink
   $j("a.productSelectorLink, a.frameUrl, input.frameUrl").click(function()
   {
      var url = $j(this).attr("rel");
      //var scroll = $j(this).attr("scroll");
      
      // control if the overlay iframe should be scrollable
      // automatically adjust height
      /*if(typeof(scroll) != 'undefined' && scroll.length > 0)
      {
         $j("#prodcutSelectorFrame").attr("scrolling", scroll).addClass("content-frame-height");
      }*/
      
      // knowledge base
      if($j(this).hasClass("kb-content"))
      {
         var model = $j(this).prev("select").val();
         url = url + "?model=" + model;
      }
      
      ContentOverlay.ShowProductSelector(url);
      
      return false;
   });
   
   // content overlay close button
   $j("a.contentOverlayCloseBtn").click(function()
   {
      ContentOverlay.Close();
   });
   //**********************************************
   
   /*$j("a[rel='link_productSelector']").click(function()
   {
      Overlay.Open();
      Overlay.Show("productselector_section");
      $j("div.categoryIllustration").hide();
   });
   
   $j("a.overlayCloseBtn").click(function()
   {
      Overlay.Close();
      $j("div.categoryIllustration").show();
   });*/
   

   
   //---------------Master Page----------------------
   
   //---------------company press template click and open------------------------
   $j(".supportContent").click(function()
   {
      var rel = $j(this).attr("rel");
      var title = $j(this).attr("title");
      var id = $j(this).attr("id");
      var hasFrame = $j(this).hasClass("frameContent");
      var hasSearch = $j(this).hasClass("searchContent");
      
      if(typeof(rel) != 'undefined' && rel.length > 0)
      {
         // change of plan...
         /*if(typeof(title) != 'undefined' && title.length > 0)
         {
            //$j("#prContentHeader").html("<span class=\"header-style\" style=\"font-size:10pt;\">" + title + "</span>");
            $j("#prContentHeader").html(title);
         }*/
         
         var contentId = "#" + id + "_content"; 
         
         $j(this).siblings("a.linkOn").removeClass("linkOn");
         
         if(!$j(this).hasClass("linkOn"))
            $j(this).addClass("linkOn");
          
         if(hasFrame)
         {
            contentId = "#frame_content";
            var src = $j(this).attr("url");
            
            if(hasSearch)
            {
               var term = $j(this).prev("input").val();
               src = src + term;
            }
            
            $j(contentId).children("iframe").attr("src", src);
         }
         
         var contentBody = $j("#" + rel + " div.company-landing");
         
         if(contentBody.css("display") != 'block' || contentBody.css("display") == '')
         {
            contentBody.slideDown(500, function()
            {
					if($j(contentId).css("display") != 'block')
					{
						$j(contentId).siblings().css("display", "none");
						$j(contentId).fadeIn(300, function()
						{
						   
						});
					}
            });
         }
         else
         {
            if($j(contentId).css("display") != 'block')
				{
					$j(contentId).siblings().css("display", "none");
					$j(contentId).fadeIn(300, function()
					{
					   
					});
				}
				/*
				$j("#" + rel).children("div").slideDown(500, function()
				{
					//var id = "#" + id + "_content";
	            
					
				});*/
         }
         
         return false;
      }
   });
   //---------------support page end---------------------
   
   ///////////////// Testings //////////////////////
   
   // product support KB
   $j("a.product-kb-item").click(function()
   {
      var url = $j(this).attr("rel");
      
      var detailFrame = $j("#kbDetailFrame").attr("src", url);
      //ContentOverlay.ShowGeneralSection("productKBSection");
      //ContentOverlay.Open();
      //ContentOverlay.HideSiblings("productKBSection");
      //Overlay.Open();        
      //Overlay.Show("product_kb_section");
   });
   
   // all Tree Node Sign Click
   $j("div.treeExpandSign > a").click(function()
   {
      var treeTitle = $j(this).parent().next();
      if(treeTitle != null)
         $j(treeTitle).click();
   });
   
   // all Neutral(no content, downloads only) attributes addon
   $j.each($j("div.treeNeutralSign > a"), function()
   {
      var treeTitle = $j(this).parent().next();
      if(treeTitle != null)
      {
         var href = $j(treeTitle).attr("href");
         var target = $j(treeTitle).attr("target");
         
         // if resource only has downloadable files, fill in href & target
         // attrs, or else if resource is a clickable, then add the click
         // event to the current element
         if(typeof(href) == 'undefined' || href == null || href.length == 0)
         {
            $j(this).click(function()
            {
               if($j(treeTitle).click)
                  $j(treeTitle).click();
            });
         }
         else
         {
             $j(this).attr("href", href);
             $j(this).attr("target", target);
         }
      }
   });
   
   // all Tree Nodes Click
   // <a> with rel='treeview_link' with a <div> as
   // immediate sibling for the content
   $j("a[rel='treeview_link']").click(function()
      {
         var sectionToShow = $j(this).parent().next();
         var signSpan = $j(this).prev();
         //var signSpan = $j(this).children(":first");
         
         if($j(signSpan).hasClass("treeExpandSign"))
         {
             // <a>
             var signLink = signSpan.children(":first");
             
             if($j.trim($j(signLink).html()) == "+")
             {       
                $j(signLink).html("-");
                $j(signLink).css({marginLeft: "2px"});
             }
             else
             {
                $j(signLink).html("+");    
                $j(signLink).css({marginLeft: ""});  
             }
             
             $j(sectionToShow).slideToggle(300, function()
             {
                // url links
                /*if($j(this).css("display") == "block" && $(this).down(0) != null)
                {
                   //var anchor = $(this).down(0).readAttribute("name");
                   var anchor = $(this).down(0).readAttribute("rel");
                   if(anchor != null && anchor.length > 0)
                      window.location.hash = anchor;
                }
                else
                {
                   //window.location.hash = "productmanual";
                }*/
             });
         }
      });
      
      
          // faq entry first column actions
          $j("input[rel='support_faq_id'] ~ a").click(function()
          {
             var faqId = $j(this).prev().val();
             var faqContentId = "product_faq_" + faqId;
             
             ContentOverlay.ShowProductFAQ("productFAQSection", faqContentId);
          });
          
          // faq entry read column actions
          $j("a[rel='support_faq_read']").click(function()
          {
             $j(this).parent().siblings(":first").children("a:first").click();
          });
      
      // faq figures    
      $j("div[rel='figure'] a:first-child").click(function()
      {
         var imageId = $j(this).attr("rel");
         var image = $j("#" + imageId);
         $j("div[rel='figure'] :nth-child(2)[id!=" + imageId + "]").hide(100);
         image.toggle();
      });
      
      // product category tool tip
      $j("a.tooltip").hover(
      function() // over
      {
         $j(this).prev("div").children("div:first").addClass("on");
      },
      function() // out
      {
         $j(this).prev("div").children("div:first").removeClass("on");
      });
      
      // product category page d-link tv switch
      $j("a.categoryTVlink").click(function()
      {
         var tvId = $j(this).attr("rel");
         var tvplayer = $j("#tvplayerWrapper");
         
         if(tvplayer.css("display") == "none")
         {
            $j(this).addClass("clicked");
            tvplayer.show(500, function()
            {
               DLinkTV.updateMovieSrcLink(tvId,"tvplayer");
               //$j(this).addClass("clicked");
            });
         }
         else
         {
            if($j(this).hasClass("clicked"))
            {
               $j(this).removeClass("clicked");
               DLinkTV.updateMovieSrcLink(-1,"tvplayer");
               tvplayer.hide(500);
            }
            else
            {
               $j("a.categoryTVlink").removeClass("clicked");
               $j(this).addClass("clicked");
               DLinkTV.updateMovieSrcLink(tvId,"tvplayer");
            }
         }
      });
      
      //product page dlink tv switch
      $j("a[rel='product_showTvList']").click(function()
      {
         //$j(this).hide();
         var tvList = $j("div[rel='product_tvList']");

         /*$j("#tvContainer").hide(10, function()
         {
            DLinkTV.defaultToIntro('tvContainer');
            tvList.slideDown(500);
         });*/
         
         $j(this).parent().fadeOut(500, function()
         {
            DLinkTV.defaultToIntro('tvContainer');
            tvList.fadeIn(800);
         });
      });
      
      $j("a[rel='product_showTv']").click(function()
      {
         var tvList = $j("div[rel='product_tvList']");
         var tvId = $j(this).attr("data");
         
         tvList.fadeOut(500, function()
         {
            $j("#tvPlayer").fadeIn(800, function()
            {
               DLinkTV.updateMovieSrcLink(tvId,"tvContainer");
            });
         });
         
         /*tvList.slideUp(500, function()
         {
            $j("#tvPlayer").slideDown(500, function()
            {
               DLinkTV.updateMovieSrcLink(tvId,"tvContainer");
            });
         });*/
      });
      
      // image scroller, swap main images, 
      // update download panel content
    $j("img[rel='product_thumbnail']").click(function()
    {
       var mainImage = $j("img[rel='product_mainImage']");
       var imageSrc = $j(this).attr("src");//$j(this).get(0).src;
       var title = $j(this).attr("title");
       
       // main image swap, change href & alt 
       if(imageSrc.length > 0)
       {
          var mainImageSrc = imageSrc.replace("_thumb.jpg", ".png");
          mainImage.attr("src", mainImageSrc);
          mainImage.attr("alt", $j(this).attr("alt"));
          mainImage.attr("title", title);
          //mainImage.get(0).src = mainImageSrc;
          //mainImage.get(0).alt = $j(this).attr("alt");//$j(this).get(0).alt;
       }
       
       // change resolution size text & download paths
       //var lowResSpan = $j("#image_LowRes");
       //var highResSpan = $j("#image_HighRes");
       var lowResSpan = $j("span[rel='image_LowRes']");
       var highResSpan = $j("span[rel='image_HighRes']");
       var webSize = $j(this).attr("web");
       var printSize = $j(this).attr("print");
       var thumbImageFullPath = $j(this).attr("src"); // http://....somthing.jpg
       var thumbImagePathEndIndex = thumbImageFullPath.lastIndexOf("/"); 
       var thumbnailFullName = thumbImageFullPath.substring(thumbImagePathEndIndex + 1); // somthing.jpg
       var downloadPath = null;
       var webDownload = null;;
       var printDownload = null;
       
       if(lowResSpan != null)
       {
          lowResSpan.each(function(i)
          {
             $j(this).html(webSize);
             //webDownload = $j(this).siblings("a");
             webDownload = $j(this.parentNode);
             if(webDownload != null)
             {
                if(downloadPath == null)
                {
                   // ftp path
                   var path = webDownload.attr("href");//webDownload.get(0).href; // ftp;
                   var pathEndIndex = path.lastIndexOf("/");
                   downloadPath = path.substring(0, pathEndIndex + 1);
                }
                
                if(downloadPath != null)
                   webDownload.attr("href", downloadPath + thumbnailFullName.replace("_thumb", ""));
             }
          });
          //lowResSpan.html($j(this).attr("web"));
          //webDownload = lowResSpan.siblings("a");
       }
          
       if(highResSpan != null)   
       {
          highResSpan.each(function(i)
          {
             $j(this).html(printSize);
             //printDownload = $j(this).siblings("a");
             printDownload = $j(this.parentNode);
             if(printDownload != null && downloadPath != null)
             {
                printDownload.attr("href", downloadPath + thumbnailFullName.replace("_thumb.jpg", ".tif"));
             }
          });
          //highResSpan.html($j(this).attr("print"));
          //printDownload = highResSpan.siblings("a");
       }
       
       if(webDownload != null)
       {
          // ftp path
          //var path = webDownload.attr("href");//webDownload.get(0).href; // ftp;
          //var pathEndIndex = path.lastIndexOf("/");
          //downloadPath = path.substring(0, pathEndIndex + 1);
          
          //$j(this).get(0).src; 
       }
       
       /*if(downloadPath != null && thumbnailFullName != null)
       {
          webDownload.attr("href", downloadPath + thumbnailFullName);
          printDownload.attr("href", downloadPath + thumbnailFullName.replace("jpg", "tif"));
       }*/
       
       //add-on image downloading
       //var downloadPanel = $j("div[rel='image_download_panel']");
       /*downloadPanel.slideDown(500, function()
       {
          //alert($j(this)..filter(":first").get(0).innerHTML);
          $j(this).children(":first").fadeIn(50);
       });*/
       /*downloadPanel.animate({height:"30px"},500, function()
       {
          //alert($j(this)..filter(":first").get(0).innerHTML);
          $j(this).children(":nth-child(1)").fadeIn(50);
       });*/
    });
    
    // show the image downloading panel, sliding up
    $j("#product_imageDownload").click(function()
    {
       //var imagePanel = $j("div[rel='image_download_panel']");
       //var imageContent = imagePanel.children(":nth-child(1)").children(":nth-child(1)");
       var imageContent = $j("div[rel='image_download_contet']");
       
       if(imageContent.css("display") == "none")
       {
          imageContent.show(1, function()
          {
             $j(this).animate({top:"0px"}, 800);
          });
          /*imagePanel.animate({height:"32px"},500,function()
          {
             $j(this).children(":nth-child(1)").fadeIn(50);
          });*/
       }
       else
       {
          imageContent.animate({top:"32px"}, 800, function()
          {
             $j(this).hide();
          });
       }
    });
    
    //====================== solution page search ========
    $j("a[rel='go']").click(function()
    {
       var zip = $j("input[rel='zip']").val();
      
       if(zip.length == 0 || zip == 'Enter Zipcode')
       {
          alert("Please enter your 5 digits zip code");
          return false;
       }
    });
    
    //========================= PR ========================
    $j("a.pi-item").click(function()
    {
       var html = $j(this).html();
       $j("#prContentHeader").html(html);
       
       // update pr type
       //var type = $j(this).attr("prType");
       $j("#templateRightContent").next("input[type='hidden']").val(html);
       
       // update comment header text
       var cmtHeader = $j(this).attr("cmtText");
       $j("#prCmtText").html(cmtHeader);
    });
    //=====================================================
    
    //=============== master quick find click =============
    $j("#masterQuickFind").click(function()
    {
    });
    
    //=============== master country navigation =============================
    $j("#navcountry").hover(function()
    {
       $j("#navCountryList").slideDown(500);
    }, function()
    {
       $j("#navCountryList").slideUp(300);
    });
    
    $j("#showMoreCountries").click(function()
    {
       var items = $j("#navCountryList > ul").children();
       var sample = $j("#navCountryList > ul").children(":first");
       var nowTop = parseInt($j(sample).css("top"));
       var length = $j("#navCountryList > ul").attr("rel");
       var showHt = parseInt($j("#navCountryList > ul").css("height"));

       if(nowTop != null && Math.abs(nowTop) < (parseInt(length))-36 && length > showHt )
       {
          nowTop = nowTop - 18;
          items.css("top", nowTop + "px");
       }
    });
    
    $j("#showLessCountries").click(function()
    {
       var items = $j("#navCountryList > ul").children();
       var sample = $j("#navCountryList > ul").children(":first");
       var nowTop = parseInt($j(sample).css("top"));
       //var length = $j("#navCountryList > ul").attr("rel");
       
       if(nowTop != null && nowTop < 0 )
       {
          nowTop = nowTop + 18;
          items.css("top", nowTop + "px");
       }
    });
    //=============== Forms Check ======================
    function FormInputEmptyCheck(formid, rel, fieldname)
    {
       // textbox or textarea
       var ctrl = $j("#" + formid + " *[rel='" + rel + "']");
       var val = ctrl.val();
       
       if(typeof(val) == 'undefined' || val.length == 0) // input box
       {
          alert("Please fill in " + fieldname);
          return false;
       } 
       
       return true; 
    }
    
    function FormCheckBoxCheck(formid, rel, msg)
    {
       var ctrl = $j("#" + formid + " input[rel='" + rel + "']");
       var checked = ctrl.attr("checked");
       
       if(!checked)
       {
          alert(msg);
          return false;
       } 
       
       return true; 
    }
    
    // form on /products/ip-surveillance/free-site-survey/
    $j("*.free-site-survey-submit").click(function()
    {
       return (FormInputEmptyCheck("siteSurvey", "fn", "first name") && 
               FormInputEmptyCheck("siteSurvey", "ln", "last name") &&
               FormInputEmptyCheck("siteSurvey", "company", "company") && 
               FormInputEmptyCheck("siteSurvey", "title", "job title") && 
               FormInputEmptyCheck("siteSurvey", "email", "email") && 
               FormInputEmptyCheck("siteSurvey", "phone", "phone number") && 
               FormInputEmptyCheck("siteSurvey", "address", "address") && 
               FormInputEmptyCheck("siteSurvey", "city", "city") && 
               FormInputEmptyCheck("siteSurvey", "state", "state") &&
               FormInputEmptyCheck("siteSurvey", "zip", "zip"));
    });
    
    $j("*.test-drive-submit").click(function()
    {
       return (FormInputEmptyCheck("testDriveForm", "companyname", "company name") && 
               FormInputEmptyCheck("testDriveForm", "name", "name") &&
               FormInputEmptyCheck("testDriveForm", "resellername", "reseller name") && 
               FormInputEmptyCheck("testDriveForm", "companyaddress", "company address") && 
               FormInputEmptyCheck("testDriveForm", "title", "job title") && 
               FormInputEmptyCheck("testDriveForm", "city", "city") &&
               FormInputEmptyCheck("testDriveForm", "state", "state") &&
               FormInputEmptyCheck("testDriveForm", "zip", "zip") &&
               FormInputEmptyCheck("testDriveForm", "companyweb", "company web") &&  
               FormInputEmptyCheck("testDriveForm", "companyemail", "company e-mail") && 
               FormInputEmptyCheck("testDriveForm", "companyPhone", "company phone number"));
    });
    
    $j("*.feedback-submit").click(function()
    {
       return (FormInputEmptyCheck("feedBackForm", "email", "e-mail") && 
               FormCheckBoxCheck("feedBackForm", "terms", "You must agree to the D-Link's terms and conditions to submit your feedback."));
    });
    
    $j("*.govEd-contact-submit").click(function()
    {
       return(FormInputEmptyCheck("govedContactForm", "fn", "first name") && 
              FormInputEmptyCheck("govedContactForm", "ln", "last name") && 
              FormInputEmptyCheck("govedContactForm", "agency", "agency/school") && 
              FormInputEmptyCheck("govedContactForm", "email", "e-mail") && 
              FormInputEmptyCheck("govedContactForm", "phone", "phone") && 
              FormInputEmptyCheck("govedContactForm", "address", "address") && 
              FormInputEmptyCheck("govedContactForm", "city", "city") && 
              FormInputEmptyCheck("govedContactForm", "state", "state") && 
              FormInputEmptyCheck("govedContactForm", "zip", "zip"));
    });
    
    $j("*.giveaway-submit").click(function()
    {
       if($j("select[rel='state']").val() == "")
       {
          alert("Please select a state");
          return false;
       }
       
       if($j("input[rel='email']").val().indexOf("@") == -1 ||
		    $j("input[rel='email']").val().indexOf(".") == -1)
		 {
		    alert("Please enter a valid email.");
		    $j(this).focus();
          return false;
		 }
    
       return(FormInputEmptyCheck("giveawayForm", "fn", "first name") && 
              FormInputEmptyCheck("giveawayForm", "ln", "last name") && 
              FormInputEmptyCheck("giveawayForm", "email", "e-mail") &&  
              FormInputEmptyCheck("giveawayForm", "zip", "zip") &&
              FormCheckBoxCheck("giveaways2ndForm", "terms", "You must agree to the D-Link's terms and conditions to sign up for D-News."));
    });
    
    $j("*.care-support-submit").click(function()
    {
       return(FormInputEmptyCheck("careSupportPkgForm", "fn", "first name") && 
              FormInputEmptyCheck("careSupportPkgForm", "ln", "last name") && 
              FormInputEmptyCheck("careSupportPkgForm", "email", "e-mail") &&  
              FormInputEmptyCheck("careSupportPkgForm", "company", "company") &&
              FormInputEmptyCheck("careSupportPkgForm", "title", "job title") &&
              FormInputEmptyCheck("careSupportPkgForm", "phone", "phone") &&
              FormInputEmptyCheck("careSupportPkgForm", "address", "address") &&
              FormInputEmptyCheck("careSupportPkgForm", "city", "city") &&
              FormInputEmptyCheck("careSupportPkgForm", "state", "state") &&
              FormInputEmptyCheck("careSupportPkgForm", "zip", "zip"));
    });
    
    //=============== tech support options =======================    
    $j("*.dynamic-swap").click(function()
    {
       var rel = $j(this).attr("rel");
       
       $j("#" + rel).siblings("*[rel='swapContent']").slideUp(300, function()
       {
          $j("#" + rel).slideDown(500);
       });
    });
    
    //=============== hp setting on overlay ======================
    $j(".set-default").click(function()
    {
       var checked = $j(this).children(":checkbox").attr('checked');
       var cookieVal = $j(this).children(":checkbox").attr("value");

       if(typeof(checked) == 'undefined' || checked == true)
       {
          // check clicked cb and uncheck other cbs
			 $j(".set-default :checkbox").attr("checked", "");
			 $j(this).children(":checkbox").attr("checked", "checked");
			 
			 // set cookie
			 setHPCookie(cookieVal, cookiePkg);
       }
    });
    
    //=============== biz switch change ===========================
    
    $j("#switchChange a").click(function()
    {
       var overview = $j("#overviewContent");
       var image = $j("img.product-img");
       var desc = $j("p.reg span");
       var ps = $j("a.productSelectorLink");
       
       var ovVal = $j(this).attr("ov");
       var imgVal = $j(this).attr("img");
       var descVal = $j(this).attr("desc");
       var psVal = $j(this).attr("ps");
       
       overview.html(ovVal);
       image.attr("src", imgVal);
       image.attr("alt", descVal);
       desc.html(descVal);
       ps.attr("rel", psVal);
    });
    
    //=============== bottom navigation ============================
    
    $j(".btmNav").hover(function()
    {
       var infoId = $j(this).attr("rel");
       var content = $j("#" + infoId);
       
       $j("#footer").css("zIndex", "300");
       $j("#" + infoId).fadeIn(500);
    }, function()
    {
       var infoId = $j(this).attr("rel");
       var content = $j("#" + infoId);
       
       $j("#footer").css("zIndex", "");
       content.fadeOut(200);
    });
    
       
   //////////////////////////////////////////////////
   // ajax functions
   //////////////////////////////////////////////////
   
   // contact option on support page
   $j(".contact-ddl-submit").click(function()
   {
   });
   
   //////////////////////////////////////////////////
   // ajax functions end
   //////////////////////////////////////////////////
    
    /*$j(".btmNav").hover(function()
    {
       var infoId = $j(this).attr("rel");
       $j("#" + infoId).animate({top:"0px"}, 800, function()
       {
       });
       $j("#" + infoId).fadeIn(500);
       
    }, function()
    {
       var infoId = $j(this).attr("rel");
       var content = $j("#" + infoId);
       
		 content.animate({top:"100px"}, 500, function()
		 {
		 });
		 //content.hide();
		 content.fadeOut(200);
		 
    });*/
    
    /*$j(".btmNavContent").hover(function()
    {
       if($j(this).css("display") != "block")
       {
          $j(this).animate({top:"0px"}, 800, function()
			 {
			 });
       }
       else
       {
       }
       
    }, function()
    {
       $j(this).animate({top:"100px"}, 500, function()
	    {
	    });
    });*/
    
    //=============== bottom navigation end =========================
    
    /*$j("#product_imageDownload2").click(function()
    {
       var imagePanel = $j(this).prev();
       var imageContent = imagePanel.children(":nth-child(1)").children(":nth-child(1)");
       
       if(imageContent.css("display") == "none")
       {
          imageContent.fadeIn(800, function()
          {
             //$j(this).animate({top:"0px"}, 800);
          });
       }
       else
       {
          imageContent.fadeOut(800);
       }
    });*/
    
    /*$j("div[rel='image_download_panel']").click(function()
    {
       if($j(this).children(":nth-child(1)").css("display") == "none")
       {
          $j(this).animate({height:"30px"},500,function()
          {
             $j(this).children(":nth-child(1)").fadeIn(50);
          });
       }
    });*//*.hover(function()
    {
       if($j(this).children(":nth-child(1)").css("display") == "none")
       {
          $j(this).animate({height:"15px"});
       }
    },function()
    {
       if($j(this).children(":nth-child(1)").css("display") == "none")
       {
          $j(this).animate({height:"5px"});
       }
    })
    $j("#imageDownloadClose").click(function()
    {
       $j("div[rel='image_download_panel']").animate({height:"0px"},500).children(":nth-child(1)").hide();
    });*/
      
   /////////////////////////////////////////////////
});
/////////////////////////////////////////////////

//////////////////////////////////////////////////
// Common Functions
//////////////////////////////////////////////////

function classSwitch(control, classToAdd, classToRemove)
{
   control = $(control);
   control.addClassName(classToAdd);
   control.removeClassName(classToRemove);
}

//////////////////////////////////////////////////
// Close HomePage Setting @ Default page
//////////////////////////////////////////////////

function closeHpSetter(click, pkg)
{
   var setter = $(click.parentNode.parentNode);
   
   /*setter.removeClassName(pkg.classOn);
   setter.addClassName(pkg.classOff);*/
   classSwitch(setter, pkg.classOff, pkg.classOn);
}

// sync HP setter radio button selection & each Tab default check box
function syncCheck(value, pkg)
{
   cookieHPPair.each(function(pair)
   {
      if(pair.value == value)
      {
         $(pair.key).checked = true;
      }
   });
   
   setHPCookie(value, pkg);
}

//--------------------------------------

//////////////////////////////////////////////////
// D-Link TV related 
//////////////////////////////////////////////////

// wrapper function to combine different functino callings.
/*function showEpisodes(vid, tvContainerId)
{
   DLinkTV.updateMovieSrcLink(vid, tvContainerId);
   tvSwitch();
}

function tvSwitch()
{
   //var tvList = $(optionPackage.tvList);
   //var tvPlayer = $(optionPackage.tvPlayer);
   var tvList = $("tvList");
   var tvPlayer = $("tvPlayer");
   var on = 'on';
   var off = '';
   
   if(tvList.hasClassName(on))
   {
      classSwitch(tvList, off, on);
      classSwitch(tvPlayer, on, off);
   }
   else
   {
      DLinkTV.defaultToIntro('tvContainer');
   
      classSwitch(tvList, on, off);
      classSwitch(tvPlayer, off, on);
   }
}*/

/*
   DLinkTV variable contains functions and settings to play embedded D-Link TV
   - CreatMovie is called on page loading to creat the object
   - UpdateMovieSrcLink is called to change the src of the playing video
   - DefaultToIntro is called to switch the playing video to the Intro video
*/
var DLinkTV =
{
   player: null,
   vid: -1,
   settings: 
   {
      playerID: "www_dlinkTV",
      width: 400,
      height: 300,
      size: 1,
      tvContainerID: "tvContainer"
   },
   createMovie: function(containerId, width, height)
   {
      /*var fo = new SWFObject("/player_www.swf?vid=", this.settings.playerID, this.settings.width, this.settings.height, "8", "#ffffff");
      fo.addParam("allowScriptAccess", "always");
	  fo.addParam("wmode","transparent");
 	  fo.write(this.settings.tvContainerID);
 	  
 	  DLinkTV.player = $(this.settings.playerID);
 	  DLinkTV.player.setStyle({margin:'0 auto'});*/

 	  var flashvars = {};

      var params = {};
      params.menu = "false";
      params.allowScriptAccess = "always";
      params.wmode = "transparent";

      var attributes = {};

 	  swfobject.embedSWF("/player_www.swf?vid=", containerId, width, height, "8.0.0","expressInstall.swf", flashvars, params, attributes);
 	  
 	  //DLinkTV.player = $(playerID);
 	  //DLinkTV.player.setStyle({margin:'0px'});
   },
   updateMovieSrcLink: function(id, containerId)
   { 
      var player = $(containerId);
      if(player != null)
      {
         var timeout = 1000;
            
         if(player.tagName.toLowerCase() == 'object')
            setTimeout(function()
            {
               if(player.playMovie)
               {
                  player.playMovie(id);
                  DLinkTV.vid = id;
               }
            }, timeout);
      }
   },
   defaultToIntro: function(containerId)
   {
      if(DLinkTV.vid != -1)
      {
         this.updateMovieSrcLink(-1, containerId);
      }
   }/*,
   playerControl: function(id, element, containerId)
   {
      element = $(element); // text link
      if(element.hasClassName('clicked'))
      {
         DLinkTV.updateMovieSrcLink(id,containerId);
      }
      else
      {
         DLinkTV.updateMovieSrcLink(-1,containerId);
      }
   }*/
};

//////////////////////////////////////////////////
// D-Link Home Page Cookie Setting 
//////////////////////////////////////////////////
var cookieHPValues = {HHO:'1', SMB:'2', LB:'3', GOV:'4', Reseller: '5'};
var cookieHPPair = $H();
//var cookieHPPair is loaded by serverside

// cookie settings
var cookiePkg = 
{
   name: 'dlinkHPSetting',
   value: cookieHPValues.HHO,
   expDays: 365,
   expires: 3600000 * 24 * this.expDays
};

function setHPCookie(value, pkg)
{
   if(value != null)
      pkg.value = value;
   
   var exDate = new Date();
   exDate.setDate(exDate.getDate() + pkg.expDays);
   
   document.cookie = pkg.name + "=" + escape(pkg.value) + ";expires=" + exDate.toGMTString() + ";path=/";
}

function getHPCookie(cookieName)
{
   if (document.cookie.length>0)
   {
      var start = document.cookie.indexOf(cookieName + "=");
      if (start!=-1)
      { 
         start = start + cookieName.length+1; 
         end = document.cookie.indexOf(";", start);
         if (end==-1) end=document.cookie.length;
            return unescape(document.cookie.substring(start,end));
      } 
   }
   return "";
}

//called when the check box on each tab is clicked, and
//set the cookie; if unchecked, set HHO as Default
function checkHP(control, value, pkg)
{
   if(control != null && pkg != null)
   {
      if(value == null)
         value = cookieHPValues.HHO;
         
      if(control.checked)
      {
         setHPCookie(value, pkg);
         
         // uncheck all other options
         cookieHPPair.each(function(pair)
         {
            var ctrl = $(pair.key);
            if(ctrl.id != control.id)
            {
               ctrl.checked = false;
            }
         }.bind(this));
      }
      else
      {
         setHPCookie(cookieHPValues.HHO, pkg);
      }
   }
}

//////////////////////////////////////////////////
// Image Scroller
//////////////////////////////////////////////////
var scroller = 
{
   //pkg: null,
   scroll: function(direction,pkg,booster)
   {
      var thisPkg = pkg;
      if(thisPkg == null || direction == null)
         return;
         
      if(booster == null)
         booster = 1;   
         
       if(direction == "left")
       {
           this.clearScroll(thisPkg);
           if(thisPkg.imageCount > thisPkg.imageToShow)
           {
              this.scrollLeft(thisPkg, booster);
           }
       }
       else
       {
           this.clearScroll(thisPkg);
           if(thisPkg.imageCount > thisPkg.imageToShow)
           {
              this.scrollRight(thisPkg, booster);
           }
       }
   },
   scrollLeft: function(pkg, booster) // should be on the right arrow
   {
      var thisPkg = pkg;
      if(thisPkg == null)
         return;
         
      var currentPosition = Number($(thisPkg.thumbnailWrapper).getStyle("left").replace("px","")) - (thisPkg.scrollSpeed*booster);
      var positionInPixel = currentPosition + "px"; 

      if(currentPosition >= thisPkg.leftBnd)
      {
         $(thisPkg.thumbnailWrapper).setStyle({left: positionInPixel});

         if(thisPkg.scrollInterval == null)
         {
            thisPkg.scrollInterval = setInterval(function(){this.scrollLeft(thisPkg, booster);}.bind(this), 10);
         }
      }
      else
      {
         var leftEnd = thisPkg.leftBnd + "px";
         $(thisPkg.thumbnailWrapper).setStyle({left: leftEnd});
         clearInterval(thisPkg.scrollInterval);
         thisPkg.scrollInterval = null;
      }   
   },
   scrollRight: function(pkg, booster)
   {
      if(pkg == null)
         return;
         
      var currentPosition = Number($(pkg.thumbnailWrapper).getStyle("left").replace("px","")) + (pkg.scrollSpeed*booster);
      var positionInPixel = currentPosition + "px"; 

      if(currentPosition < pkg.rightBnd)
      {
         $(pkg.thumbnailWrapper).setStyle({left: positionInPixel});

         if(pkg.scrollInterval == null)
         {
            pkg.scrollInterval = setInterval(function(){this.scrollRight(pkg, booster);}.bind(this), 10);
         }
      }
      else
      {
         var rightEnd = pkg.rightBnd + "px";
         $(pkg.thumbnailWrapper).setStyle({left: rightEnd});
         clearInterval(pkg.scrollInterval);
         pkg.scrollInterval = null;
      }   
   },
   clearScroll: function(pkg)
   {
      clearInterval(pkg.scrollInterval);
      pkg.scrollInterval = null;
   }
};

/*function mainImageSwap(thisImage, mainImageId)
{
   var mainImage = $(mainImageId);
   var imageSrc;
   
   if(typeof(thisImage.src) == 'undefined' || thisImage.src == null)
   {  
      imageSrc = '';
   }
   else
   {
      imageSrc = thisImage.src;
      imageSrc = imageSrc.replace(".jpg", "_main.png");
      //imageSrc = imageSrc.replace("_30x30.gif", "_main.jpg");
      mainImage.src = imageSrc;
      mainImage.alt = thisImage.alt;
   }
}*/

//////////////////////////////////////////////////
//  Overlay DropDown Menu
//////////////////////////////////////////////////


//////////////////////////////////////////////////
//  Product Page Functions
//////////////////////////////////////////////////
/*var demoWindow = null;
var productSelectorWindow = null;

function LoadBtmResource(rscURL)
{
   var rscWrapper = $('overlay');
   var rsc = $('frame_productResource');
   
   rsc.src = rscURL;
   
   rscWrapper.removeClassName('off');
}

function LoadProductSelector(dpodid, width, height)
{
   var productSelector = $('productResourceOverlay');
   var selectorFrame = $('frame_productselector');
   
   if(selectorFrame.src == '')
      selectorFrame.src = 'http://webapps.easy2.com/cm/masterflash/generic_index.asp?page_id=' + dpodid;
      
   productSelector.removeClassName('off');
}

function LoadDemo(dpodid, width, height)
{
   if(demoWindow != null)
      demoWindow.close();

   if(width == null)
      width = 629;
      
   if(height == null)
      height = 511;  
   
   demoWindow = window.open('http://webapps.easy2.com/cm/masterflash/generic_index.asp?page_id=' + dpodid,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ', height=' + height + '');
}*/

//////////////////////////////////////////////////
//  Product Page Quote Rotator
//////////////////////////////////////////////////

function rotate(pkg)
{
     var control = $(pkg.control);
     var rotationText = pkg.rotationText;
     
     if(control.getStyle("opacity") != 0)
     {
        control.setStyle({opacity:0, filter:"alpha(opacity=0)"});
     }
      
     if(Object.isUndefined(control.rotateIndex))
     {
        control.rotateIndex = 0;
        var displayText = rotationText[control.rotateIndex];
        control.innerHTML = displayText;
     }
     
     control.opCount = 0;
     
     control.opInterval = setInterval(function()
     {
        control.opCount = control.opCount + 1;
           
        var nowOp = control.opCount/10;
        var nowFilter = control.opCount*10;
        
        //nowOp = nowOp + 0.1;
        nowFilter = "alpha(opacity=" + nowFilter.toString() + ")";
        
        if(nowOp > 1)
        {
             clearInterval(control.opInterval);
             control.opCount = 10;
             
             setTimeout(function()
             {  
                control.opInterval = setInterval(function()
                {
                   control.opCount = control.opCount - 1;
                   
                   var nowOp = control.opCount/10;
                   var nowFilter = control.opCount*10;
                    
                   nowFilter = "alpha(opacity=" + nowFilter.toString() + ")";
                   
                   if(nowOp < 0)
                   {
                        clearInterval(control.opInterval);
                   
                        control.rotateIndex = control.rotateIndex + 1;
                        
                        if(control.rotateIndex >= rotationText.length)
                           control.rotateIndex = 0;
                           
                        var displayText = rotationText[control.rotateIndex];
                        control.innerHTML = displayText;
                           
                        rotate(pkg);
                   }
                   else
                   {
                      control.setStyle({opacity:nowOp, filter:nowFilter});
                   }
                   
                }, 100);
             
                
             }, 
             pkg.timeout);
        }
        else
        {
           control.setStyle({opacity:nowOp, filter:nowFilter});
        }
     }.bind(this), 150);
}

//////////////////////////////////////////////////

//////////////////////////////////////////////////
//  Search Box Ajax functions
//////////////////////////////////////////////////

function GetSearchResult(term)
{
  var target = $('searchResult');

  Dlink_New_Site.WS.MasterProcesses.Search(term, 
  function(result)
  {
     target.innerHTML = result;     
     if(!target.hasClassName('on') && result.length > 0)
     {
        classSwitch(target, 'on', 'off');
        //classSwitch(target, 'on', 'off');
     }
     else if(result.length == 0)
     {
        classSwitch(target, 'off', 'on');
        //target.innerHTML = "No results were found.";
     }                              
  }.bind(this));
}

function OnSucceeded(result)
{
    $('searchResult').innerHTML = result;
}

//////////////////////////////////////////////////
//  Search Box client functions
//////////////////////////////////////////////////

function searchboxStateChange(searchBox, resultBoxId)
{
   searchBox = $(searchBox);
   //alert(searchBox.beforeValue);
   if(searchBox.beforeValue != null)
   {
      if(searchBox.beforeValue == searchBox.value)
         return;
   }

   var resultBox = $(resultBoxId);
   if(searchBox.value.length < 2)
   {    
      if(!resultBox.hasClassName('off'))  
         classSwitch(resultBox, 'off', 'on');
      resultBox.innerHtml = '';
   }
   else
   {
      setTimeout(function(){GetSearchResult(searchBox.value);}.bind(this), 500);
   }
}

// change search result item state on the list when mouse is hovered over
function searchMouseHover(searchItem)
{
   searchItem = $(searchItem);
   searchItem.siblings().each(function(sibling)
   {   
      $(sibling).removeClassName('selected');
   });
   searchItem.addClassName('selected');
}

// check if the user key in numbers
function isNumberKey(evt)
{
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
      return false;

   return true;
}

// make search result list accessible from keyboard with up & down & enter
function keyboardDown(e)
{
   var keynum;
   var result = $('searchResult');
   var isSelected = false;
   var resultList = result.down(0); // ul
   var tb = Event.element(e);
   //var result = $('searchresults');
   
   if(result == null)
      return;

   // get keycode for different browser
   if(window.event) // IE
   {
      keynum = e.keyCode;
   }
   else if(e.which) // Netscape/Firefox/Opera
   {
      keynum = e.which;
   }
   
   
   if(keynum == 40 && result != null && result.hasClassName('on')) // key arrow up
   {
      resultList.childElements().each(function(element, index)
      {
         if($(element).hasClassName('selected'))
         {  
            if(index < resultList.childElements().length - 1)
            {
               $(element).removeClassName('selected');
               $(element).next(0).addClassName('selected');
            }
            isSelected = true;
            throw $break;
         }
      });
      
      if(!isSelected)
         resultList.down(0).addClassName('selected');
   }
   else if(keynum == 38 && result != null && result.hasClassName('on')) // key arrow down
   {
      resultList.childElements().each(function(element, index)
      {
         if($(element).hasClassName('selected'))
         {
            if(index > 0)
            {
               $(element).removeClassName('selected');
               $(element).previous(0).addClassName('selected');
            }
            else
            {
               $(element).removeClassName('selected');
            }
            isSelected = true;
            throw $break;
         }
      });
      
      if(!isSelected)
         resultList.up(0).addClassName('selected');
   }
   else if(keynum == 13 && result != null && result.hasClassName('on')) // enter key
   {
      resultList.childElements().each(function(element, index)
      {
         if($(element).hasClassName('selected'))
         {
            var dest = $(element).down(0).href;
            tb.value = dest;
            tb.setStyle({color:'white'});
            if(window.event) // IE
            {
               document.location = dest;
            }
            else if(e.which) // Netscape/Firefox/Opera
            {
               document.location.url = dest;
            }
         }
      });
   }  
}
//////////////////////////////////////////////////
//  Product Selector functions
//////////////////////////////////////////////////
/*var Overlay = 
{
   overlaySection: "overlay",
   Open: function(){$(this.overlaySection).removeClassName("off");},
   Close: function(){$(this.overlaySection).addClassName("off");},
   Show: function(overlaySectionId)
   {
      $j("#" + overlaySectionId).siblings(":not(a)").hide();
      $j("#" + overlaySectionId).slideDown(500);
   },
   Hide: function(overlaySectionid){}
};*/

var ContentOverlay =
{
   overlaySection: "#contentOverlaySection",
   Open: function() 
   {
      $j(this.overlaySection).show(500, function()
      {
         var illustration = $j("div.categoryIllustration");
         if(illustration != null)
            illustration.hide();
            
         /*var contentBody = $j("#contentBody");
         if(contentBody != null)
         {
            //contentBody.hide();
            contentBody.removeClass("contentBodyBG");
         }*/
      });
   },
   Close: function() 
   {
      $j(this.overlaySection).hide(500);
      //$j("#prodcutSelectorFrame").removeAttr("src");
      var illustration = $j("div.categoryIllustration");
      if(illustration != null)
         illustration.show();
         
      openingShow();
      
      /*var contentBody = $j("#contentBody");
      if(contentBody != null)
         contentBody.addClass("contentBodyBG");*/
   },
   HideSiblings: function(sectionId)
   {
      var sec = $j("#" + sectionId);
      sec.siblings(":not(a)").hide();
      sec.show();
   },
   ShowProductSelector: function(url)
   {
      this.Open();
      this.HideSiblings("productSelectorSection");
      $j("#productSelectorFrame").attr("src", url);
       
       openingHide();
   },
   ShowProductFAQ: function(sectionId, faqId)
   {
      if($j("#" + faqId).length > 0)
      {
         this.Open();
         this.HideSiblings(sectionId);
         this.HideSiblings(faqId);
         $j("#" + faqId).slideDown(300);
         
         openingHide();
      }
   },
   ShowGeneralSection: function(sectionId)
   {
      this.Open();
      this.HideSiblings(sectionId);
      
      openingHide();
   }
};

function openingShow()
{
    if($j("#opening") != null)
    {
       $j("#opening").fadeIn(300, function()
       {
          DLinkTV.updateMovieSrcLink(321,"openingContainer");
       });
    }
}

function openingHide()
{
    if($j("#opening") != null)
    {
     $j("#opening").fadeOut(800, function()
     {
        DLinkTV.defaultToIntro('openingContainer');
     });
    }
}

/*function OpenProductSelector(id)
{
   //$(id).addClassName('on');
   $(id).removeClassName('off');
}

function CloseProductSelector(id)
{
   //$(id).removeClassName('on');
   $(id).addClassName('off');
   //$('frame_productResource').src = '';
   //$('frame_productselector').addClassName('off');
}

// product category functions
var Switcher =
{
   changeState: function(element, ctrlElement)
   {
      // element properties: ctrlElement
      if(!Object.isElement(element))
         return;
    
      element = $(element);
      
      if(Object.isUndefined(element.ctrlElement))
      {
         element.ctrlElement = $(ctrlElement);
      }
      
      if(!element.hasClassName('clicked'))
      {
         this.turningOn(element);
      }
      else
      {
         element.removeClassName('clicked');
         element.ctrlElement.setStyle({display:'none'});
      }
         
      return element;
   },
   turningOn: function(element)
   {
      element.addClassName('clicked'); // add style to link
      var ctrl = element.ctrlElement;
      ctrl.setStyle({display:'block'}); // show tv
      
      // remove 'on' style on other members
      if(switcherPkg.members.length > 0)
         switcherPkg.members.each(function(i)
                                 {
                                    var member = $(i);
                                    if(i != element.id)
                                    {
                                       member.removeClassName('clicked');
                                    }
                                 });
   }
};*/
//======================= pop up for retailer map
function mapPopup(url)
{
   window.open(url,"","width=900,height=520,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1");
}
//======================= pop up for retailer map end

//======================= support page pop up 
// no delay
function doPopup(url) 
{
   url = "/support/" + url;
   window.open(url,'DlinkReg', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1');
}
//======================= support page pop up end
// End DLink.js
//////////////////////////////////////////////////
// -->
