﻿/*
	Title: MAIN EVENT Common Scripts [Version 1]
	Author: James Hartcher
	Created: 1/1/2011
	
	Copyright © 2011 Internet Design Studios Pty Ltd, All Rights Reserved
	www.idstudios.com.au
*/


// Automatic sniffing of appropriate domain.
var ajaxPrefix = (document.domain == "internal.idstudios.net") ? 'http://internal.idstudios.net/mainevent.com.au/' : "http://" + document.domain + "/";


//-----------------------------------------------------------------------
// Document Ready
//-----------------------------------------------------------------------
$(document).ready(function () {

    // Advertisements
    $('.Advertisement').each(function (i) {

        // Get Settings
        var ord = new Date().getTime();
        var settings = $(this).html().replace('<!--', '').replace('-->', '').replace(' ', '');

        // Leaderboard (Option)
        if (settings.indexOf('728x90') > 0) {
            $(this).html('<iframe src="http://ad.au.doubleclick.net/adi/mcn.mainevent.com.au/' + settings + ';ord=' + ord + '?" style="width:728px;height:90px;" frameborder="0" scrolling="no"></iframe>');

        // Med Rec (Option)
        } else if (settings.indexOf('300x250') > 0) {
            $(this).html('<iframe src="http://ad.au.doubleclick.net/adi/mcn.mainevent.com.au/' + settings + ';ord=' + ord + '?" style="width:300px;height:250px;" frameborder="0" scrolling="no"></iframe>');
        }
    });

});


//-----------------------------------------------------------------------
// Embed Flash Video Player
//-----------------------------------------------------------------------
/*function EmbedVideoPlayer(id, flv, img, auto, hide) {

    // Width/Height
    var width = $('#' + id).attr('width');
    var height = $('#' + id).attr('height');

    // Embed Flash
    var flashvars = {};
    flashvars.videoSRC = flv;
    flashvars.screenshotSRC = img;
    flashvars.autoStart = auto;
    if (hide == true) flashvars.showClose = true;
    var params = {};
    params.menu = "false";
    params.scale = "noscale";
    params.wmode = "transparent";
    var attributes = {};
    attributes.id = "FlashPlayer";

    swfobject.embedSWF(ajaxPrefix + "includes/flash/dynamic.player.v1.swf", id, width, height, "9.0.0", ajaxPrefix + "includes/flash/expressInstall2.swf", flashvars, params, attributes);

}*/

//-----------------------------------------------------------------------
// Home Page Videos
//-----------------------------------------------------------------------
//$(document).ready(function () {
//    // Home Page Only
//    if ($(".EventVideosContent").size() == 0) {
//        $(".Videos").find(".Item").children("a[rel!='']").click(EmbedVideo);
//        $(".Videos").find(".Item").children("a[rel!='']").fancybox({
//            'scrolling': 'no',
//            'titleShow': false,
//            'titlePosition': 'inside',
//            'transitionIn': 'elastic',
//            'transitionOut': 'elastic',
//            'easingIn': 'easeOutBack',
//            'easingOut': 'easeInBack',
//            'speedIn': 500,
//            'speedOut': 500,
//            'onComplete': ShowVideo,
//            'onClosed': HideVideo
//        });
//    }
//    
//});
var PlayerCounter = 0;
function EmbedVideo()
{
	var divID = "VideoPlayer" + PlayerCounter;
	$("#VideoPlayerInner").html('<div id="' + divID + '"></div>');
	
	var flashvars = {
        videoURL:ajaxPrefix + "content/videos/" + $(this).attr("rel"),
        thumbnailURL:"",
        colour:"#666666",
        autoPlay:"true"
    };
	var params = {
        menu:"false",
        wmode:"transparent",
        bgcolor:"#000000",
        allowfullscreen:"true"
    };
	var attributes = {
        id:"FlashVideoPlayer"
    };
	swfobject.embedSWF(ajaxPrefix + "includes/flash/mainevent.player.v1.swf", divID, "650", "360", "10.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
	
	PlayerCounter ++;
}
function ShowVideo()
{
	$("#VideoPlayerInner").show();
}
function HideVideo()
{
	$("#VideoPlayerInner").hide();
}
