﻿var map = null;
var geocoder = null;
function initialize() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.addControl(new GSmallMapControl());
        geocoder = new GClientGeocoder();
	$("#map_canvas").width('620px');
    }
}
function showAddress(address, strtitle) {
    $("#map_container").dialog("destroy");
    $("#map_container").dialog({ width: 650, height: 350, title: strtitle });
    $("#map_container").dialog("open");
    initialize();
    if (geocoder) {
        geocoder.getLatLng(
                      address,
                      function(point) {
                          if (!point) {
                              alert(address + " not found");
                          } else {
                              map.setCenter(point, 13);
                              var marker = new GMarker(point);
                              map.addOverlay(marker);
                              //marker.openInfoWindowHtml(address);
                          }
                      }
                    );
    }
}


function showBusMoreInfo(strInfoText, strtitle) {
    $("#business_moreinfo").dialog("destroy");
    $("#business_moreinfo").dialog({ width: 650, height: 350, title: strtitle } );
    $("#business_moreinfoinner").html(strInfoText);
    $("#business_moreinfo").dialog("open");
}

$(document).ready(function() {
    startSlider();
    //$(".prefoot-inner").corner("bottom");
    //$(".pageContent").corner("bottom");
    //$(".news").corner();
    //$(".video").corner();
    //$(".button").corner("7px");
    $('.news-accordion-object').accordion({ autoHeight: false });
    $(".video-text-accordion").accordion({ autoHeight: false });
    $(".generictab").tabs();
    $(".creatingacv-tabs").tabs();
    $("#community-tab-container").tabs();
    $("#feature-tabs").tabs();
    $("#feature-tabs").show();
    $(".feature-sub-tabs").tabs();
    $("#titletab").tabs();
    $("#friendtabs").tabs();
    $("#comptabs").tabs();
    $("#profiletab").tabs();
    $("#tabs").tabs();
    $("#mediatabs").tabs();
    $("#friendtabs").tabs();
    $("#friendmediatabs").tabs();
    $("#friendmediatabs-friends-tabs").tabs();
    $("#friendmediatabs-groups-tabs").tabs();
    $("#socialtabs").tabs();
    $("#feedtabs").tabs();
    $("#feedtabs-1-sectors").tabs();
    $("#feedtabs-2-sectors").tabs();
    $("#chattab").tabs();
    $("#user_toplefttabs").tabs();
    $("#user_toprighttabs").tabs();
    $("#user_middlelefttabs").tabs();
    $("#user_middlebottomtabs").tabs();
    $(".feature-tabs-content-accordion").accordion({ autoHeight: false, collapsible: true, active: false });
    $("#btnhome_a").click(function() { window.location = "/"; });
    $("#btnmusic_a").click(function() { window.location = "/music_and_film_design/c-8.html"; });
    $("#btncosplay_a").click(function() { window.location = "/cosplay_and_memorabilia/c-7.html"; });
    $("#btncomics_a").click(function() { window.location = "/comics/c-6.html"; });
    $("#btnconsole_a").click(function() { window.location = "/console_and_computer_games/c-5.html"; });
    $("#btnttw_a").click(function() { window.location = "/table_top_wargaming/c-30.html"; });
    $("#btnttr_a").click(function() { window.location = "/table_top_roleplaying/c-3.html"; });
    $("#btnlarp_a").click(function() { window.location = "/larp_re-enactment/c-1.html"; });
    $("#btnmmo_a").click(function() { window.location = "/mmo_games/c-4.html"; });
    $(".logo").click(function() { window.location = "/"; });
    $("#jobresults").jScrollPane({ showArrows: true, animateTo: true });
    $(".scroll-by").bind(
                    'click',
                    function() {
                        var pane = $(this).attr('title');
                        var jump = parseInt($(this).attr('rel'));
                        $("#" + pane)[0].scrollBy(jump);
                        return false;
                    }
                );
                
    $("#CommentButton").bind('click',
        function() {
            postLibComment();
            return false;
        }
    );
             
    $(".lightbox").lightbox({
        fitToScreen: true,
        imageClickClose: false
    });
    $("#create-session").click(function() {
        $("#createsession").block({
            message: '<h1 style="background:#fff;color:#000;">Just a moment...</h1>',
            css: {
                border: '3px solid #a00',
                backgroundColor: '#fff',
                padding: '3px'
            }
        });
        $.post("/user/chat.asp",
                        {
                            newchatsession: 'true'
                        }, function(xml) {
                            $("#createsession").unblock();
                            if ($("session_id", xml).text() != "0")
                                window.open("http://dotnet.alltern8.com/chat.aspx?U_ID=<%=loginUserID %>&CM_S_ID=" + $("session_id", xml).text());
                            else
                                alert("An error occured, please try again, alternatively contact Alltern8 Support.");
                        }
                    );
    });
    $(".star").live("click", function() {
        if ($(this).parents('form').find("input[name=RT_Rating]:checked").val() > 0) {
            var tArray = {};
            $(this).parents('form').find("input, textarea, select").each(function() {
                if ($(this).attr("name").length && $(this).val().length) {
                    if ($(this).attr("name") == "RT_Rating") {
                        tArray[$(this).attr("name")] = $(this).parents('form').find("input[name=RT_Rating]:checked").val();
                    } else {
                        tArray[$(this).attr("name")] = $(this).val();
                    }
                }
            });
            $.post("/xtaddrating.asp", 
		        tArray,
                function() {
                    //nothing
                }
            );
        }
    });

    $("#complaintbutton").click(function() {
        $("#ratingdialog").dialog({
            height: 300,
            width: 430
        });
    });
    $("#invitefield").click(function() {
        if ($("#invitefield").val() == 'Enter Email Here') { $("#invitefield").val('') }
    });
    $("#step1button").click(function() {
        $("#firsthalf").hide();
        $("#secondhalf").show();
    });
    $("#step1back").click(function() {
        $("#secondhalf").hide();
        $("#firsthalf").show();
    });

});

