function addSmile(txt) {
e = document.getElementById("message");
if (e.value == '<Type your message here>') e.value='';
insertText(e," "+txt+" ");
}


function insertText(e,inp) {
e = document.getElementById("message");
	
if (document.selection) {
e.focus();
sel = document.selection.createRange();
e.focus();
sel.text = inp;

sel.moveStart('character',0);
sel.moveEnd('character',0);

sel.select();

}
else {
var startPos = e.selectionStart;
var endPos = e.selectionEnd;
e.value = e.value.substring(0,startPos) + inp + e.value.substring(endPos,e.value.length);
e.selectionStart = startPos + inp.length;
e.selectionEnd = startPos + inp.length;
e.focus();
}
}

function wipeTextArea(e) {
if (e.value == '<Type your message here>') e.value='';
if (e.value == '<Write a little about yourself>') e.value='';
}

function liteon(e) {
//e.className = e.className + ' hilite';
}

function liteoff(e) {
//e.className = e.className.substring(0,e.className.length-7);
}

function outputImage(w,h,x) {
document.write('<embed src="flashview.swf" scale="noscale" salign="tl" quality="high" bgcolor="#ffffff" width="'+w+'" height="'+h+'" FlashVars="picID='+x+'" name="imgview" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">');
}

function outputVideo(x,size) {

if ( (size < 1) || (size > 3) ) size = 2;

if (size == 1) document.write('<embed src="movieplayer_ri.swf" width="320" height="280" FlashVars="movie='+x+'&moviewidth=320" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">');

if (size == 2) document.write('<embed src="movieplayer_ri.swf" width="480" height="416" FlashVars="movie='+x+'&moviewidth=480" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">');

if (size == 3) document.write('<embed src="movieplayer_ri.swf" width="640" height="560" FlashVars="movie='+x+'&moviewidth=640" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">');

}

function outputAdvert() {
document.write('<embed src="ad.swf" width="210" height="350" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
}

function outputFreeVideo(x) {
document.write('<embed src="freemovie'+x+'_r2.swf" width="400" height="350" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">');
}

function updateCharCounter(src,maxlen) {

e = src;
f = document.getElementById(src.id + "_cc");

if ((!e) || (!f)) return;

if (e.value.length >= maxlen) {
e.value = e.value.substring(0,maxlen);
}

f.innerHTML = '<span class="t2">' + src.value.length + '</span> of <span class="t2">' + maxlen + '</span> chars max';

}




function confirmation(i) {
	var answer = confirm(i)
	if (answer){
		return true;
	}
	else{
		return false;
	}
}




function doChecks() {
 $("#ggonline").load("ggonline.php",function(data) {
 
 data = data.split('|');
 
 if (parseInt(data[0]) > 0) { $("#ggonline").html('<b>online</b>'); } else { $("#ggonline").html('<i>offline</i>'); }
 
 if (parseInt(data[1]) > 0) {
 $("#mail_indi").html('<a class="mailblink" href="inbox.php">'+data[1]+' msg'+(data[1]==1 ? '' : 's')+'</a>');
 }
 else
 $("#mail_indi").html('No msgs');

 setTimeout("doChecks();",3000);
 
 });
 }



 
 $(document).ready(function() {
 
 
 
 $("#nav").find('a').eq(section-1).addClass('nav_selected');
 
 
 $(".info,.error").show();
// $(".info").animate({height:48,lineHeight:48}).delay(5000).animate({height:0,lineHeight:0});
// $(".error").animate({height:48,lineHeight:48}).delay(5000).animate({height:0,lineHeight:0});
 
 
 animateTwitter();
 
 $(".thumbT1").hover(function() {
 //$(this).css('padding','2px');
 });
 
 $("#admin_nav").mouseenter(function() {
 $(this).stop(true).delay(250).animate({height:48,lineHeight:'48px'});
 $("a",$(this)).stop(true).delay(250).animate({opacity:1});
 $("span",$(this)).stop(true).delay(250).animate({right:-100,opacity:0});
 }).mouseleave(function() {
 $(this).stop(true).animate({height:24,lineHeight:'24px'});
 $("a",$(this)).stop(true).animate({opacity:0});
  $("span",$(this)).stop(true).animate({right:0,opacity:1});
 });
 
 
shift = $(document).height() - $("body").innerHeight();
//alert(shift);
//$("#content").css('height',($("#content").css('height')+shift));

//$("#footer").css('top',shift);

//$("#content").css('padding-bottom',parseInt($("#content").css('padding-bottom'))+shift);

 
 $("#socials a").hover(function(event) {
 $("#socialpopup").stop().animate({height:34,opacity:1}).html($(this).attr('title'));
 event.preventDefault();
 },function() {
 $("#socialpopup").stop().animate({height:0,opacity:0});
 });
 
 
 $(".msglist tr").hover(function() {
 $(this).css({backgroundColor:'#f8f8f8'});
 },function() {
 $(this).css({backgroundColor:'transparent'});
 });
 
 $(".msglist tr").click(function(e) {
 
 if ($(e.target).attr('tagName') == 'DIV')
	 window.location = $(this).find('a').attr('href');
	 
 });
 
 $(".thumbT1,.galbox_r3").hover(function() {
 $(this).stop().animate({backgroundColor:'#fed78f'});
 },function() {
 $(this).stop().animate({backgroundColor:'#ffffff'});
 });
  
 setTimeout("doChecks();",3000);
 
 

 
 
// $("tr:even","table.msglist").css('backgroundColor','#f8f8f8');
 
 
 
// $("#admin_nav > a").hover(function() {
// $(this).









 
 });
 
 
  function animateTwitter() {
 //$("#twitter").delay(5000).animate({opacity:0.5}).animate({opacity:1},function() { setTimeout("animateTwitter;",5000);});
 }
 
 
 
 /**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
