function openWinCentered(loc, winname, widthh, heightt, params)
{
    var tp = Math.ceil((screen.height - heightt) / 2);
    var lf = Math.ceil((screen.width - widthh) / 2);
    if (params.length > 0)
        params = "," + params;

    var win = window.open(loc, winname, "width=" + widthh + ",height=" + heightt + ",top=" + tp + ",left=" + lf + params);
    win.focus();
    return win;
}


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






function toggle(obj_name)
{
	name = obj_name.substr( 0, obj_name.lastIndexOf('_') );
	siz = obj_name.substr( obj_name.lastIndexOf('_') + 1 );

	obj = document.getElementById(obj_name);

	if (siz == 'big') siz2 = 'small'; else siz2 = 'big';
	obj2 = document.getElementById(name+'_'+siz2);
	obj.style.display = 'none';
	obj2.style.display = 'block';
}

function cache_img(src)
{
	var img = new Image();
	img.src = src;
}

function is_copy_to_clipboard_enabled()
{
	if(window.clipboardData)
	{
		return true;
	}
	return swfobject.hasFlashPlayerVersion('3');
}
function enable_copy_to_cliboard_links()
{
	if(is_copy_to_clipboard_enabled())
	{
		var coll = document.getElementsByTagName('a');
		for(i=0;i<coll.length;i++)
		{
			if(coll[i].className.indexOf('copy_to_clipboard') >= 0)
			{
				coll[i].style.display = 'inline';
			}
		}
	}
}
function copy_to_clipboard(text)
{
	if (window.clipboardData)
	{
		window.clipboardData.setData("Text",text);
	}
	else
	{
		if(!document.getElementById('copy_to_clipboard_flash'))
		{
			var divholder = document.createElement('div');
			divholder.id = 'copy_to_clipboard_flash';
			document.body.appendChild(divholder);
		}
		swfobject.embedSWF(http_static_path+'/flash/clipboard.swf', 'copy_to_clipboard_flash', '0', '0', '3', null, {clipboard:escape(text)});
	}
}

function get_elements_by_class(class_name, parent, tag)
{
	var res = new Array();
	var coll = parent.getElementsByTagName(tag);
	var reg = new RegExp('(^|\s)'+class_name+'($|\s)');
	for(i=0;i<coll.length;i++)
	{
		if(coll[i].className.match(reg))
		{
			res.push(coll[i]);
		}
	}
	return res;
}

function friendFilter(e) {
sval=document.getElementById(e+'_f').value;

if(sval.length>=2){
document.getElementById(e).style.display='inline';
ajaxgo(sval,e);
} else document.getElementById(e).style.display='none';


}




function ajaxgo(username,e) {


var url = 'search_ajax.php';


	pars = 'c=usersearch&user='+ username +'&r='+ Math.random() +'';

	sh_frame=e;

	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: showResponse} );

	



}


 function showResponse(originalRequest)
    {
        //put returned XML in the textarea

	$(sh_frame).innerHTML = originalRequest.responseText;
    }


function search_result(sid){
if(document.getElementById(sid).value=='Enter Friend Name'){
document.getElementById(sid).value='';
}
if(document.getElementById(sid).value=='Enter Friend Name'){
document.getElementById(sid).value='';
}
}