function switchVideos(vType, vUrl,screenshot){

    // Unload the flowplayer before deleting the element
      // if(flowplayerobj != null)
     //     flowplayerobj.unload();

    // removing the element
       $('#video').text(' ');
       $('#video').remove();
    // Creating the element [ #video ] again after removng it.

       $('#video-wrap').append('<div id="video" style="width:520px; height:300px"></div>');

    var vType = vType;

    var vUrl = vUrl;

    if(vType=='youtube')
    {
        $('#video').append('<object width="520" height="300"><param name="wmode" value="transparent"></param><param name="movie" value="'+ vUrl +'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+ vUrl +'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="520" height="300"></embed></object>');

    } else {

        insertFlowPlayer(vUrl,screenshot);

    }

}


function insertFlowPlayer(url,screenshot){

    var vUrl = url;
	var ss = screenshot;

    flowplayerobj = $f("video", {src: 'videos/flowplayer-3.1.5.swf?0.14858235498773342', wmode: 'transparent'}, {
    
                  // change the default controlbar to tube
                  plugins: {
                             controls: {
                                          url: 'videos/flowplayer.controls-tube-3.1.5.swf',
                                          borderRadius: '0px',
                                          bufferGradient: 'none',
                                          sliderColor: '#c9c9c9',
                                          timeBgColor: '#d5d5d5',
                                          volumeSliderGradient: 'none',
                                          tooltipTextColor: '#000',
                                          buttonOverColor: '#BA1010',
                                          volumeSliderColor: '#aaaaaa',
                                          progressGradient: 'medium',
                                          progressColor: '#BA1010',
                                          bufferColor: '#c78f8e',
                                          backgroundColor: '#e1e1e1',
                                          timeColor: '#000',
                                          sliderGradient: 'none',
                                          buttonColor: '#000',
                                          durationColor: '#000',
                                          tooltipColor: '#d5d5d5',
                                          height: 25,
                                          opacity: 1.0
                                       }
                          },
                  playlist: [
                              {
                                  url: ss,  //screenshot url onload of the player
                                  scaling: 'orig'
                              },
                              {
                                  url: vUrl,
                                  autoPlay: false
                              }
                            ],
                  canvas:
                            {
                                  backgroundColor: '#ffffff'
                            }
       });

}
