
var flashParameters = {
    classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
    quality: 'high',
    wmode: 'transparent',
    allowScriptAccess: 'always',
    TYPE: 'application/x-shockwave-flash ',
    ALIGN: '',
    PLUGINSPAGE: 'http://www.adobe.com/go/getflashplayer',
    codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,2,0'
};
//var J = jQuery.noConflict();
var J = jQuery;
var LiveOnPage = {};
LiveOnPage.init = function (domId, location) {
    this.obj = J("#" + domId);
    this.location = location;
	
	


	
}






LiveOnPage.setLocation = function (x, y) {

    var viewH = J(window).height();
    var scrollH = J(window).scrollTop();
    var viewW = J(window).width();
    var scrollW = J(window).scrollLeft();

    var t = 0;
    var l = 0;
    var isCustom = true;
 /*   switch (this.location) {

    case "topleft":
        t = scrollH;
        l = scrollW;
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;
    case "topcenter":
        t = scrollH;
        l = scrollW + (viewW / 2) - (this.obj.width() / 2);
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;
    case "topright":
        t = scrollH;
        l = viewW + scrollW - this.obj.width();
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;

    case "centerleft":
        t = scrollH + (viewH / 2) - (this.obj.height() / 2);
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        l = scrollW;
        break;
    case "centerpage":
        t = scrollH + (viewH / 2) - (this.obj.height() / 2);
        l = scrollW + (viewW / 2) - (this.obj.width() / 2);
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;
    case "centerright":
        t = scrollH + (viewH / 2) - (this.obj.height() / 2);
        l = viewW + scrollW - this.obj.width();
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;

    case "bottomleft":
        t = viewH + scrollH - this.obj.height();
        l = scrollW;
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;
    case "bottomright":
        t = viewH + scrollH - this.obj.height();
        l = viewW + scrollW - this.obj.width();
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;
    case "bottomcenter":
        t = viewH + scrollH - this.obj.height();
        l = scrollW + (viewW / 2) - (this.obj.width() / 2);
        this.obj.css('top', t + "px").css('left', l + "px");
        isCustom = false;
        break;

    }

    if (isCustom) {

        this.obj.css('top', y + "px").css('left', x + "px");
    }
*/



};

LiveOnPage.Unload = function () {
    if (LiveOnPage.Clips[LiveOnPage.ReloadClipIndex].showPlayAgain) {
     //   this.obj.html('<A href="#" onclick="LiveOnPage.ReloadLastClip();return false;"><img src="http://motiliti.net/content/images/playagain.jpg" /></A>');
        LiveOnPage.setLocation(0, 0);
    }
    else {
          this.obj.html('');
    //    var xx = this.obj.attr('id');
    //    alert(xx);

    }
};

LiveOnPage.exitLOPPanel = function (id) {
    setTimeout('LiveOnPage.Unload()', 5); 
	$("#LOPContainer").next('.content').show();
	var move=0;
	if($("#LOPContainer").hasClass('homevideo')) { move=1;}
	$("#LOPContainer").remove();
	$('.content').show();
	if(move==1) {api.seekTo(1,0); }

};

LiveOnPage.OpenWindow = function (url) {
    //window.open(url, 'liveOnPage', '');
	    window.open(url + LiveOnPage.GetQueryString(url), 'liveOnPage', '');

};

LiveOnPage.RedirectQueue = function (url) {
    setTimeout('LiveOnPage.OpenWindow("' + url + '")', 5);
};

LiveOnPage.RedirectQueueNoPop = function (url) {
    setTimeout('LiveOnPage.Redirect("' + url + '")', 5);
};

LiveOnPage.Redirect = function (url) {
  //  window.location = url;
      window.location = url + LiveOnPage.GetQueryString(url);
};

LiveOnPage.GetQueryString = function (url) {
    if (url.indexOf('?') == -1) {
        return '?' + extraParams;
    }
    return '&' + extraParams;

}

LiveOnPage.LoadClip = function (pageName) {
    var selectedClip = -1;
//alert('a');
    for (var i = 0; i < LiveOnPage.Clips.length; i++) {
	//	alert(LiveOnPage.Clips.length);
        if (LiveOnPage.Clips[i].pageName.toString().toLowerCase() == pageName.toString().toLowerCase()) {
         //  alert('a');
		   selectedClip = i;
            break;
        }
    }

    if (selectedClip != -1) {
        LiveOnPage.ReloadClipIndex = selectedClip;
        setTimeout(LiveOnPage.Runner, LiveOnPage.Clips[selectedClip].delaySeconds * 1000);
    }



};

LiveOnPage.Runner = function () {
    LiveOnPage.LoadClipByIndex(LiveOnPage.ReloadClipIndex);
}


LiveOnPage.ReloadLastClip = function () {

    J("#LOPContainer").html('');
    LiveOnPage.LoadClipByIndex(LiveOnPage.ReloadClipIndex);
};


LiveOnPage.LoadClipByIndex = function (selectedClip) {


    LiveOnPage.ReloadClipIndex = selectedClip;
    LiveOnPage.SetClip(LiveOnPage.Clips[selectedClip]);
    LiveOnPage.init("LOPContainer", LiveOnPage.Clips[selectedClip].location);
    LiveOnPage.setLocation(LiveOnPage.Clips[selectedClip].x, LiveOnPage.Clips[selectedClip].y);


    if (LiveOnPage.Clips[selectedClip].isScrolling) {

        J(window).scroll(function () {
            LiveOnPage.setLocation(0, 0);
        });
        J(window).resize(function () {
            LiveOnPage.setLocation(0, 0);
        });
    }
    else {
       // J(window).unbind("scroll");
       // J(window).unbind("resize");
    }
	

	
    LiveOnPage.setLocation(LiveOnPage.Clips[selectedClip].x, LiveOnPage.Clips[selectedClip].y);
};


