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) {

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

}

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);});
 }
 
 


(function($) {
    $.cookie = function(key, value, options) {

        // key and at least value given, set cookie...
        if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
            options = $.extend({}, options);

            if (value === null || value === undefined) {
                options.expires = -1;
            }

            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setDate(t.getDate() + days);
            }

            value = String(value);

            return (document.cookie = [
                encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
                options.path    ? '; path=' + options.path : '',
                options.domain  ? '; domain=' + options.domain : '',
                options.secure  ? '; secure' : ''
            ].join(''));
        }

        // key and possibly options given, get cookie...
        options = value || {};
        var decode = options.raw ? function(s) { return s; } : decodeURIComponent;

        var pairs = document.cookie.split('; ');
        for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
            if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
        }
        return null;
    };
})(jQuery);
