﻿var CurrentName = "";
var CurrentID = 0;
function embedMain() {
    swfobject.embedSWF("http://media.mtvnservices.com/mgid:uma:video:cmt.com:593383", "mainVideo", "384", "288", "9.0.0", "swf/expressInstall.swf", { "configParams":"sid%3DCMT_Videos%26autoPlay=false" }, { allowfullscreen: "true" });
}
function hideMain() {
    swfobject.removeSWF("mainVideo");
    _gaq.push(['_trackPageview', '/videos/' + CurrentName]);
}
function showMain() {
    $("#videoPlayer").html("<div id='mainVideo'></div>");
    embedMain();
}
$(document).ready(function () {
    embedMain();
    $(".videoLink").fancybox({
        titleShow: false,
        padding: 0,
        onStart: hideMain,
        onClosed: showMain
    });

    $(".videoLink").mouseenter(function () {
        var id = $(this).attr('id').replace("video", "");
        var name = $("#vTitle" + id).val();
        var city = $("#vSubTitle" + id).val();
        var url = $("#vFLV" + id).val();
        var vidId = $("#vVideo" + id).val();
        var voteSub = $("iframe#vote_sub").attr("basesrc");
        CurrentID = id;
        CurrentName = name;
        $("#fTitle").html(name);
        $("#fCity").html(city);
        $("#fVideo").html(vidId);
        $("iframe#vote_sub").attr("src", voteSub + "?voteId=" + vidId);
        //$("input#videoinput").attr("value",vidId);
        //swfobject.embedSWF("swf/burlesque_player.swf", "videosPlayer", "384", "288", "9.0.0", "swf/expressInstall.swf", { "vidURL": url }, { allowfullscreen: "true", wmode: "transparent" });
        swfobject.embedSWF("http://media.mtvnservices.com/mgid:uma:video:cmt.com:"+vidId, "videosPlayer", "444", "272", "9.0.0", "swf/expressInstall.swf", { "configParams":"sid%3DCMT_Videos%26autoPlay=true" }, { allowfullscreen: "true", wmode: "transparent", swliveconnect: "true", allowscriptaccess: "always" });
    });

//    $("form#formcountrystrongvideochoice").submit(function(event){
//        event.preventDefault();
//        var $this = $(this);
//        var url = $this.attr('action');
//        var dataToSend = $this.serialize();
//        var callback = function(dataReceived, textStatus){
//            $this.hide();
//            $("p#voteResult").append(dataReceived);
//        };
//            
//        var typeOfDataToReceive = 'html';
//        $.get( url, dataToSend, callback, typeOfDataToReceive )
//    });

});

//function vote_Callback(val) {
//    var res = "";
//    switch (parseInt(val)) {
//        case 1: res = "Thank You. Come back tomorrow to vote again."; break;
//        default: res = "Sorry, you've already voted today!";
//
//    }
//
//    if ($('#videosModal').is(':visible')) {
//        $("#voteButton").hide();
//        $("#voteResult").html(res);
//        $("#voteResult").show();
//    } else {
//        alert(res);
//    }
//    
//}

