﻿
$().ready(function() {
    loadvoting();
});

var templ;
var votedata;

function loadvoting() {
    $.jmsajax({
        url: "/plingg_api/WS/VotingService.svc/GetVoting",
        data: { VotingID: VotingID },
        success: function (data) {
            if (data) {
                votedata = data;

                var templurl;
                if (votedata.ResultDisplay < 100) {
                    if (votedata.ProcessTyp < 100) {
                        templurl = "/plingg_api/Templ/VotingDisplay_Simple.htm";
                        templ = jQuery.createTemplateURL(templurl, null, { filter_data: false, runnable_functions: true });
                        templ.setParam("Texte", tobj);
                        bindsimplevoting();
                    } else {
                        if (votedata.Status == 3) {
                            templurl = "/plingg_api/Templ/VotingDisplay_ContestOnly.htm";
                            templ = jQuery.createTemplateURL(templurl, null, { filter_data: false, runnable_functions: true });
                            templ.setParam("Texte", tobj);
                            bindrankingvoting();
                        } else {
                            if (votedata.ResultDisplay < 10) {
                                templurl = "/plingg_api/Templ/VotingDisplay_RankingList.htm";
                                templ = jQuery.createTemplateURL(templurl, null, { filter_data: false, runnable_functions: true });
                                templ.setParam("Texte", tobj);
                                bindrankingvoting();
                            } else {
                                templurl = "/plingg_api/Templ/VotingDisplay_Ranking.htm";
                                templ = jQuery.createTemplateURL(templurl, null, { filter_data: false, runnable_functions: true });
                                templ.setParam("Texte", tobj);
                                bindrankingvoting();
                            }
                        }
                    }
                } else {
                    templurl = "/plingg_api/Templ/VotingSpecial_" + VotingID + ".htm?d=" + new Date().getTime(); //
                    templ = jQuery.createTemplateURL(templurl, null, { filter_data: false, runnable_functions: true });
                    templ.setParam("Texte", tobj);
                    bindrankingvoting();
                }



            } else {
                alert("NO VOTING WITH THIS ID WAS FOUND");
            }
        }
    });
}

var nextrankingitem = 1;

function renumberListItems() {
    i = 1;
    var hiddennr = 0;
    $("#rankingitems li").each( function() {
        $(".rankingtarget", this).attr("rel",i);
        $(".rankingnr", this).text(i + ".");
        
        var pointline = votedata.PointsPerUser - (i-1) + " " + tobj.Points;
        $(".rankingsubcontainer",this).html("<b>" + pointline + "</b>");
                    
        if ($(":visible",this).length==0) {
            hiddennr=i;
        } else {
            
        }
        i++;
        
    });
    return hiddennr;
}

function revalidateItems() {
    i = 1;
    var hiddennr = 0;
    
    var setitems = [];
    var sethtml = [];
    var setid=0;
    
    $("#rankingitems li").each( function() {
                
        if (isItemEmpty(this) == false) {
            setitems.push($(".innercontainer",this).attr("selitem"));
            sethtml.push($(".innercontainer",this).html());
        }
        
        i++;
    });
    
    
    if (setitems.length>0 && setitems.length<$("#rankingitems li").length) {
        
        var y;
        for (y=0;y<setitems.length;y++) {
            //alert(y + " : " + setitems[y]);
            
            var incont = $("#rankingitems li:eq(" + y + ") .rankingtarget .innercontainer");
            if (incont.length>0) {
                incont.attr("selitem",setitems[y]);
                incont.html(sethtml[y]);
                
                $("#remvotelink_" + setitems[y],incont).click(function() {
                    var itemRIDValSplitter 	= (this.id).split("_");
                    var itemRIDVal 			= itemRIDValSplitter[1];
                    removerankingitem(itemRIDVal);
                });
                
            }
        }
        
        for (y=setitems.length;y<$("#rankingitems li").length;y++) {
            var incont = $("#rankingitems li:eq(" + y + ") .rankingtarget .innercontainer");
            if (incont.length>0) {
                incont.attr("selitem","0");
                incont.html(tobj.SelectItem);
            }
            
        }
        
    } else {
        
    }
    
    return 1;
}

