/**
Copyrights Chris Tanaskoski 2008
All rights reserved.
Licensed to: Creativenine
Project: Vorolo
*/
var BaseURL = "http://www.vorolo.com/";
var MessageBox = Class.create();
var CurIndex = 500;
//defining the rest of the class implementation
MessageBox.prototype = {
initialize: function(strTitle, strMessage, className, arrActions, bDisableEffects) {
var msgBoxCont = document.createElement('div');
msgBoxCont.className = className;
msgBoxCont.style.zIndex = CurIndex;
CurIndex = CurIndex + 1;
var title = document.createElement('h3');
var closeBtn = document.createElement('span');
var closeBtnA = document.createElement('a');
var closeBtnX = document.createTextNode('x');
title.style.zIndex=2;
closeBtnA.href="#";
closeBtnA.onclick = function(){
Element.extend(msgBoxCont);
msgBoxCont.remove();
return false;
}
msgBoxCont.onmousedown= function() {
CurIndex = CurIndex + 1
msgBoxCont.style.zIndex = CurIndex;
}
title.onmousedown = msgBoxCont.onmousedown;
closeBtnA.appendChild(closeBtnX);
closeBtn.appendChild(closeBtnA);
title.appendChild(closeBtn);
if(arrActions.length>0) {
rootList = document.createElement('ul');
rootList.className = "actionDropDownMenu";
menuOpener = document.createElement('li');
rootList.appendChild(menuOpener);
menuOpener.appendChild(document.createTextNode('>'));
actionList = document.createElement('ul');
Element.extend(rootList);
menuOpener.onmouseover = function(){if(actionList.style.display!="block") actionList.style.display="block";}
menuOpener.onmouseout = function(){actionList.style.display="none";}
menuOpener.appendChild(actionList);
for(i=0; i< arrActions.length; i++) {
actionItem = document.createElement('li');
actionLink = document.createElement('a');
if(arrActions[i].hasOwnProperty('href')) actionLink.href = arrActions[i].href;
else actionLink.href = "#";
if(arrActions[i].hasOwnProperty('strOnClick')) actionLink.onclick = new Function(arrActions[i].strOnClick);
actionLink.appendChild(document.createTextNode(arrActions[i].caption));
actionItem.appendChild(actionLink);
actionList.appendChild(actionItem);
}
rootList.appendChild(menuOpener);
title.appendChild(rootList);
}
title.appendChild(document.createTextNode(strTitle));
title.className="handle";
var cont = document.createElement('div');
cont.className = "cont";
msgBoxCont.appendChild(title);
Element.extend(cont);
cont.update('
'+strMessage+'
');
msgBoxCont.appendChild(cont);
var footer = document.createElement('div');
footer.appendChild(document.createTextNode("\u00a0"));
footer.className = "footer";
msgBoxCont.appendChild(footer);
document.body.appendChild(msgBoxCont);
// retrieve required dimensions
var offsets = document.viewport.getScrollOffsets();
// calculate the center of the page using the browser and element dimensions
var top = (offsets.top + 100) + "px";
msgBoxCont.style.top = top;
msgBoxCont.style.marginTop = 0;
/*if(!bDisableEffects) new Draggable(msgBoxCont,{handle: title});
else */new Draggable(msgBoxCont,{handle: title, starteffect: function(){}, endeffect:function(){}});
}
};
ajaxMessageBox = function(url, params) {
$('ajaxLoader').style.display = "block";
var myAjax = new Ajax.Request(
url,
{
method: 'POST',
parameters: params,
onComplete: function(originalRequest) {
var data = eval("("+originalRequest.responseText+")");
if(data.hasOwnProperty('actions') == false) data.actions = [];
new MessageBox(data.title, data.message, data.className, data.actions, data.disableEffects);
$('ajaxLoader').hide();
},
onFailure: function() {
new MessageBox('An error occured','Could not contact the webserver.
Please check if your internet connection is online.','msgBox', false);
$('ajaxLoader').hide();
}
}
);
return false;
}
function presentVideo(videoId) {
var params = 'showVid=' + videoId;
var url = BaseURL+'ytsearch.php';
ajaxMessageBox(url,params);
return false;
}
function addVideoToProfile(videoId) {
var params = "action=add&ajax=1&vid=" + videoId;
var url = BaseURL+'ytmanage.php';
ajaxMessageBox(url,params);
return false;
}
function removeVideoFromProfile(videoId) {
var params = 'action=remove&ajax=1&vid=' + videoId;
var url = BaseURL+'ytmanage.php';
ajaxMessageBox(url,params);
return false;
}
function showMsgBody(mid) {
var params = 'action=show&ajax=1&id=' + mid;
var url = BaseURL+'messages.php';
ajaxMessageBox(url,params);
return false;
}
function msgReply(mid) {
var params = 'action=reply&ajax=1&id=' + mid;
var url = BaseURL+'messages.php';
ajaxMessageBox(url,params);
return false;
}
function msgCompose(sentTo) {
if (typeof sentTo == 'undefined' ) sentTo = 'default';
var params = 'ajax=1&action=compose&sn='+sentTo;
var url = BaseURL+'messages.php';
ajaxMessageBox(url,params);
return false;
}
function saveVideoOrder(listToSort)
{
var url = BaseURL+'devristo/reorder_videos.php';
var params = {data: Sortable.serialize(listToSort) }
ajaxMessageBox(url,params);
return false;
}
function saveFriendOrder(listToSort)
{
var url = BaseURL+'devristo/reorder_friends.php';
var params = {data: Sortable.serialize(listToSort) }
ajaxMessageBox(url,params);
return false;
}
function sentInvite(objForm) {
var url = BaseURL+'scripts/invite.php';
var params = objForm.serialize()+'&ajax=1';
//alert(params);
ajaxMessageBox(url,params);
Effect.toggle('inviteForm','blind');
$('aUseInvite').show(); return false;
return false;
}
function showAlbum(albumid) {
var params = 'action=show&ajax=1&albumid=' + albumid;
var url = BaseURL+'album.php';
ajaxMessageBox(url,params);
return false;
}
function showYTSearch(){
new MessageBox(
"YouTube® Search",
'Search for your favourite clip on
and add it instantly to your profile! ',
'msgBox',
false
);
return false;
}
function copyField(obj) {
obj.focus();
obj.select();
if(obj.createTextRange) {
r = obj.createTextRange();
if(confirm("Do you want to copy the following value to the clipboard?\n\t"+obj.value))
r.execCommand('copy');
}
}
function Bookmark(url, title) {
if (window.sidebar) { // firefox
window.sidebar.addPanel(title, url, "");
} else if(window.opera && window.print){ // opera
return true;
} else if(document.all){ // ie
window.external.AddFavorite(url, title);
}
return false;
}
/** Hover fix IE6 **/
if(navigator.userAgent && navigator.userAgent.indexOf("MSIE 6.0")){
Event.observe(window, 'load', function(){
$$('div.tooltipcont').each(function(el){
el.onmouseover = function(){ this.className += ' tooltipcont_hover'; }
el.onmouseout = function(){ this.removeClassName('tooltipcont_hover'); }
});
});
}
Event.observe(window, 'load',
function() {$('ajaxLoader').onclick = function() { $('ajaxLoader').style.display ="none"} }
)