function showVideo() {
    var so1 = new SWFObject("http://www.alltern8.com/videoplayer/videoplayer.swf", "flvplayer", "370", "305", "7", null, true);
    so1.addParam("allowSciptAccess", "always");
    so1.addParam("wmode", "transparent");
    so1.addVariable("autoplay", "false");
    so1.addVariable("themes", "http://www.alltern8.com/elite_player/themes.xml");
    so1.addVariable("config", "http://www.alltern8.com/elite_player/skin/config.xml");
    so1.addVariable("flv", "http://www.alltern8.com/videoplayer/video.flv");
    so1.write("video-content-swf");
}

function showContent() {
 $('.content').show();
}

function showAreaVideo(intAreaID) {
    var tmp = "http://www.alltern8.com";
    if (intAreaID != 10) {
        var so1 = new SWFObject(tmp + "/elite_player/flvplayer_elite.swf", "flvplayer", "389", "305", "7", null, true);
    } else {
        var so1 = new SWFObject(tmp + "/elite_player/flvplayer_elite.swf", "flvplayer", "475", "340", "7", null, true);
        intAreaID = '';
    }
    so1.addParam("allowSciptAccess", "always");
    so1.addParam("wmode", "transparent");
    so1.addVariable("autoplay", "false");
    so1.addVariable("themes", tmp + "/elite_player/themes.xml");
    so1.addVariable("config", tmp + "/elite_player/skin/config" + intAreaID + ".xml");
    so1.addVariable("flv", tmp + "/elite_player/video.flv");
    so1.write("video-content-swf");
}

function openWin(fileName, windowName) {
    window.open(fileName, windowName, 'width=350,height=350,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}
function openwintb(fileName, width, height) {
    window.open(fileName, 'externalsite', 'width='+width+',height='+height+',directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');
}

function MM_openBrWindow(fileName, windowName,attrs) {
    window.open(fileName, windowName, attrs);
}

function openAd(object) {
    var url = object.attr('href');
    var newWindow = window.open(url, '_blank');
    newWindow.focus();
    return false;
}
function eventBlockBox(obj) {
    var sUrl = $(obj).attr('rel');
    var sTitle = $(obj).attr('title');
    $.ajax({
        type: "GET",
        url: sUrl,
        success: function(msg) {
        $.blockUI({
                message: '<div class="areaBackground">'+sTitle+'</div><div>' + msg + '</div>',
                css: { width: '800px', height: '400px', padding: '10px', top: '20%', left: '17%', cursor: 'default' }
            });
            $('.blockOverlay').attr('title', 'Click to close window').click($.unblockUI);
        }
    });
}

function jumpDLPage(pageNum) {
    $.ajax({
        type: "POST",
        url: "/idream/albumcontents.asp",
        data: ({
            albumTitle: $("#_albumTitle").html(),
            albumID: $("#_albumID").html(),
            jumpPage: pageNum,
            keywords: $("#_keywords").html()
        }),
        success: function(msg) {
            $(".dlbot").html(msg);
        }
    });
    return false;
}


function postLibComment() {
    $.ajax({
        type: "POST",
        url: "/library/xtaddlibcomment.asp",
        data: ({
            CommentName: $("#CommentName").val(),
            CommentEmail: $("#CommentEmail").val(),
            CommentText: $("#CommentText").val(),
            LIBID: $("#LIBID").val()
        }),
        success: function(msg) {
            $("#commentdisplay").html(msg);
            $("#CommentForm").html("<p>Your comment has been added, we moderate all comments and it will show shortly</p>");
        }
    });
    return false;
}