function gotoregister() {
    document.location.href = document.location.href + "&com=reg";
}

function isItemEmpty(selel) {
    if ($(".innercontainer",selel).attr("selitem")) {
        if ($(".innercontainer",selel).attr("selitem")!="0") {
            return false;
        } else {
            return true;
        }    
    } else {
        return true;
    }   
}


function bindrankingvoting() {
    var ht = jQuery.processTemplateToText(templ,votedata);
    $("#DisplayDiv").html(ht);
    inittooltip();

   
    if (votedata.UserVoteStatus==10 && querySt("com")!="res") {
        $("#rankingitems").sortable({
                placeholder: 'ui-state-highlight',
                distance: 10,
                axis: "y",
                change: function(event,ui) {
                    var hnr = renumberListItems();
                    $(".rankingnr",ui.helper).text(hnr + ".");
                    var pointline = votedata.PointsPerUser - (hnr-2) + " " + tobj.Points;
                    $(".rankingsubcontainer",ui.helper).html("<b>" + pointline + "</b>");
                    
                },
                start: function(event,ui) {
                    //$(this).sortable("cancel");
                },
                stop: function(event,ui) {
                    revalidateItems();
                    renumberListItems();
                }
            });
        $("#rankingitems").disableSelection();
        
       
        
        $("#DisplayDiv .rankingcontainer a.addvotelink").click(function() {
                var itemIDValSplitter 	= (this.id).split("_");
                var itemIDVal 			= itemIDValSplitter[1];
                if (addrankingitem(itemIDVal)) {
                    $(this).hide();
                }   
                return false;
        });
        
        $("#DisplayDiv .rankingcontainer").click(function() {
                var itemIDValSplitter 	= (this.id).split("_");
                var itemIDVal 			= itemIDValSplitter[1];
                if (addrankingitem(itemIDVal)) {
                    $("a.addvotelink",this).hide();
                }   
            	      
        });
        
        $("#vote-container").fadeIn("slow");
    } else {

        if (querySt("com") == "res") {
            votedata.Options.sort(votesort);
        }
        
        if (votedata.ID == 13) {
            processFM4Voting(votedata);
        }
        
        if (votedata.ID == 14) {
            processEutopiaVoting(votedata);
        }
        
        if (votedata.ID == 15) {
            processEGAVoting(votedata);
        }

            for (i = 0; i < votedata.Options.length; i++) {
                if (votedata.Options[i] != null) {

                    var rescont = $("#rescontainer_" + (i + 1));

                    $("#emptyrescontainer").clone().attr("id", "rescont_" + (i + 1)).appendTo(rescont);

                    rescont.hide();

                    $(".emptyresult", rescont).show();

                    $(".innercontainer", rescont)
                    .html($("#RankingItem_" + votedata.Options[i].ID).html());


                    if (votedata.Options[i].SNR != undefined) {
                        $(".rankingnr", rescont).text(votedata.Options[i].SNR);
                    } else {
                        $(".rankingnr", rescont).text(i + 1);
                    }
                    $(".innercontainer .addvotelink", rescont).hide();

                    $("div.graph div.bardiv", rescont).attr("rel", votedata.Options[i].Percentage);
                } else {
                    $("#rescontainer_" + (i + 1)).hide();
                }
            }    
            
            $("#emptyrescontainer").remove();

            $("#result-container").fadeIn("fast", function () {
                var currid = votedata.Options.length;

                if (currid > 10) {
                    currid = 10;
                    for (var x = votedata.Options.length; x > 10; x--) {
                        if (votedata.Options[x] != null) {
                            $("#rescontainer_" + x).show();
                        }
                    }
                }


                $("#rescontainer_" + currid).slideDown(1000, function () {
                    currid--;
                        if ($("#rescontainer_" + currid).length > 0) {
                            $("#rescontainer_" + currid).slideDown("fast", arguments.callee);
                        } else {
                            animateResults();
                        }
                });

            });     

		$(".rescontainer").show();      
        
    }
    
    if (votedata.BandRegistration==true) {
        $("#registerbandbutton").show();
    }

    //$("a.fboxlink").fancybox({
    //    'hideOnContentClick': false
    //});
	$("a.ytlink").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
    
    initjplayer();
}

