var fbConnectBtn='<a href="#" onclick="FB.Connect.requireSession(); return false;" ><img border="0" id="fb_login_image" src="http://wiki.developers.facebook.com/images/6/6f/Connect_iphone.png" alt="Connect"/></a>';
function onFBConnected() {
    if(document.getElementById('fbConnect'))
        document.getElementById('fbConnect').innerHTML="";
    if(document.getElementById("fbProfilePic"))
        document.getElementById("fbProfilePic").style.display="";
        
} 
function onFBNotConnected() { 
     FB.ensureInit(function() {
        FB.Connect.get_status().waitUntilReady(function(status) {
            if (status == FB.ConnectState.userNotLoggedIn && document.getElementById('fbConnect') )    {
                document.getElementById('fbConnect').innerHTML=fbConnectBtn;
            }
            if (status == FB.ConnectState.appNotAuthorized && document.getElementById('fbConnect'))    {
                document.getElementById('fbConnect').innerHTML=fbConnectBtn;
            }
        });
    });
}
function sendmeSearch(term,adres){
    window.location=adres+term.value+'.aspx';
}
function f(o){
	var code = event.keyCode
	switch (code)
	{
	case 37:
		break
	case 38:
		break
	case 39:
		break
	case 40:
		break
	default:
		if(o.value != o.value.toLowerCase()) {
		    o.value=o.value.toLowerCase();
		}
	}
}
function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}
function iA(mF, mV) {
if (document.selection) {
var t;mF.focus();
sel=document.selection.createRange();t=sel.text.lenght;sel.text=mV;
if (mV.length==0){sel.moveStart('character',mV.length);
sel.moveEnd('character',mV.length);
}else {
sel.moveStart('character',-mV.length+t);
}sel.select();
}else if (mF.selectionStart || mF.selectionStart=='0'){
var sP=mF.selectionStart;
var eP=mF.selectionEnd;
mF.value=mF.value.substring(0,sP)+mV+mF.value.substring(eP,mF.value.length);
mF.selectionStart=sP+mV.length;
mF.selectionEnd=sP+mV.length;
mF.focus();
}else{
mF.value+=mV;}}

function backAtCursor(mF){if (document.selection){
mF.focus();
sel=document.selection.createRange();

if(sel.text.length>0){ 
sel.text='';
}else{
sel.moveStart('character',-1); 
sel.text='';
}

sel.select();
 
}else if (mF.selectionStart || mF.selectionStart == '0'){
var sP=mF.selectionStart;
var eP=mF.selectionEnd;
mF.value=mF.value.substring(0,sP-1)+mF.value.substring(eP,mF.value.length);
mF.selectionStart=sP-1;
mF.selectionEnd=sP-1;
mF.focus();
}else{
mF.value=mF.value.substr(0,(mF.value.length-1));
mF.focus();
}
}

function showProfilPic(proPicPath,link){    
    document.getElementById('profilPic').innerHTML="<img width=110 src='"+proPicPath+"' />";
}
function closeProfile(){
    document.getElementById('profilPic').innerHTML="";
}
function moveProfilePic(e,o){
    e = jQuery.event.fix(e); 
    document.getElementById('profilPic').style.left=e.pageX+10+"px";
    document.getElementById('profilPic').style.top=e.pageY+5+"px";
}