function buttonSwap(obj,imgsrc)
{obj.focus;obj.src=imgsrc;}
function toggleDisplay(id)
{var obj=document.getElementById(id);if(!obj)return;if(obj.style.display=='none')
obj.style.display='block';else
obj.style.display='none';}
var menus=new Array('menu_Members','menu_Events');var menu_Events=new Object();menu_Events['Upcoming_Events']='http://www.ticketbreak.com/vibeto';menu_Events['Event_Pictures']='/mag/event_pics';var menu_Members=new Object();menu_Members['New_Members']='/mag/mem-new-members';menu_Members['Online_Now']='/online';menu_Members['Birthdays']='/mag/mem-birthdays';menu_Members['Search']='/mag/members-search';var ddMenuTimeout;var ddMenuActive;function buildMenus(){for(var i=0;i<menus.length;i++)
{var obj=eval(menus[i]);var div=document.createElement('div');div.id=menus[i];div.className='ddMenu';div.onmouseover=function(){if(ddMenuTimeout)
window.clearTimeout(ddMenuTimeout);}
div.onmouseout=function(){ddMenuOut();}
for(var q in obj)
{var a=document.createElement('a');var text=q.toString();text=text.replace(/_/,' ');text=document.createTextNode(text);a.href=obj[q];if(obj[q].indexOf('http://')!=-1)
a.target='blank';a.appendChild(text);div.appendChild(a);}
document.body.appendChild(div);}}
function ddMenuExpand(t,id,left)
{var container=document.getElementById(id);if(!container)return;var coords=findPos(t);if(ddMenuTimeout)
window.clearTimeout(ddMenuTimeout);if(id!=ddMenuActive)
ddMenuCollapse();container.style.left=coords[0]+'px';container.style.top=(coords[1]+32)+'px';container.style.display='block';ddMenuActive=id;}
function ddMenuCollapse()
{var container;if(container=document.getElementById(ddMenuActive)){container.style.display='none';ddMenuActive=null;}}
function ddMenuOut()
{ddMenuTimeout=window.setTimeout(function(){ddMenuCollapse();},1000);}
function applyTag(field,tag)
{var selectedText=document.selection;if(selectedText.type=='Text'){var newRange=selectedText.createRange();var mySelection=newRange.text;field.focus();s=new String(field.value);var replaced=s.replace(mySelection,'['+tag+']'+mySelection+'[/'+tag+']');field.value=replaced;}}
function addTag(field,tag,between)
{var curText=document.getElementById(field).value;document.getElementById(field).value=curText+"["+tag+"]"+between+"[/"+tag+"]";}
function styleTag(field,tag,title,def)
{var text=prompt("Please insert the "+title,def);var curText=document.getElementById(field).value;if(text)document.getElementById(field).value=curText+"["+tag+"]"+text+"[/"+tag+"]";}
function insertLink(field)
{var url=prompt("Please insert the URL to the website page","http://");var curText=document.getElementById(field).value;if(url)document.getElementById(field).value=curText+"[url]"+url+"[/url]";}
function p_up(URL,w,h)
{return false;var scrolling;if(h>500)
{h=500;scrolling=1;}else scrolling=0;day=new Date();id=day.getTime();eval("page"+id+" = window.open('"+URL+"', '"+id+"', 'toolbar=0,scrollbars="+scrolling+",location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+"');");}
function addToText(text)
{var curText=document.getElementById('replybox').value;document.getElementById('replybox').value=curText+text;}
function showTooltip(divid)
{var tooltip=document.getElementById(divid);tooltip.style.display='block';}
function hideTooltip(divid)
{var tooltip=document.getElementById(divid);tooltip.style.display='none';}
function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}
function doPop(URL)
{return false;var popunder=URL;var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"
var once_per_session=0
function get_cookie(Name){var search=Name+"="
var returnvalue="";if(document.cookie.length>0){offset=document.cookie.indexOf(search)
if(offset!=-1){offset+=search.length
end=document.cookie.indexOf(";",offset);if(end==-1)
end=document.cookie.length;returnvalue=unescape(document.cookie.substring(offset,end))}}
return returnvalue;}
function loadornot(){if(get_cookie('popunder')==''){loadpopunder()
document.cookie="popunder=yes"}}
function loadpopunder(){return;win2=window.open(popunder,"",winfeatures)
win2.blur()
window.focus()}
if(once_per_session==0)
loadpopunder()
else
loadornot()}
function addEvent(obj,evType,fn,useCapture)
{if(obj.addEventListener){obj.addEventListener(evType,fn,useCapture);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{alert("Handler could not be attached");}}
function removeEvent(obj,evType,fn,useCapture)
{if(obj.removeEventListener){obj.removeEventListener(evType,fn,useCapture);return true;}else if(obj.detachEvent){var r=obj.detachEvent("on"+evType,fn);return r;}else{alert("Handler could not be removed");}}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function noBubble(e)
{if(e.stopPropagation)e.stopPropagation();else if(window.event)window.event.cancelBubble=true;}
function show_infoTip(e,msg,pushLeft,pushTop)
{e=(e)?e:window.event;var t=(e.target)?e.target:e.srcElement;if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;if(!t)return;var div=document.createElement('div');div.className='infoTip';div.innerHTML=msg;div.id='infoTip123';var coords=findPos(t);div.style.left=(coords[0]+parseFloat(pushLeft))+'px';div.style.top=(coords[1]+parseFloat(pushTop))+'px';document.body.appendChild(div);}
function hide_infoTip()
{var div=document.getElementById('infoTip123');if(!div)return;document.body.removeChild(div);}
function toggleCitySelect(t,curCity)
{coords=findPos(t);t.onselectstart=function(){return false;}
t.onmousedown=function(){return false;}
var id='citySelectPop';var div=document.getElementById(id);if(!div)
{var cities=new Array('Calgary','Montreal','Toronto','Vancouver','Show \'em All!');var div=document.createElement('div');div.id=id;var title=document.createElement('h3');title.className='contentHeaderRed';var text=document.createTextNode('Switch Cities');title.appendChild(text);div.appendChild(title);var ul=document.createElement('ul');for(var i=0;i<cities.length;i++)
{var li=document.createElement('li');var a=document.createElement('a');var text=document.createTextNode(cities[i]);if(cities[i].indexOf('All')==-1)
a.href='http://'+cities[i].toLowerCase()+'.vibe.to/';else
a.href='http://global.vibe.to/';a.appendChild(text);li.appendChild(a);ul.appendChild(li);}
div.appendChild(ul);div.style.display='none';div.style.position='absolute';document.body.appendChild(div);}
var div=document.getElementById(id);var clipRight=0;var clipBottom=0;var interval;if(div.style.display=='none')
{div.style.top=(coords[1]+16)+'px';div.style.left=coords[0]+'px';to=window.setInterval(function(){clipRight+=40;clipBottom+=40;div.style.clip='rect(0px, '+clipRight+'px, '+clipBottom+'px, 0px)';div.style.display='block';if(clipRight>=320&&clipBottom>=320)
window.clearInterval(to);},25);}
else
{div.style.display='none';}}
if(document.images)
{var nav1=new Image;nav1.src='http://images.vibe.to/mag/amagnav_01.gif';var nav2=new Image;nav2.src='http://images.vibe.to/mag/amagnav_02.gif';var nav3=new Image;nav3.src='http://images.vibe.to/mag/amagnav_03.gif';var nav4=new Image;nav4.src='http://images.vibe.to/mag/amagnav_04.gif';var nav5=new Image;nav5.src='http://images.vibe.to/mag/amagnav_05.gif';var nav6=new Image;nav6.src='http://images.vibe.to/mag/amagnav_06.gif';var nav7=new Image;nav7.src='http://images.vibe.to/mag/amagnav_07.gif';var nav8=new Image;nav8.src='http://images.vibe.to/mag/amagnav_08.gif';}
$(window).keypress(function(event){var keyCode=event.which?event.which:event.keyCode;if(keyCode==104&&event.ctrlKey){event.preventDefault();document.location.href='http://www.vibe.to';}});
function handleLogin()
{var login=document.getElementById('top_login');var pass=document.getElementById('top_password');if(!login||!pass)return;if(login.value=='')login.value='username';if(pass.value=='')pass.value='password';}
function comment(userid)
{day=new Date();id=day.getTime();eval("page"+id+" = window.open('http://www.vibe.to/comment.php?id=' + userid, '"+id+"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=495,height=520,left = 277,top = 159');");}
function buddyNow(userid)
{var listener=document.getElementById('listen');listener.src='_listen.php?call=1&userid='+userid+'&buddy=1';}
function removeBuddy(userid)
{var listener=document.getElementById('listen');document.getElementById('isMyFriend').style.display='none';listener.src='_listen.php?call=1&userid='+userid+'&removebuddy=1';}
function deleteComment(commentid)
{if(confirm("Are you sure you want to delete this comment?"))
{var listener=document.getElementById('listen');document.getElementById('h'+commentid).style.display='none';document.getElementById('b'+commentid).style.display='none';listener.src='_listen.php?call=1&dc='+commentid;}}
function friendsDisplay(calling,userid)
{var myframe=document.getElementById('interactFrame');myframe.src='http://www.vibe.to/interact_new.php?t='+calling+'&userid='+userid;var allLink=document.getElementById('viewAll');allLink.href='http://www.vibe.to/friends/'+userid+'/'+calling+'/';}
function handleLoginFocus(field,def)
{if(field.value==def)
{field.value='';}}
var xmlHttp;var isActive;var timeout;var domain="http://www.vibe.to";function getRecentViews(userid)
{ajaxStatus('Grabbing your recent profile views...');var divname="ajaxProfileViews";xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
document.location.href='http://www.vibe.to/friends/'+userid+'/friends/';return}
var url="http://www.vibe.to/_ajax.profileViews.php"
url=url+"?userid="+userid
url=url+"&rand="+Math.random()
xmlHttp.onreadystatechange=doOutput
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
function doOutput()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{var views=document.createElement('div');views.id=divname;views.innerHTML=xmlHttp.responseText;var node=document.getElementById('titlePromptEtc');var viewsPrompt=document.getElementById('viewsPrompt');node.insertBefore(views,viewsPrompt.nextSibling);ajaxStatus();document.getElementById('viewsPrompt').onclick=function()
{toggleViews(1);}
document.getElementById(divname).className="recentViews";toggleViews(-1);return false;}
else
{document.getElementById('viewsPrompt').onclick=function()
{return false;}}}}
function toggleViews(toggle)
{if(toggle>0)
{document.getElementById('ajaxProfileViews').style.display="none";document.getElementById('viewsPrompt').onclick=function()
{toggleViews(-1);}
document.getElementById('viewsPrompt').className="prompt_fade";}
else
{document.getElementById('ajaxProfileViews').style.display="block";document.getElementById('viewsPrompt').onclick=function()
{toggleViews(1);}
document.getElementById('viewsPrompt').className="prompt";}
return false;}
function ajaxQuickFind(firstSearch)
{xmlHttp=GetXmlHttpObject();ajaxStatus('Searching the database...');var divname="quickFindContainer";if(xmlHttp==null)
{var quickForm=document.getElementById('quickfind');quickForm.submit();return}
var url="http://www.vibe.to/_ajax.quickFind.php";url=url+"?gender="+document.getElementById('quick_gender').value;url=url+"&location="+document.getElementById('quick_location').value
url=url+"&agemin="+document.getElementById('quick_agemin').value
url=url+"&agemax="+document.getElementById('quick_agemax').value
if(firstSearch<0)
{var prevSearchResults=document.getElementById(divname);document.getElementById('memberQuickFind').removeChild(prevSearchResults);}
var container=document.createElement("div");container.setAttribute("id",divname);document.getElementById('memberQuickFind').appendChild(container);xmlHttp.onreadystatechange=doOutput;xmlHttp.open("GET",url,true);xmlHttp.send(null);function doOutput()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{container.innerHTML=xmlHttp.responseText;ajaxStatus();document.getElementById('quickFindSubmit').onclick=function()
{ajaxQuickFind(-1);}}
else
{document.getElementById('quickFindSubmit').onclick=function()
{return false;}}}}
function hideQuickResults()
{var results=document.getElementById('quickFindContainer').innerHTML="";}
function fetchQuote(e,postid,username,table)
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{return;}
if(window.event)window.event.returnValue=false;else if(e&&e.preventDefault)e.preventDefault();var url=domain+"/_ajax.fetchQuote.php?postid="+postid+"&username="+username+"&table="+table+"&rand="+Math.random();xmlHttp.onreadystatechange=doOutput;xmlHttp.open("GET",url,true);xmlHttp.send(null);function doOutput()
{if(xmlHttp.readyState==4)
{var replybox=document.getElementById('replybox');replybox.value+=xmlHttp.responseText;coords=findPos(replybox);window.scrollTo(0,coords[1]);}}}
function add2Fav(userid)
{if(!userid)
{alert("You must login before you can bookmark pages");return}
xmlHttp=GetXmlHttpObject();var docURL=document.location;var docTitle=document.title;var url="http://www.vibe.to/_ajax.add2Fav.php";url=url+"?userid="+userid;url=url+"&url="+escape(docURL);url=url+"&title="+escape(docTitle);url=url+"&rand="+Math.random();xmlHttp.onreadystatechange=doOutput;xmlHttp.open("GET",url,true);xmlHttp.send(null);function doOutput()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{isActive=null;if(xmlHttp.responseText=="1")
{alert("You have successfully bookmarked this page.\n\n"+docTitle);}
else
{alert("We couldn't save the page to your favourites list because of an error");}}}}
function showBookmarks(e,userid)
{var divid='favmenu';if(isActive)return;isActive=1;e=(e)?e:window.event;var obj=e.target?e.target:e.srcElement;xmlHttp=GetXmlHttpObject();xmlHttp.onreadystatechange=doBookmarksAJAX;xmlHttp.open("GET","http://www.vibe.to/_ajax.getBookmarks.php?userid="+userid+"&rand="+Math.random(),true);xmlHttp.send(null);function doBookmarksAJAX()
{if(xmlHttp.readyState==4)
{var absOffset=findPos(obj);var menu=document.createElement('div');menu.id=divid;var leftPX=parseInt(absOffset[0])-274;menu.style.left=leftPX+'px';var topPX=parseInt(absOffset[1])+27;menu.style.top=topPX+'px'
document.body.appendChild(menu)
document.getElementById(divid).innerHTML=xmlHttp.responseText;menu.onmouseout=function()
{timeout=window.setTimeout("hideBookmarks(1)",3000);}
menu.onmouseover=function()
{if(timeout)
{clearTimeout(timeout);}}}}}
function hideBookmarks(fade)
{var ms=fade?350:1;if(!fade)
{if(timeout)
clearTimeout(timeout);isActive=0;var menu=document.getElementById('favmenu');if(!menu)return;document.body.removeChild(menu);}
else
{setTimeout("hideBookmarks(0)",ms);}}
function findPos(obj)
{var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}
function fadeIn(opacity,objname)
{obj=document.getElementById(objname);if(obj)
{if(opacity<=100)
{if(obj.style.MozOpacity!=null)
{obj.style.MozOpacity=(opacity/100)-.001;}else if(obj.style.opacity!=null)
{obj.style.opacity=(opacity/100)-.001;}else if(obj.style.filter!=null)
{obj.style.filter="alpha(opacity="+opacity+")";}
opacity+=10;window.setTimeout("fadeIn("+opacity+", '"+objname+"')",35);}}}
function fadeOut(opacity,objname,debug)
{var obj=document.getElementById(objname);if(obj)
{if(opacity>=0)
{if(obj.style.MozOpacity!=null)
{obj.style.MozOpacity=(opacity/100)-.001;}else if(obj.style.opacity!=null)
{obj.style.opacity=(opacity/100)-.001;}else if(obj.style.filter!=null)
{obj.style.filter="alpha(opacity="+opacity+")";}
opacity-=10;window.setTimeout("fadeOut("+opacity+", '"+objname+"')",35);}}else if(debug)alert("Couldn't get object: "+objname);}
function rateNow(rating,userid,rateclass,pid)
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)return;var url="http://www.vibe.to/_ajax.userVote.php"
url=url+"?rating="+rating;url=url+"&userid="+userid;url=url+"&rateclass="+rateclass;url=url+"&pid="+pid;url=url+"&rand="+Math.random();xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4)
{if(rateclass=='profile')
{document.getElementById('rateDrop').style.display='none';var doneMsg=document.createTextNode('rating '+rating+' submitted');document.getElementById('rateSpot').appendChild(doneMsg);}
else if(rateclass=='picture')
{var div=document.getElementById('ratingContainer');if(!div)return;var br=document.createElement('br');var text=document.createTextNode('saved');div.appendChild(br);div.appendChild(text);}}}
xmlHttp.open("GET",url,true);xmlHttp.send(null);}
function dirBrowser(hlink,dir,objref)
{var divid=objref+"_child";if(document.getElementById(divid))
{hlink.style.fontWeight='normal';collapseDir();return;}
xmlHttp=GetXmlHttpObject();xmlHttp.onreadystatechange=doBrowseDir;xmlHttp.open("GET","http://www.vibe.to/_ajax.dirBrowser.php?dir="+dir+"&rand="+Math.random(),true);xmlHttp.send(null);function doBrowseDir()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{hlink.style.fontWeight='bold';var obj=document.getElementById(objref);var div=document.createElement('div');div.setAttribute('id',divid);div.innerHTML=xmlHttp.responseText;obj.appendChild(div);fadeIn(0,divid);}}
function collapseDir()
{var parent=document.getElementById(objref);var child=document.getElementById(divid);parent.removeChild(child);}}
function ajaxStatus(string)
{var output=document.getElementById('ajaxStatus');if(string&&!output)
{var status=document.createElement('div');status.setAttribute('id','ajaxStatus');status.className='AJAXStatus';var innerTXT=document.createTextNode(string);status.appendChild(innerTXT);document.body.appendChild(status);}
else
{if(output)
{fadeOut(100,'ajaxStatus');setTimeout("killAjaxStatus()",350);}}}
function killAjaxStatus()
{var output=document.getElementById('ajaxStatus');document.body.removeChild(output);}
function GetXmlHttpObject()
{var objXMLHttp=null
if(window.XMLHttpRequest)
{objXMLHttp=new XMLHttpRequest()}
else if(window.ActiveXObject)
{objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")}
return objXMLHttp}
// * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};