﻿

VitalStim = 
{
    ImageReplace:function()
    {
        var nodes = $(".img-replace");
        
        for(x = 0; x < nodes.length; x++)
        {
            var imgpath = $(nodes[x]).attr("id");
            $(nodes[x]).html("<img src=\"/images/" + imgpath + "\" />");
        }
    }
    ,
    Init:function(SectionID)
    {

        VitalStim.SetMainNav(SectionID);
        VitalStim.ImageReplace();
        VitalStim.SetFaqs();
        VitalStim.SwallowSwf();
        
        if(VitalStim.VideoSrc != null)
        {
            VitalStim.VideoPlay();
        }     
        
        
        $("#search_input_button").bind("click", function(e){
        
            var searchTerm = $("#search_input").val();
            document.location.href="/search.aspx?searchtext=" + searchTerm + "&folderid=0&orderby=id&searchfor=all&orderdirection=ascending";
  
        });   
    }
    ,
    PopUpLogin:function(url)
    {
        window.open(url, "myWindow", "status = 1, height = 300, width = 300, resizable = 0" );
    }
    ,
    SectionID:null
    ,
    SetFaqs:function()
    {
        var faqs = $(".faq");
        
        for(f =0; f < faqs.length; f++)
        {
            $(faqs[f]).find(".question").attr("id","faq"+f);
            $(faqs[f]).find(".question").css("cursor","pointer");
            
            $(faqs[f]).find(".answer").attr("id","ans"+f);
            
           
            
            $(faqs[f]).find(".question").bind("click", function(e){
                
                
                var s = $(this).attr("id");
                var ansid = "ans" + s.substring(3,s.length);
                
                
                if($("#"+ansid).css("display") == "none")
                {
                    $("#"+ansid).show(200);
                }
                else
                {
                    $("#"+ansid).hide(200);
                }
                               
            });
            
            
  
            
            
        }
    }
    ,
    SetMainNav:function(section_id)
    {
    
          $("#vslogo").bind("click", function(e){
             document.location = "/index.aspx";
          });
        
        
     

    
      // replace text with images  
      var x =  $("#main-nav ul li a");
           
            if(section_id == 1)
            {
                $(x[0]).html("<img src='/images/main_nav/n1_on.gif' alt='What is Dysphagia?'/>");
            }
            else
            {
                $(x[0]).html("<img src='/images/main_nav/n1.gif' alt='What is Dysphagia?'/>");
            }
            
            if(section_id == 2)
            {
               $(x[1]).html("<img src='/images/main_nav/n2_on.gif' alt='What is VitalStim?'/>");
            }
            else
            {
                $(x[1]).html("<img src='/images/main_nav/n2.gif' alt='What is VitalStim?'/>");
            }
           
            if(section_id == 3)
            {
               $(x[2]).html("<img src='/images/main_nav/n3_on.gif' alt='Patient Stories'/>");
            }
            else
            {
                $(x[2]).html("<img src='/images/main_nav/n3.gif' alt='Patient Stories'/>");
            }
            
            if(section_id == 4)
            {
                $(x[3]).html("<img src='/images/main_nav/n4_on.gif' alt='Health Professionals'/>");
            }
            else
            {
                $(x[3]).html("<img src='/images/main_nav/n4.gif' alt='Health Professionals'/>");
            }
            
            
           
           
      // set hover event for each image
      var i =  $("#main-nav ul li a img");
           
            if(section_id != 1)
            {
                $(i[0]).hover(
                  function () {
                    $(this).attr("src", "/images/main_nav/n1_on.gif");
                  }, 
                  function () {
                     $(this).attr("src", "/images/main_nav/n1.gif");
                  }
                );
            }
            
            if(section_id != 2)
            {
                $(i[1]).hover(
                  function () {
                    $(this).attr("src", "/images/main_nav/n2_on.gif");
                  }, 
                  function () {
                     $(this).attr("src", "/images/main_nav/n2.gif");
                  }
                );
            }
            
            if(section_id != 3)
            { 
                $(i[2]).hover(
                  function () {
                    $(this).attr("src", "/images/main_nav/n3_on.gif");
                  }, 
                  function () {
                     $(this).attr("src", "/images/main_nav/n3.gif");
                  }
                );
            }
            
            if(section_id != 4)
            { 
                $(i[3]).hover(
                  function () {
                    $(this).attr("src", "/images/main_nav/n4_on.gif");
                  }, 
                  function () {
                     $(this).attr("src", "/images/main_nav/n4.gif");
                  }
                );
            }
    
    }
    ,
    SwallowSwf:function()
    {
        if($("#swallow-swf").length > 0)
        {
            flashembed("swallow-swf", 
					   
						  /*
						   * second argument supplies standard Flash parameters.
						   * basically these are all you want to modify
						   * but you can see full list here
						   */
						  {
							 src:'/flash/swallow.swf',
							 width:250,  
							 height:278,
							 bgcolor:'#FFFFFF'
						  }
							
						 
					   );
        }        
    }
    ,
    VideoSrc:null
    ,
    VideoPlay:function()
    {
    
				flashembed("videoplayer", 
					   
						  /*
						   * second argument supplies standard Flash parameters.
						   * basically these are all you want to modify
						   * but you can see full list here
						   */
						  {
							 src:'/flash/FlowPlayerLight.swf',
							 width:400,  
							 height:300,
							 bgcolor:'#ffffff'
						  },
							
						  /*
						   * third argument is Flowplayer specific configuration
						   * full list of options is given here
						   */
						   
						  {config: {   
							 videoFile: VitalStim.VideoSrc,
							 initialScale: 'scale', 
							 useNativeFullScreen: true
								
							 // supply more options here by separating them with commas
						  }}
						    
					   );
    
    }
    ,
    LoadHomeFlash:function()
    {
        
    	flashembed("home-intro", 
					   
						  /*
						   * second argument supplies standard Flash parameters.
						   * basically these are all you want to modify
						   * but you can see full list here
						   */
						  {
							 src:'/flash/vitalstim_home.swf',
							 width:905,  
							 height:253,
							 bgcolor:'#39671E'
						  }
							
						 
					   );
    
    }
}   



