/*------------------------

  Initial Variables
 
------------------------*/

var siteTitle       = "Honda Insight";
var clientPath      = "http://stage-creative.myspacecdn.com/Client/Honda/Insight/"
var liveProfileID   = "";

/*------------------------

  Required Functions
 
------------------------*/

    //needed for the contact links funtion to work properly
    function getDisplayFriendID() { return MySpace.ClientContext.DisplayFriendId; }
    
    
    //required for add this javascript
    addthis_offset_top      = 0;
    addthis_offset_top_low  = 0;
    addthis_offset_left     = 0;
    

/*------------------------

  PWC
 
------------------------*/

//Prototype Windows Class
var win = null;
var index = 6000;
function openDialog(id,w,h) {
    Dialog.alert($(id).innerHTML, {className: "alphacube",  width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
    index++;
}

function lastDialog(id) {
    Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:250, okLabel: "Close", ok: closeAllModalWindows})
}

function closeAllModalWindows() {
    Windows.closeAllModalWindows();
    return true;
}


function Enter()
{
        closeAllModalWindows();
		document.getElementById('b').style.display = 'block';
		document.getElementById('c').style.display = 'block';
		document.getElementById('header').style.display = 'block';
		document.getElementById('topnav').style.display = 'block';
}


/*------------------------

  PWC Functions
 
------------------------*/
var win = null;
var index = 6000;

function openDialog(id,w,h) {
    
    //initialize pwc
    Dialog.alert($(id).innerHTML, {width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
    index++;
}

function openIframe(id,w,h,urlPath) {
    
    //initialize pwc
    Dialog.alert($(id).innerHTML, {width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
    index++;
    
    //dynamically swap out src of iframe
    $("iframeContent").width = w;
    $("iframeContent").height = h;
    $("iframeContent").src = urlPath;
}

function openIframeLoggedIn(id,w,h,urlPath) {
    
    if (isLoggedIn < 0) {
         window.alert("You Must Be Logged In");
    }  else {        
        //initialize pwc
        Dialog.alert($(id).innerHTML, {width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
        index++;
        
        //dynamically swap out src of iframe
        $("iframeContent").width = w;
        $("iframeContent").height = h;
        $("iframeContent").src = urlPath;
    }
}

function openWallpaper(id,w,h, wallpaperFilename) {
    //initialize pwc
    Dialog.alert($(id).innerHTML, {width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
    index++;
    
    //displays the thumbnail of the wallpaper
     $("wallpaperHolder").innerHTML = '<img src="'+ clientPath +'images/pwc_' + wallpaperFilename + '.jpg" />';
     
     //insert wallpaper links
     $("wallpaperLinks").innerHTML = '<h3>Download '+ siteTitle +' Wallpaper</h3>' +
        '<a href="' + clientPath + 'images/downloads/' + wallpaperFilename + '_1024.jpg" target="_blank" name="&lid='+ wallpaperFilename +'_1024" id="'+ wallpaperFilename +'_1024" title="Download the 1024x768 ' + siteTitle + ' Wallpaper" target="_blank">1024x768</a> |' +
        '<a href="' + clientPath + 'images/downloads/' + wallpaperFilename + '_1280.jpg" target="_blank" name="&lid='+ wallpaperFilename +'_1280" id="'+ wallpaperFilename +'_1280" title="Download the 1280x1024 ' + siteTitle + ' Wallpaper" target="_blank">1280x1024</a>';
}

function openBadge(id,w,h,badgeFilename) {
    //initialize pwc
    Dialog.alert($(id).innerHTML, {width:w, height:h, okLabel: "Close", ok:closeAllModalWindows, id: "d" + index})
    index++;
    
    //displays the badge image
    $("badgeHolder").innerHTML = '<img src="' + clientPath + 'downloads/Badges/thumbnails/' + badgeFilename + '.jpg" />' + 
                                      '<br /><br /><center><a href="' + clientPath + 'downloads/Badges/full/' + badgeFilename + '.jpg" target="_blank">view full image</a></center>';
    
    //insert embed code for users badge
    $("badgeCode").innerHTML = '<form name="badge"><textarea name="badgeCode" id="badgeCode" cols="40" rows="7" onClick="this.select();"><a href="http://www.myspace.com/' + liveProfileID + '" name="&lid=badge'+ badgeFilename +'" id="badge'+ badgeFilename +'" target="_blank"><img border="0" src="' + clientPath + 'downloads/Badges/full/' + badgeFilename + '.jpg" alt="' + siteTitle + ' -  Profile Badge"></a></textarea></form>'
}




function lastDialog(id) {
    Dialog.confirm($(id).innerHTML, { width:250, okLabel: "Close", ok: closeAllModalWindows})
}

function closeAllModalWindows() {
    Windows.closeAllModalWindows();
    return true;
}


function Enter() {
        closeAllModalWindows();
		document.getElementById('b').style.display = 'block';
		document.getElementById('c').style.display = 'block';
		document.getElementById('header').style.display = 'block';
		document.getElementById('topnav').style.display = 'block';
}

/*-------------------------
 Commercial Videos
--------------------------*/

function loadVideo(videoId, videoname, songname, songartist, autoplay) {
    
    // change the video source   
    var videoPlayerContainer = document.getElementById('player');
    videoPlayerContainer.innerHTML = '<embed  allowScriptAccess="always" src="http://mediaservices.myspace.com/services/media/embed.aspx/m=' + videoId + ',t=1,mt=video,ap=' + autoplay + ',sr=0" width="326" height="261" allowscriptaccess="always" allowfullscreen="true"></embed>';

    document.getElementById('videoname').innerHTML = videoname;
    document.getElementById('songname').innerHTML = songname;
    document.getElementById('songartist').innerHTML = songartist;
}

//load initial video
loadVideo(55967062, 'Beach', 'THE HONEY TREE', 'Mostar Diving Club', 0);
