﻿

//טעינת הוידאו אל הדף


$(window).load(function(){
  $('.hp_video .flashPlace').each(function() {
    var id = $(this).attr("name");
    var strUrl = "../Resources/Flash/themovie.swf?longText=../Handler/Video.ashx?id=" + id + "&lastVar=1";
 /*   $(this).media({ 
                width:     '298', 
                height:    '234', 
                bgColor: '#DCDCDC',
                autoplay:  true, 
                src:       '../Resources/Flash/themovie.swf',
                params:    { allowFullScreen:'true',id:'EmbedVideo', name:'EmbedVideo'},
                flashvars: { longText:'../Handler/Video.ashx?id=' + id , lastVar:'1' }, 
                caption:   false // supress caption text 
            }).attr("id","EmbedVideo"); 
        */
      $(this).html("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH='298'  HEIGHT='234' id='EmbedVideo'> 	<PARAM NAME=movie VALUE='" + strUrl +"'> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#DCDCDC>    <param name='allowFullScreen' value='true' />	<EMBED    swliveconnect='true'  id='EmbedVideo1' name='EmbedVideo' src='" +strUrl +"'	quality=high 	bgcolor=#DCDCDC  	WIDTH=298 	HEIGHT=234        allowFullScreen=true	TYPE='application/x-shockwave-flash' 		PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>	</EMBED></OBJECT>");
     });
});







$(document).ready(LoadRelatedVideo);

var myTimer;
var items;
var gallery_images_place;
var selectedItem;
var header_place;
var description_place;
var images_group;
var scroll_right;
var scroll_left;
var gallery_images;
var scroll;
function LoadRelatedVideo()
{

header_place= $('#header_place');
description_place= $('#description_place');
gallery_images_place=$('#gallery_images_place');
gallery_images=$('#gallery_images');
scroll_left=$('#scroll_left');
scroll_right=$('#scroll_right');
             $.ajax({
             type: "POST",
             contentType: "application/json; charset=utf-8",
             url: "../Services/Service.asmx/GetHpRelatedVideo",
             data:"{}",
             dataType: "json",
             success: function(results) {
                    items=results; 
                    images_group=new Array();
                    AddThumbnail();
                    $(scroll_left).click(function(){
                        gallery_images.scrollTo( '-=250px',500, { axis:'x' } );
                    }); 
                    $(scroll_right).click(function(){
                        gallery_images.scrollTo( '+=250px',500, { axis:'x' } );
                    }); 
             }

            });

}






function AddThumbnail()
{
if(items != null)
{

      for (var i =0; i< items.length; i++)
      {
           var td = document.createElement('td');
           var img =document.createElement('img');
           $(img).attr('id',i).attr('src',root+ "Data/"+ items[i].Thumbnail);
           $(img).click(function(){
             $(header_place).text(items[this.id].Header);
             $(description_place).text(items[this.id].Description);    
               $(images_group[selectedItem]).removeClass('select');
               $(this).addClass('select');
               getVideoByXml('../Handler/Video.ashx?id=' +items[this.id].VideoId,"EmbedVideo" );
               selectedItem=this.id;  
           });
           td.appendChild(img);
           images_group[i]=img;
           $(td).appendTo(gallery_images_place);
           
           if(i==0)// first element
           {
             selectedItem= i;
             $(img).addClass('select');
           }   
    
  

    }
 }

}


$(document).ready(function(){
   $('.panel2_item').mouseenter(function(){ 
       var image = $('.panel2_img', $(this));
            if(image){  image.animate({height:0}, 200); $(this).addClass('opened'); }
       })
      .mouseleave(function(){ 
        var image = $('.panel2_img', $(this));
            if(image){image.animate({height:77}, 200); $(this).removeClass('opened');}
       })
       .click(function(){
            var link = $('.panel2_link',$(this));
            if(link)
            {
                location.href= link.attr("href");
            }
       });
  
});
