/*
 * Script for chat functions
 */
function limitText(limitField, limitNum) {
	if (limitField.value.length > (limitNum)) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

function showlimitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > (limitNum)) {
		limitCount.value = 0;
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function create_chat_window($id) {
     var dimensions = {width: 0, height: 0};
     if (document.documentElement) {
         dimensions.width = document.documentElement.offsetWidth;
         dimensions.height = document.documentElement.offsetHeight;
     } else if (window.innerWidth && window.innerHeight) {
         dimensions.width = window.innerWidth;
         dimensions.height = window.innerHeight;
     }
     /* only open window once */
     if ($('#'+$id+'_chatwindow').val() == undefined){ 
       $('<div id="'+$id+'_chatwindow" style="position:absolute; z-index:1;left:'+(dimensions.width/2-250)+'px;top:'+(document.body.scrollTop+100)+'px;"></div>').appendTo("#onlinebox_chatlist"); 
       $.get('/core/chat/chat_mainframe.php?id='+$id, function(data) { $('#'+$id+'_chatwindow').html(data); });
     } 
     $('#onlinebox_chatlist').show();
}

