$(document).ready(function(){

$("#my-glog-friends .friend").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});

$(".loggedout #my-glog-friends .friend").mouseover(function() {$(this).removeClass("over");});


// $("#my-glog-messages .message-container").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});


$(".categories .item").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
//$("#glogger-list-items .glogger").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});

//$("#search-results #users div.glogger").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});

$("#log-in").click(function(){ $("#user-details").addClass("showform"); });

$("#embed-glog-header").click(function(){ $("#embed-glog-info").removeClass("hidden"); return false; });
$("#embed-glog-info .close-popup a").click(function(){ $("#embed-glog-info").addClass("hidden"); return false; });

$("#send-friends-header.loggedin").click(function(){ $("#send-friends-info").removeClass("hidden"); return false; });
$("#send-friends-info .close-popup a").click(function(){ $("#send-friends-info").addClass("hidden"); return false; });

$(".email-container input").click(function() { if(this.value == '@') this.value = ''; });

$("#friend-message").click(function() { if(this.value == 'Your message...') this.value = ''; });

$("#invite-a-friend").click(function(){ $("#send-friends-info").removeClass("hidden"); return false; });

// $("#my-glog-messages .message").click(function(){ $(this).addClass("show"); return false; });
//$("#my-glog-messages .message .cancel-message a").click(function(){ $("#my-glog-messages .message").removeClass("show"); return false; });
//$("#my-glog-messages .message .reply-message a").click(function(){ $(this).parent().parent().parent().addClass("noactions"); $(this).parent().parent().parent().addClass("showform"); return false; });
// $("#rate-glog #glog-rating a span").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});

$("#alreadyreg a").click(function(){ $("#reg-page-login").addClass("show"); return false; });


var ratingmsg = $("#glog-rating #rating-msg").text();

$("#glog-rating #star1").mouseover(function() {$("#glog-rating #rating-msg").html('Poor');}).mouseout(function() {$("#glog-rating #rating-msg").html(ratingmsg)});
$("#glog-rating #star2").mouseover(function() {$("#glog-rating #rating-msg").html('Nothing special');}).mouseout(function() {$("#glog-rating #rating-msg").html(ratingmsg)});
$("#glog-rating #star3").mouseover(function() {$("#glog-rating #rating-msg").html('Fair');}).mouseout(function() {$("#glog-rating #rating-msg").html(ratingmsg)});
$("#glog-rating #star4").mouseover(function() {$("#glog-rating #rating-msg").html('Cool');}).mouseout(function() {$("#glog-rating #rating-msg").html(ratingmsg)});
$("#glog-rating #star5").mouseover(function() {$("#glog-rating #rating-msg").html('Awesome!');}).mouseout(function() {$("#glog-rating #rating-msg").html(ratingmsg)});

/*
if (glogster.getcookie('sendFrCloseInfo') == 1) {
$("#send-to-friends-info").addClass("hidden");
} else {
$("#send-to-friends-info a.close-small-info").click(function(){ $("#send-to-friends-info").addClass("hidden"); glogster.setcookies('sendFrCloseInfo',1); return false; });
}
*/

});




//function limitChars(textarea, limit, infodiv)
function limitChars(textarea, limit)
{
  var text = textarea.value; 
  var textlength = text.length;
//  var info = document.getElementById(infodiv);
  if(textlength > limit) {
//    info.innerHTML = 'You cannot write more then '+limit+' characters!';
    textarea.value = text.substr(0,limit);
    return false;
  } else {
//    info.innerHTML = 'You have '+ (limit - textlength) +' characters left.';
     return true;
  }
}


/* copy to clipboard */
function copy(text2copy)
{
    alert(text2copy);
    
    if (window.clipboardData)
    {
        window.clipboardData.setData("Text",text2copy);
    }
    else
    {
        var flashcopier = 'flashcopier';
        
        if(!document.getElementById(flashcopier))
        {alert('flashcopier');
            var divholder = document.createElement('div');
            
            divholder.id = 'flashcopier';
            
            document.body.appendChild(divholder);
        }
        
        document.getElementById('flashcopier').innerHTML = '';
        
        var divinfo = '<embed src="/images/swf/_clip.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        
        alert(divinfo);
        
		alert("window.clipboardData "+ window.clipboardData);
		alert("document.getElementById('flashcopier') "+ document.getElementById('flashcopier'));
        document.getElementById('flashcopier').innerHTML = divinfo;
    }
}

function confirmation(elem, msgConf, msgKeep)
{
    // See if a confirmation message was sent
    if (msgConf == undefined)
    {
        var msgConf = "Are you sure you want to delete your glog?";
    }
    
    // See if a keeping message was sent
    if (msgKeep == undefined)
    {
        var msgKeep = "You're keeping your Glog - great!";
    }

    var answer = confirm(msgConf);
    
    if (answer){
       return true;
        //window.location = elem.href;
        
    }
    else{
       
        alert(msgKeep);
        return false;
    }
}

