function getWindowTitle() {
    if (NAME != "") {
        var title = NAME;
    } else {
        var title = document.title.split(' | ')[1];
    }
    return title;
}
function getLocation() {
    if (LOCATION != "") {
        var thisLocation = LOCATION;
    } else {
        var thisLocation = window.location.href;
    }
    return thisLocation;
}
function bookmark() {
	var title = "glumbert.com - The most amazing videos on the Internet";
	var url = "http://www.glumbert.com";
	
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) {
		window.external.AddFavorite(url, title);
	} else if (window.opera && window.print) {
		alert("This feature isn't compatible with your browser. Try pressing Ctrl-D to bookmark.");
	}
	
}
function recommend() {
    var title = getWindowTitle();
    window.open('/send/send.php?page='+encodeURIComponent(URLNAME)+'&title='+encodeURIComponent(title), 'recommendpage', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=550');
}
function delicious() {
	var title = getWindowTitle();
	var thislocation = getLocation();
	window.open('http://del.icio.us/post/?url=' + encodeURIComponent(thislocation)+'&title='+encodeURIComponent(title), '_blank');
}
function diggThis() {
    var title = getWindowTitle();
    var thislocation = getLocation();
    window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(thislocation)+'&title='+encodeURIComponent(title)+'&topic=videos_comedy','_blank');
}
function sendaim() {
    var thislocation = getLocation();
    window.open(location.href='aim:goim?screenname=Choose+a+buddy+from+this+box&message=' + thislocation, '_self');
}
function reddit() {
    var title = getWindowTitle();
    var thislocation = getLocation();
    window.open('http://reddit.com/submit?url='+encodeURIComponent(thislocation)+'&title='+encodeURIComponent(title), '_blank');
}
function facebook() {    
    u=location.href;
    t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}
function urlEncode(str) {
    var result = "";
    for (i = 0; i < str.length; i++) {
        if (str.charAt(i) == " ") result += "+";
        else result += str.charAt(i);
    }
    return result;
}
function contact() {
    window.open(location.href='/contact/?ref=' + encodeURIComponent(location.href), '_self');
}
function loadSuggest() {
    var suggest = document.getElementById('suggest');
    if (suggest) {
        var urlInput = document.createElement('input');
        urlInput.setAttribute('name', 'url');
        urlInput.setAttribute('type', 'text');
        urlInput.setAttribute('value', 'Suggest a Link');
        urlInput.id = "suggest-url";
        var submitButton = document.createElement('input');
        submitButton.setAttribute('name', 'Submit');
        submitButton.setAttribute('type', 'submit');
        submitButton.setAttribute('value', 'Suggest a Link');
        submitButton.onclick = function() {
            if (!f) {
                var submitUrl = document.getElementById('suggest-url');
                content = "url=" + encodeURIComponent(submitUrl.value);
                http.open("POST", "/dev/suggest/suggest.php", true);
                http.onreadystatechange = function() {
                    if ((http.readyState == 4) && (http.status == 200)) {
                        var response = http.responseText;
                        if (response == "true") {
                            document.getElementById('suggest-url').value = "";
                            document.getElementById('suggest-message').innerHTML = "Thank You!";
                        }
                    }
                    f = false;
                };
                http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                http.setRequestHeader('Accept','text/xml');
                http.send(content);
                f = true;
            }
        }
        var message = document.createElement('div');
        message.id = "suggest-message";
        suggest.appendChild(message);
        suggest.appendChild(urlInput);
        suggest.appendChild(submitButton);
    }
}

var f = false;
var http = XMLHTTPObject(); // Create the XMLHttpRequest Object.

function XMLHTTPObject() {
    var xmlhttp = null;

    if (window.ActiveXObject) {
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (ex1) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (ex2) {
                // do nothing
            }
        }
    } else if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }

    return xmlhttp;
}
function optionsToggle() {
	var OPTIONSCONTAINER = "extrashare";
	var OPTIONSLINKCONTAINER = "extrasharetoggler";
	var OPTIONSTEXTUP = "More Sharing Options";
	var OPTIONSTEXTDOWN = "Fewer Sharing Options";
	
	var optionsContainer = document.getElementById(OPTIONSCONTAINER);
	var optionsToggler = document.getElementById(OPTIONSLINKCONTAINER);
	if (optionsContainer.style.display == "none") {
		optionsContainer.style.display = "";
		optionsToggler.innerHTML = OPTIONSTEXTDOWN;
		optionsToggler.className = 'optionsdown';
	} else {
		optionsContainer.style.display = "none";
		optionsToggler.innerHTML = OPTIONSTEXTUP;
		optionsToggler.className = 'optionsup';
	}
}
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 pauseVid() {	
	//if (confirm('preview pause')) debugger;
	ss_flashProxy.call('pauseVid');
}
function playVid() {
	//if (confirm('preview pause')) debugger;
	ss_flashProxy.call('playVid');
}
function getTime()	{
	var player = document.getElementById(self.ss_videoPlayerId);
	if (player == null) {
		return 0;
	}	
	var moviePosition = player.GetVariable("ss_moviePosition");
	
	if (moviePosition == null || moviePosition == "") {
		moviePosition = 0;
	}	
	
	var result = moviePosition;
	var posit = Math.floor(Number(result));
	return posit;	
}
function getVideo() {
	var video = "http://cdn.glumbert.com/video/flash/" + URLNAME + ".flv";
	return video;
}
function hideAd() {
	ss_debugLog('ss_hideBAU() called');

	if (ss_updateAds.timeoutId)
		window.clearTimeout(ss_updateAds.timeoutId);
	ss_updateAds.timeoutId = null;
	
	var ads = document.getElementById("ss_ads");
	if (!ads) return;
	ads.style.display = 'none';
	ads.innerHTML = '';
}