function openMask(isOpen){
    var loadingmask=document.getElementById('loading-mask');
    var loading=document.getElementById('loading');
    if(isOpen==true){
    	loadingmask.style.display="block"; 
    	loading.style.display="block";
    }else{
    	loadingmask.style.display="none"; 
    	loading.style.display="none";
    }
    
}

function checktext(text) {
	allValid = true;
	for (i = 0; i < text.length; i++) {
		if (text.charAt(i) != " ") {
			allValid = false;
			break;
		}
	}
	return allValid;
}

function gbcount(message, total, used, remain) {
	var max;
	max = total.value;
	if (message.value.length > max) {
		message.value = message.value.substring(0, max);
		used.value = max;
		remain.value = 0;
		alert("Maximun 200 characters!");
	} else {
		used.value = message.value.length;
		remain.value = max - used.value;
	}
}

function checkSubmit(){
    var message = document.getElementById('message');
	if(message.value.length<1){
	alert("Text empty");
	return false;
    }
	if(message.value.length>200){
		alert("Maximun 200 characters!");
		return false;
	    }
    return true;
	
}
function loadingProfile(twitterid){
	easyDialog.open({
		  container : {
		    header : 'User Profile',
		    content : 'Loading'
		  },
		  follow : 'tripuserSpan'+twitterid,
			followX : 0,
			followY : -10
		});
}
function callProfileMouseOn(id,twitterid){
	//loadingProfile(twitterid);
	callProfileMouseOn1(id,twitterid);
}
function callProfileMouseOn0(id,twitterid){
	var timmer = document.getElementById('timmer');
	if(timmer.value == 1){
		easyDialog.close();
		setBackTimmer();
		callProfileMouseOn1(id,twitterid);
	}else{
		//alert(timmer.value ++);
		timmer.value ++;
		document.getElementById('timmer').value = timmer.value;
		setTimeout('callProfileMouseOn0('+id+','+twitterid+')', 1000);
	}	
}

function callProfileMouseOn1(id,twitterid) {
	
		var iframe = document.getElementById('userProfileFrame');
		iframe.style.display='block';
		iframe.src = 'profilebox?userid=' + id;
		openProfileForm(twitterid);
		/*
		  try{	    
	   	   if (iframe.attachEvent){
	   		    iframe.attachEvent("onload", function(){
	   		    	openProfileForm(twitterid);
	   		    });
	   		} else {
	   		    iframe.onload = function(){
	   		    	openProfileForm(twitterid);
	   		    };
	   		}
	   	   iframe.focus();
	   	  
	   	  }catch (ex){}
	   	  */		
}

function setBackTimmer(){
	document.getElementById('timmer').value = 0;
}
function callProfileMouseOut(){
	setBackTimmer();
	easyDialog.close();
}

function openProfileForm(followid){
	easyDialog.open( {
		container : 'userProfileFrame',
		follow : 'tripuserSpan'+followid,
		followX : 0,
		followY : -10
	});
}

function userProfileMouseOut() {
	easyDialog.close();
}

function addFollow(followid) {     	
    $.ajax({  
   url: 'addfollow',
   data: ({followid : followid}),
   success: function(data) {
    alert(data);
   }
   });  
}

function deleteFollow(followid) {     	
   alert(followid);
   $.ajax({  
  url: 'deleteFollow',
  data: ({followid : followid}),
  success: function(data) {
   alert(data);
  }
  });  
}
