<!--
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
		
var mouseX = 0;
var mouseY = 0;
	
document.onmousemove = mouseMove;
document.onmouseup   = mouseUp;

var dragObject  = null;
var mouseOffset = null;

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function getMouseOffset(target, ev){
	ev = ev || window.event;
	
	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;
	
	return {x:left, y:top};
}

function mouseMove(ev){
	ev           = ev || window.event;
	var mousePos = mouseCoords(ev);

	if (IE) {
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	} else {
		mouseX = ev.pageX;
		mouseY = ev.pageY;
	}
		
	if(dragObject){
		dragObject.style.position = 'absolute';
		dragObject.style.top      = mousePos.y - mouseOffset.y;
		dragObject.style.left     = mousePos.x - mouseOffset.x;

		return false;
	}
}
	
function mouseUp(){
	dragObject = null;
}

function makeDraggable(item){
	if(!item) return;
	item.onmousedown = function(ev){
		dragObject  = this;
		mouseOffset = getMouseOffset(this, ev);
		return false;
	}
}

/* Show/hide login form */
function showHideLogin() {
	if (document.getElementById('loginform').style.visibility != 'visible') {
		document.getElementById('loginform').style.top = mouseY+10;
		document.getElementById('loginform').style.left = mouseX-170;
		document.getElementById('loginform').style.visibility = 'visible';
	} else {
		document.getElementById('loginform').style.visibility = 'hidden';
	}
}

/* Comments related functions */
function showEditCommentWin(commentid) {
	var commentbody = '';
	document.getElementById('editcommentwin').style.visibility='visible';
	document.getElementById('editcommentwin').style.top=mouseY;
	document.getElementById('editcommentid').value=commentid;
				
	commentbody = document.getElementById('commentbody'+commentid).innerHTML;
	commentbody = commentbody.replace(/<br>/gi, '\r');
	commentbody = commentbody.replace(/<img title=[\"\']?(.+?)[\"\']? .*?>/gi, '$1');
				
	document.getElementById('editcommentbody').value=commentbody;
}

function hideEditCommentWin() {
	document.getElementById('editcommentwin').style.visibility='hidden';
}

/* Check and Uncheck all checkboxes */
function checkUncheckBoxes(form, check) {
	x = document.getElementById(form);
	for(var i=0,l=x.length; i<l; i++)
		if(x[i].type == 'checkbox')
			x[i].checked=check;
}

/* AJAX Codes */
function makeRequest(url, container) {
        var httpRequest;
        
        document.getElementById(container).innerHTML = 
        	"<div id='ajaxloader'></div>";

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/html');
                // See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            document.getElementById(container).innerHTML = 
            	"<div id='notification'>Giving up :( Cannot create an XMLHTTP instance</div>";
            return false;
        }
        
        httpRequest.onreadystatechange = function() { alertContents(httpRequest, container); };
        httpRequest.open('GET', url, true);
        httpRequest.send('');
}

function alertContents(httpRequest, container) {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                document.getElementById(container).innerHTML = 
                	httpRequest.responseText;
            } else {
                document.getElementById(container).innerHTML = 
                	"<div id='notification'>There was a problem with the request.</div>";
            }
        }
}

/* Latest bank videos on the top of every blog page */
var latestBankVideosPage = 0;

function getLatestBankVideos() {
	makeRequest('../lib.php?video=latest&limit=6&start='+(latestBankVideosPage*6)+'&small=1', 'ajaxbanklatestvideos');
}

function nextLatestBankVideos() {
	latestBankVideosPage++;
	getLatestBankVideos();
}

function prevLatestBankVideos() {
	if (latestBankVideosPage > 0) {
		latestBankVideosPage--;
		getLatestBankVideos();
	}
}

/* Popular and User Latest bank videos on the left */
var sideBankVideosPage = 0;

function getSideBankVideos(type, userid) {
	if (userid) {
		uservar = '&user='+userid;
	} else {
		uservar = '';
	}
	
	makeRequest('../lib.php?video='+type+'&limit=6&start='+(sideBankVideosPage*6)+'&small=1'+uservar, 'ajaxbanksidevideos');
}

function nextSideBankVideos(type, userid) {
	sideBankVideosPage++;
	getSideBankVideos(type, userid);
}

function prevSideBankVideos(type, userid) {
	if (sideBankVideosPage > 0) {
		sideBankVideosPage--;
		getSideBankVideos(type, userid);
	}
}

/* Zoom tv in and zoom out by changing the whole iframe source */
var tvZoomed = false;

function zoomTV() {
	if (!tvZoomed) {
		tvZoomed = true;
		document.getElementById('tv').style.width = '330px';
		document.getElementById('tvcontainer').innerHTML = "<iframe src='http://tv.theoopsbank.com/player.php' frameborder='0' marginheight='0' marginwidth='0' scrolling='no' width='328' height='292' allowtransparency='true'></iframe>";
	} else {
		tvZoomed = false;
		document.getElementById('tv').style.width = '205px';
		document.getElementById('tvcontainer').innerHTML = "<iframe src='http://tv.theoopsbank.com/player.php?w=196&h=147' frameborder='0' marginheight='0' marginwidth='0' scrolling='no' width='205' height='199' allowtransparency='true'></iframe>";
	}
}

-->