function addrankingitem(itemIDVal) {
            
    var itemX 		= $("#RankingItem_" + itemIDVal).offset().left;
    var itemY 		= $("#RankingItem_" + itemIDVal).offset().top;
    
    if ($("#rankingitems li .rankingtarget .innercontainer[selitem='" + itemIDVal + "']").length==0) {
        var nextrankingitem = getnextavailableitem();
        
        if (nextrankingitem>-1) {
            //alert("NEXT : " + nextrankingitem);
            
            var incont = $(".rankingtarget[rel='" + nextrankingitem + "'] .innercontainer");
            
            incont.attr("selitem",itemIDVal);
            
            var listX 		= incont.offset().left;
            var listY 		= incont.offset().top;

            var gotoX 			= listX - itemX;
            var gotoY 			= listY - itemY;
                   
            var newItemWidth = incont.width()+20;
            var newItemHeight = incont.height()+20;

            incont.hide("slow");

            $("#RankingItem_" + itemIDVal + " .addvotelink").hide();
            $("#RankingItem_" + itemIDVal + " .rankingsubcontainer").hide();

            $("#RankingItem_" + itemIDVal)
            .clone()
            .prependTo("#RankingItem_" + itemIDVal)
            .css({'position' : 'absolute'})
            .width(newItemWidth)
            .animate({opacity: 0.8}, 100 )
            .animate({opacity: 0.8, marginLeft: gotoX, marginTop: gotoY, width:newItemWidth, height:newItemHeight}, 1200, function() {
                var pointline = votedata.PointsPerUser - (nextrankingitem-1) + " " + tobj.Points;
                
                $(".rankingsubcontainer",this).html("<b>" + pointline + "</b>");
                $(".rankingsubcontainer",this).show();
    				
                incont.html($(this).html());
                
                $("<a href='#' id='remvotelink_" + itemIDVal + "' class='negative'>" + tobj.Remove + "</a>").appendTo($(".buttons",incont));
                //$("").appendTo($(".buttons",incont));
                
                $("#remvotelink_" + itemIDVal,incont).click(function() {
                    
                    var itemRIDValSplitter 	= (this.id).split("_");
                    var itemRIDVal 			= itemRIDValSplitter[1];
                    removerankingitem(itemRIDVal);
                });
                
                incont.show();
                    //
                $(this).remove();
                
                $("#RankingItem_" + itemIDVal + " .rankingsubcontainer").show();
                
            }); 
             
            return true;
        } else {
            alert(tobj.Maximum);
            return false;
        }
    } else {
        //ALREADY ADDED   
    }
}

function removerankingitem(itemIDVal) {
    $("#RankingItem_" + itemIDVal + " .addvotelink").show();
    var incont = $("#rankingitems li .rankingtarget .innercontainer[selitem='" + itemIDVal + "']");
    if (incont.length>0) {
        incont.attr("selitem","0");
        incont
        .animate({opacity: 0}, "slow", function() {
            $(this).html(tobj.SelectItem);
            $(this).animate({opacity: 1});
            revalidateItems();
            renumberListItems();
        });
    }        
    
}

function submitranking() {
    var vals = new Array();
    var i=0;
    $("#rankingitems li").each( function() {
        if ($(".rankingtarget .innercontainer",this).attr("selitem")) {
            if ($(".rankingtarget .innercontainer",this).attr("selitem")!="0") {
                vals[i]=$(".rankingtarget .innercontainer",this).attr("selitem");
                i++;
            }    
        }
    });
    if (vals.length > 0) {
        $("#vote-container").hide("slow");
        submvote(0,vals);
    } else {
        alert(tobj.NoneSelected);
    }
}

function getnextavailableitem() {
    var i=1;
    var selnr = -1;
    $("#rankingitems li").each( function() {
        //alert($(".rankingtarget .innercontainer",this).attr("selitem"));
        if (selnr==-1) {
            if ($(".rankingtarget .innercontainer",this).attr("selitem")) {
                //selnr = i;
                if ($(".rankingtarget .innercontainer",this).attr("selitem")=="0") {
                    selnr = i;
                }    
            } else {
                selnr = i;
            }
        }
        i++;
    });
    return selnr;
}


