function SetCountryCitySelect(SetActiveType)
{
  $('select').each(function() {
    if($(this).attr('name') == '_fs6') {
      if($(this).attr('listtype') == SetActiveType) {
        $(this).show();
        $(this).removeAttr("disabled");
      } else {
        $(this).hide();
        $(this).attr("disabled", "disabled");
      }
    }
  });
}

$(document).ready(function() { 
  SetYoutubeVideos();
     
  $(".youtube").click( function() { 
    $.fancybox({
        'padding'        : 0,
        'autoScale'      : false,
        'transitionIn'   : 'none',
        'transitionOut'  : 'none',
        'title'          : this.title,
        'width'          : 810,
        'height'         : 480,
        'centerOnScroll' : true,
        'hideOnOverlayClick' : false,
        'onStart'        : function() { $("body").css("overflow", "hidden"); },
        'onComplete'     : function() { $(document).scrollTop(0); },
        'onCleanup'      : function() { $("body").css("overflow", "auto"); },
        'href'           : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + "&autoplay=1",
        'type'           : 'swf',
        'overlayOpacity' : 1,
        'overlayColor'   : '#000',
        'swf'            : {
          'wmode'            : 'transparent',
          'allowfullscreen'  : 'true'
        }
      });

    return false;
  });
  
  $(".youtubenewslink").click(function() {
    var VideoId   = GetYoutubeVideoId($(this).attr("href"));
    $.fancybox({
        'padding'        : 0,
        'autoScale'      : false,
        'transitionIn'   : 'none',
        'transitionOut'  : 'none',
        'titleShow'      : false,    
        'width'          : 810,
        'height'         : 480,
        'centerOnScroll' : true,
        'hideOnOverlayClick' : false,
        'onStart'        : function() { $("body").css("overflow", "hidden"); },
        'onComplete'     : function() { $(document).scrollTop(0); },
        'onCleanup'      : function() { $("body").css("overflow", "auto"); },
        'href'          : "http://www.youtube.com/v/" + VideoId + "&autoplay=1",
        'type'          : 'swf',
        'overlayOpacity' : 1,
        'overlayColor'   : '#000',
        'swf'            : {
          'wmode'            : 'transparent',
          'allowfullscreen'  : 'true'
        }
      });

    return false;
  });
  
	if($('#content .img_top').length > 0) {
		$('#content .img_top').cycle({
			fx: 'fade'    
		});
	}

})

function SetYoutubeVideos() {
  
  if($(".youtubeblock").length > 0) {
    $(".youtubeblock .youtubenews").each( function() {
      var VideoId   = GetYoutubeVideoId($(this).attr("href"));
      $(this).parent().append("<img style=\"width: 173px;\" src=\"http://img.youtube.com/vi/"+ VideoId +"/0.jpg\" alt=\"youtube\" />"); 
    });
  }
                             
  $(".youtubenews").click(function() {
    var VideoId   = GetYoutubeVideoId($(this).attr("href"));
    $.fancybox({
        'padding'        : 0,
        'autoScale'      : false,
        'transitionIn'   : 'none',
        'transitionOut'  : 'none',
        'titleShow'      : false,
        'width'          : 810,
        'height'         : 480,
        'centerOnScroll' : true,
        'hideOnOverlayClick' : false,
        'onStart'        : function() { $("body").css("overflow", "hidden"); },
        'onComplete'     : function() { $(document).scrollTop(0); },
        'onCleanup'      : function() { $("body").css("overflow", "auto"); },
        'href'          : "http://www.youtube.com/v/" + VideoId + "&autoplay=1",
        'type'          : 'swf',
        'overlayOpacity' : 1,
        'overlayColor'   : '#000',
        'swf'            : {
          'wmode'            : 'transparent',
          'allowfullscreen'  : 'true'
        }
      });

    return false;
  });
  
  return ;
}

function GetYoutubeVideoId (URL) {
  if(URL === null){ 
    return ""; 
  }
  
  var VideoId;
  var Results;
  Results = URL.match("[\\?&]v=([^&#]*)");
  
  if(Results == null){
    Results = URL.split("/")  
    VideoId = ( Results === null ) ? URL : Results[3];  
  } else {
    VideoId = Results[1]
  }

  return VideoId;
}