//LiveOnPage.SetClip = function(width, height, presenterUrl, videoName, pageName, playerMode, removalOption, followUrl, clickUrl, logoUrl, clickImage, baseUrl, motilitiControls, showCloseButton)
LiveOnPage.SetClip = function (clip) {
    J("#LOPContainer").html('<OBJECT id="LOPPlayer"  ' + ' classid="' + flashParameters.classid + '" ' + ' codebase="' + flashParameters.codebase + '"' + ' WIDTH="' + clip.width + '"' + ' HEIGHT="' + clip.height + '"' + ' ALIGN="' + flashParameters.ALIGN + '">' + ' <PARAM NAME=movie VALUE="' + clip.presenterUrl + '">' + ' <PARAM NAME=quality VALUE=' + flashParameters.quality + '>' + ' <PARAM NAME=wmode VALUE=' + flashParameters.wmode + '>' + ' <PARAM NAME=allowScriptAccess VALUE=' + flashParameters.allowScriptAccess + '>' + ' <PARAM NAME=FlashVars VALUE="' + generateFlashVars(clip) + '">' + ' <EMBED ' + ' src="' + clip.presenterUrl + '"' + ' allowScriptAccess=' + flashParameters.allowScriptAccess + ' ' + ' quality="' + flashParameters.quality + '"' + ' WIDTH="' + clip.width + '"' + ' HEIGHT="' + clip.height + '"' + ' ALIGN="' + flashParameters.ALIGN + '"' + ' TYPE="' + flashParameters.TYPE + '"' + ' wmode="' + flashParameters.wmode + '"' + ' PLUGINSPAGE="' + flashParameters.PLUGINSPAGE + '"' + ' FLASHVARS="' + generateFlashVars(clip) + '">' + '</EMBED></OBJECT>');


};

function generateFlashVars(clip)
{

return 'motilitiControls=' + clip.motilitiControls
        + '&baseUrl=' + clip.baseUrl + '&clickImage=' + clip.clickImage + '&logoUrl=' + clip.logoUrl + '&link=' + clip.clickUrl
        + '&video=' + clip.videoName + '&id=' + clip.pageName + '&playerMode=' + clip.playerMode + '&removalOption=' + clip.removalOption
        + '&followURL=' + clip.followUrl + '&showCloseButton=' + clip.showCloseButton + "&openingPreview=" + clip.openingPreview
        + '&movieWidth=' + clip.width + '&movieHeight=' + clip.height + '&playAgainPreview=' + clip.playAgainPreview
        + '&logoImage=' + clip.logoImage + '&popUpLinks=' + clip.popUpLinks + '&progressive=' + clip.progressive + '&' + extraParams;
}

LiveOnPage.WipeQueue = function (time) {

    LiveOnPage.Wiper = setTimeout('LiveOnPage.Unload()', time * 1000);
};

LiveOnPage.CancelWipeQueue = function () {
    clearTimeout(LiveOnPage.Wiper);
};
//var extraParams='ci=7874&pi=home_monique';
var extraParams='ci=7874';
LiveOnPage.Clips = [
					
//home//--ok
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_monique_home2', pageName: 'greatdiscovery_home', playerMode: 'normal', removalOption: 'stay', followUrl: true, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false,progressive:false},

//overview//
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_mf_overview', pageName: 'greatdiscovery_overview', playerMode: 'normal', removalOption: 'stay', followUrl: true, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'http://motiliti.net/Logging.mvc/LogAndRedirectLogo?pageClipId=2404',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false,progressive:false},
//novel
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_scott_novel', pageName: 'greatdiscovery_novel', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//solutions
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_scott_solutions', pageName: 'greatdiscovery_solutions', playerMode: 'normal', removalOption: 'stay', followUrl: true, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'http://motiliti.net/Logging.mvc/LogAndRedirectLogo?pageClipId=2406',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false,progressive:false},
//events
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_mf_events', pageName: 'greatdiscovery_events', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'http://hwcdn.net/e5w3s6i4/fms/greatdiscovery/greatdiscovery_mf_events.flv.smil',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//media
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_mf_media', pageName: 'greatdiscovery_media', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'http://hwcdn.net/e5w3s6i4/fms/greatdiscovery/greatdiscovery_mf_media.flv.smil',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//kudos
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_mf_kudos', pageName: 'greatdiscovery_kudos', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'http://hwcdn.net/e5w3s6i4/fms/greatdiscovery/greatdiscovery_mf_kudos.flv.smil',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//faq
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_scott_faq', pageName: 'greatdiscovery_faq1', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'http://hwcdn.net/e5w3s6i4/fms/greatdiscovery/greatdiscovery_scott_faq.flv.smil',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//creator
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_mf_creator', pageName: 'greatdiscovery_creator', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//team
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_scott_team', pageName: 'greatdiscovery_team', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false},
//opportunity
{width: '448', height: '336', presenterUrl: 'http://motiliti.net/content/players/FLashV2/Player.swf', videoName: 'greatdiscovery_scott0811_redo', pageName: 'greatdiscovery0711', playerMode: 'normal', removalOption: 'stay', followUrl: false, location: 'bottomright', playOnLoad: true,clickUrl:'',clipTagName:'',logoUrl:'',clickImage:'',showPlayAgain:false,showCloseButton:false,motilitiControls:false,delaySeconds:0,x:0,y:0,isScrolling:false,baseUrl:'',logoImage:'',playAgainPreview:false,openingPreview:false,popUpLinks:false}

];

$(document).ready(function () {

    $('#c0').append('<div id="LOPContainer" class="homevideo"></div>');
    	LiveOnPage.LoadClip('greatdiscovery_home');		
}

);