function bindsimplevoting() {
    var ht = jQuery.processTemplateToText(templ,votedata);
    $("#DisplayDiv").html(ht);
    inittooltip();

    if (votedata.UserVoteStatus==10) {
        
         
        $("input[name='poll']").change(function() {
            if ($("input[name='poll']:checked").val()) {
                //alert($(this).val());
            }
            $(this).blur();
        });
        
        $("a.fboxlink").fancybox({
            'hideOnContentClick': false
        });
    
        $("#DisplayDiv #votelink").click(function() {
            //alert("CLICKED SUBM BUTTON");
            if ($("input[name='poll']:checked").val()) {
                //alert("SUBMITTING : " + $("input[name='poll']:checked").val());
                
                var vspl = $("input[name='poll']:checked").val().split("_");
                submvote(vspl[0],[Number(vspl[1])]);    
            }
        });
        
        $("#vote-container").fadeIn("slow");
        
    } else {
        //NOT ABLE TO VOTE - DISPLAY RESULT
        $("#result-container").fadeIn("slow",function(){animateResults();});
    }
    
    
}

function submvote(vid,opts) {
    //alert("SUBMIT VOTE : " + vid + "/" + opts[0]);
    $.jmsajax({
        url: "/plingg_api/WS/VotingService.svc/SubmitVote",
        data: { VotingID: VotingID, OptionIDs: opts },
        success: function (data) {
            if (data.VoteStatus == 1) {
                //alert("SUBMITTED VOTE"); 
                votedata = data.SelVoting;
                votedata.UserVoteStatus = 11;
                if (votedata.ProcessTyp < 100) {
                    bindsimplevoting();
                } else {
                    bindrankingvoting();
                }

            } else {
                if (data.VoteStatus == -97) {
                    alert("Die Stimme wurde nicht gezählt da zu oft von dieser IP Adresse gevotet wurde, bitte warte etwas bis du es erneut versuchst. Manipulationen durch Mehrfachaccounts oder ähnliches können zur Disqualifikation einer Band führen.");
                    if (votedata.ProcessTyp < 100) {
                        bindsimplevoting();
                    } else {
                        bindrankingvoting();
                    }
                } else {
                    alert("ERROR WHILE SUBMITTING VOTE (" + data.VoteStatus + ")");
                }
            }
        }
    });
}

function animateResults() {
   $("#vote-results div.bardiv").each(function(){ 
      var percentage = $(this).attr("rel") + "%";  
      $(this).css({width: "0%"}).animate({width: percentage}, 1000,function() {
        $("strong",$(this).parent()).hide();
        $("strong",$(this).parent()).text(percentage);  
        $("strong",$(this).parent()).fadeIn("slow");
      });
  });  
}


function initjplayer() {
    if ($("a.mp3link").length > 0) {
    
        $("#jquery_jplayer").jPlayer({
            swfPath: "/js/",
            ready: function () {
                demoInstanceInfo($(this), $("#jplayer_info"));
            }
        })
    	.jPlayerId("play", "player_play")
    	.jPlayerId("pause", "player_pause")
    	.jPlayerId("stop", "player_stop")
    	.jPlayerId("loadBar", "player_progress_load_bar")
    	.jPlayerId("playBar", "player_progress_play_bar")
    	.jPlayerId("volumeMin", "player_volume_min")
    	.jPlayerId("volumeMax", "player_volume_max")
    	.jPlayerId("volumeBar", "player_volume_bar")
    	.jPlayerId("volumeBarValue", "player_volume_bar_value")
    	.onProgressChange(function (loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
    	    var myPlayedTime = new Date(playedTime);
    	    var ptMin = (myPlayedTime.getUTCMinutes() < 10) ? "0" + myPlayedTime.getUTCMinutes() : myPlayedTime.getUTCMinutes();
    	    var ptSec = (myPlayedTime.getUTCSeconds() < 10) ? "0" + myPlayedTime.getUTCSeconds() : myPlayedTime.getUTCSeconds();
    	    $("#play_time2").text(ptMin + ":" + ptSec);

    	    var myTotalTime = new Date(totalTime);
    	    var ttMin = (myTotalTime.getUTCMinutes() < 10) ? "0" + myTotalTime.getUTCMinutes() : myTotalTime.getUTCMinutes();
    	    var ttSec = (myTotalTime.getUTCSeconds() < 10) ? "0" + myTotalTime.getUTCSeconds() : myTotalTime.getUTCSeconds();
    	    $("#total_time2").text(ttMin + ":" + ttSec);
    	})
    	.onSoundComplete(function () {
    	    //$("#jquery_jplayer").playHead(0); // Crossover the players here
    	});

    	$("a.mp3link").click(
          function (objEvent) {
              // Cancel default event and propagation.
              return (false);
          }
        );
    } else {
          $("#player_container2").hide();
    }

    if ($("a.mp3link").length > 0 && $("#jquery_jplayer2").length > 0) {
    
        $("#jquery_jplayer2").jPlayer({
            swfPath: "/js/",
            ready: function () {
                demoInstanceInfo($(this), $("#jplayer_info2"));
            }
        })
    	.jPlayerId("play", "player_play2")
    	.jPlayerId("pause", "player_pause2")
    	.jPlayerId("stop", "player_stop2")
    	.jPlayerId("loadBar", "player_progress_load_bar2")
    	.jPlayerId("playBar", "player_progress_play_bar2")
    	.jPlayerId("volumeMin", "player_volume_min2")
    	.jPlayerId("volumeMax", "player_volume_max2")
    	.jPlayerId("volumeBar", "player_volume_bar2")
    	.jPlayerId("volumeBarValue", "player_volume_bar_value2")
    	.onProgressChange(function (loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
    	    var myPlayedTime = new Date(playedTime);
    	    var ptMin = (myPlayedTime.getUTCMinutes() < 10) ? "0" + myPlayedTime.getUTCMinutes() : myPlayedTime.getUTCMinutes();
    	    var ptSec = (myPlayedTime.getUTCSeconds() < 10) ? "0" + myPlayedTime.getUTCSeconds() : myPlayedTime.getUTCSeconds();
    	    $("#play_time2").text(ptMin + ":" + ptSec);

    	    var myTotalTime = new Date(totalTime);
    	    var ttMin = (myTotalTime.getUTCMinutes() < 10) ? "0" + myTotalTime.getUTCMinutes() : myTotalTime.getUTCMinutes();
    	    var ttSec = (myTotalTime.getUTCSeconds() < 10) ? "0" + myTotalTime.getUTCSeconds() : myTotalTime.getUTCSeconds();
    	    $("#total_time2").text(ttMin + ":" + ttSec);
    	})
    	.onSoundComplete(function () {
    	    //$("#jquery_jplayer2").playHead(0); // Crossover the players here
    	});

    	$("a.mp3link").click(
          function (objEvent) {
              // Cancel default event and propagation.
              return (false);
          }
        );
    } else {
          $("#player_container3").hide();
    }

}

function playtrack(ev, mp3name, mp3url) {
    if ( $("#vote-container").is(':visible') ) {

    $("#song_title").text(mp3name);
    $("#jquery_jplayer").setFile("http://plinggownfiles.s3.amazonaws.com" + mp3url).play();
} else {
	if ($("#jquery_jplayer2").length>0) {
    $("#song_title2").text(mp3name);
    $("#jquery_jplayer2").setFile("http://plinggownfiles.s3.amazonaws.com" + mp3url).play();
}
}
 
    ev.preventDefault();
    return false;
}

function cancelevent() {
    return false;
}

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function votesort(a, b) {
        // psudeo code.
    if (a.PointCount > b.PointCount) {
        return -1;
    }
    if (a.PointCount < b.PointCount) {
        return 1;
    }
    if (a.PointCount == b.PointCount) {
        return 0;
    }
}


function processFM4Voting(votedata) {
    
    var altslots = new Array();
    var hiphopslots = new Array();
    var othslots = new Array();

    var optlength = votedata.Options.length;

    for (i = 0; i < votedata.Options.length; i++) {
        if (votedata.Options[i] != null) {
            if (votedata.Options[i].RSubTitle == "1" && altslots.length < 6) {
                votedata.Options[i].SNR = altslots.length + 1; 
                altslots.push(votedata.Options[i]);
            } else if (votedata.Options[i].RSubTitle == "2" && hiphopslots.length < 3) {
                votedata.Options[i].SNR = hiphopslots.length + 1;
                hiphopslots.push(votedata.Options[i]);
            } else {
                votedata.Options[i].SNR = othslots.length + 10;
                othslots.push(votedata.Options[i]);
            }
        }
    }
    
    if (altslots.length < 7) {
        for (i = altslots.length+1; i < 7; i++) {
            altslots.push(null);
        }
    }

    if (hiphopslots.length < 4) {
        for (i = hiphopslots.length + 1; i < 4; i++) {
            hiphopslots.push(null);
        }
    }

    votedata.Options = new Array();
    votedata.Options = altslots.concat(hiphopslots.concat(othslots));

    //alert("FM4 Processing " + votedata.Options.length + " = " + altslots.length + "/" + hiphopslots.length + "/" + othslots.length);
}

function processEGAVoting(votedata) {
    
    var altslots = new Array();
    var hiphopslots = new Array();
    var othslots = new Array();

    var optlength = votedata.Options.length;

    for (i = 0; i < votedata.Options.length; i++) {
        if (votedata.Options[i] != null) {
            if (votedata.Options[i].RSubTitle == "1" && altslots.length < 6) {
                votedata.Options[i].SNR = altslots.length + 1; 
                altslots.push(votedata.Options[i]);
            } else if (votedata.Options[i].RSubTitle == "2" && hiphopslots.length < 6) {
                votedata.Options[i].SNR = hiphopslots.length + 1;
                hiphopslots.push(votedata.Options[i]);
            } else {
                votedata.Options[i].SNR = othslots.length + 13;
                othslots.push(votedata.Options[i]);
            }
        }
    }
    
    if (altslots.length < 7) {
        for (i = altslots.length+1; i < 7; i++) {
            altslots.push(null);
        }
    }

    if (hiphopslots.length < 7) {
        for (i = hiphopslots.length + 1; i < 7; i++) {
            hiphopslots.push(null);
        }
    }

    votedata.Options = new Array();
    votedata.Options = altslots.concat(hiphopslots.concat(othslots));

    //alert("FM4 Processing " + votedata.Options.length + " = " + altslots.length + "/" + hiphopslots.length + "/" + othslots.length);
}

function processEutopiaVoting(votedata) {
    
    var eleslots = new Array();
    var hiphopslots = new Array();
    var vjslots = new Array();
    var othslots = new Array();

    var optlength = votedata.Options.length;

    for (i = 0; i < votedata.Options.length; i++) {
        if (votedata.Options[i] != null) {
            if (votedata.Options[i].RSubTitle == "2" && eleslots.length < 2) {
                votedata.Options[i].SNR = eleslots.length + 1; 
                eleslots.push(votedata.Options[i]);
            } else if (votedata.Options[i].RSubTitle == "1" && hiphopslots.length < 1) {
                votedata.Options[i].SNR = hiphopslots.length + 1;
                hiphopslots.push(votedata.Options[i]);
            } else if (votedata.Options[i].RSubTitle == "3" && vjslots.length < 3) {
                votedata.Options[i].SNR = vjslots.length + 1;
                vjslots.push(votedata.Options[i]);
            } else {
                votedata.Options[i].SNR = othslots.length + 13;
                othslots.push(votedata.Options[i]);
            }
        }
    }
    
    if (eleslots.length < 3) {
        for (i = eleslots.length+1; i < 3; i++) {
            eleslots.push(null);
        }
    }

    if (hiphopslots.length < 2) {
        for (i = hiphopslots.length + 1; i < 2; i++) {
            hiphopslots.push(null);
        }
    }
    
    if (vjslots.length < 4) {
        for (i = vjslots.length + 1; i < 4; i++) {
            vjslots.push(null);
        }
    }

    votedata.Options = new Array();
    votedata.Options = hiphopslots.concat(eleslots.concat(vjslots.concat(othslots)));

    //alert("FM4 Processing " + votedata.Options.length + " = " + altslots.length + "/" + hiphopslots.length + "/" + othslots.length);
}