var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

/* mithra */
function unselectcheckbox()
{
	document.getElementById('read_enable').style.display ="none";
	document.getElementById('read_disable').style.display ="block";
	document.getElementById('unread_enable').style.display ="none";
	document.getElementById('unread_disable').style.display ="block";
	document.getElementById('delete_enable').style.display ="none";
	document.getElementById('delete_disable').style.display ="block";	
}
function cboxreadcboxunread_check()
{
	document.getElementById('read_enable').style.display ="block";
	document.getElementById('read_disable').style.display ="none";
	document.getElementById('unread_enable').style.display ="block";
	document.getElementById('unread_disable').style.display ="none";
	document.getElementById('delete_enable').style.display ="block";
	document.getElementById('delete_disable').style.display ="none";
}
function cboxunread_check()
{
	document.getElementById('read_enable').style.display ="block";
	document.getElementById('read_disable').style.display ="none";
	document.getElementById('unread_enable').style.display ="none";
	document.getElementById('unread_disable').style.display ="block";
	document.getElementById('delete_enable').style.display ="block";
	document.getElementById('delete_disable').style.display ="none";
}
function cboxread_check()
{
	document.getElementById('unread_enable').style.display ="block";
	document.getElementById('unread_disable').style.display ="none";
	document.getElementById('read_enable').style.display ="none";
	document.getElementById('read_disable').style.display ="block";
	document.getElementById('delete_enable').style.display ="block";
	document.getElementById('delete_disable').style.display ="none";
}
function ajaxsubmit(pageurl,div_id,value)
{
		pageurl = Url.encode(pageurl);
		value = Url.encode(value);
		$.ajax({
		url: pageurl+'/'+value,
		cache: false,
		data: "param=value",
		
		success: function(html){
		$('#'+div_id) .html(html);
		}
		});	
}
function messageprocess(pagename,read,message,messagebox)
{

var viewid="";
		var value=document.inboxform.cbox.value;
		var len=document.inboxform.cbox.length;
		a=len-1;
		if(len>0)
		{
			for(i=0;i<=len-1;i++)
			{
				if(document.inboxform.cbox[i].checked==true)
				{
				var val=document.inboxform.cbox[i].value;
				viewid+=val+'-';
				}
			}
			if(viewid=="")
			{
				alert("Please select checkbox");
			}
			else
			{
					$.ajax({
					url: httppageurl+'inboxs/'+pagename+'/'+messagebox+'/'+viewid+'/'+read,
					cache: false,
					data: "param=value",
					
					success: function(html){
					$('#inboxcontent') .html(html);
					}
					});
					unselectcheckbox()
			}
		}
		else
		{
			var val=document.inboxform.cbox.value;
			viewid=val+'-';
			if(document.inboxform.cbox.checked==false)
			{
				alert("Please select checkbox");
			}
			else
			{
					$.ajax({
					url: httppageurl+'inboxs/'+pagename+'/'+messagebox+'/'+viewid+'/'+read,
					cache: false,
					data: "param=value",
					
					success: function(html){
					$('#inboxcontent') .html(html);
					}
					});
					unselectcheckbox()
					
			}
		}
}
function messageprocess_outbox(pagename,read,message,messagebox)
{
var viewid="";
		var value=document.inboxform.cbox.value;
		var len=document.inboxform.cbox.length;
		a=len-1;
		if(len>0)
		{
			for(i=0;i<=len-1;i++)
			{
				if(document.inboxform.cbox[i].checked==true)
				{
				var val=document.inboxform.cbox[i].value;
				viewid+=val+'-';
				}
			}
			if(viewid=="")
			{
				alert("Please select checkbox");
			}
			else
			{
					$.ajax({
					url: httppageurl+'inboxs/'+pagename+'/'+messagebox+'/'+viewid+'/'+read,
					cache: false,
					data: "param=value",
					
					success: function(html){
					$('#inboxcontent') .html(html);
					}
					});
			}
		}
		else
		{
			var val=document.inboxform.cbox.value;
			viewid=val+'-';
			if(document.inboxform.cbox.checked==false)
			{
				alert("Please select checkbox");
			}
			else
			{
					$.ajax({
					url: httppageurl+'inboxs/'+pagename+'/'+messagebox+'/'+viewid+'/'+read,
					cache: false,
					data: "param=value",
					
					success: function(html){
					$('#inboxcontent') .html(html);
					}
					});
			}
		}
}
function join_circle(circle_id)
{
	if(window.confirm("Do you want to join this circle?"))
	{
		window.location="../../circles/joinCircle/"+circle_id;
	}
	else
	{
		return false;
	}
}
function unjoin_circle(circle_id)
{
	if(window.confirm("Do you want to leave the circle?"))
	{
		window.location="../../circles/unjoinCircle/"+circle_id;
	}
	else
	{
		return false;
	}
}
function join_group(circle_id,group_id)
{
	if(window.confirm("Are you sure you want to join this group?"))
	{
		window.location="../../../circles/joinGroup/"+circle_id+'/'+group_id;
	}
	else
	{
		return false;
	}
}
function unjoin_group(circle_id,group_id)
{
	if(window.confirm("Are you sure you want to unjoin this group?"))
	{
		window.location="../../../circles/joinGroup/"+circle_id+'/'+group_id;
	}
	else
	{
		return false;
	}
}
//

function creatimgelement(div_name,image_name,get_width,get_height)
{
	var img = document.createElement('img');
	img.src = image_name;
	img.setAttribute('width', get_width);
	img.setAttribute('height', get_height);
	img.alt = 'Kibology';
	my_div = document.getElementById(div_name);
	my_div.parentNode.insertBefore(img,my_div);
}
function modelwindow(id1){
var time = 0;
setTimeout("$('#preloader').show();",10);
setTimeout("$('#"+id1+"').show();",time); 
setTimeout("$('#preloader').hide();",300);
("body").addClass("body");
}
function commentValitation()
{
	var title=document.form1.title.value;
	if(title=="")
	{
	alert("Please enter the content.");
	document.form1.title.focus();
	return false;
	}
	var title=document.form1.title.value;
	if(title=="")
	{
	alert("Please enter the content.");
	document.form1.title.focus();
	return false;
	}
}
function video_selection(value)
{
	if(value==1)
	{
	window.location='\addpic';
	}
	else if(value==2)
	{
	window.location='\addvideo';
	}
}
var return_value=1;
function settilldate(divname,no_val)
{
	//var tentitive = document.getElementById(divname).checked;
	if(no_val==return_value)
	{
		if(document.getElementById(divname).style.display == 'block')
		{
			document.getElementById(divname).style.display ="none";

		}
		else
		{
			document.getElementById(divname).style.display ="block";
		}
		return return_value=0;
	}
	else{
		//alert("no");
		if(document.getElementById(divname).style.display == 'none')
		{
			document.getElementById(divname).style.display ="block";
		}
		else
		{
			document.getElementById(divname).style.display ="none";
		}
	}
} 
/* damu  for profile eidt laod content 
var return_value=1;
function showandhide(updatediv,no_val,url)
{
	alert("da");
	//var tentitive = document.getElementById(updatediv).checked;
	if(no_val==return_value)
	{
		if(document.getElementById(updatediv).style.display == 'block')
		{
			document.getElementById(updatediv).style.display ="none";

		}
		else
		{
			document.getElementById(updatediv).style.display ="block";
			loadjforms(url,updatediv);
		}
		return return_value=0;
	}
	else{
		//alert("no");
		if(document.getElementById(updatediv).style.display == 'none')
		{
			document.getElementById(updatediv).style.display ="block";
			loadjforms(url,updatediv);
		}
		else
		{
			document.getElementById(updatediv).innerHTML ="";
			document.getElementById(updatediv).style.display ="none";
			
		}
	}
} */

function delete_conent(loading,url,updatediv)
{
	if(window.confirm("Are you sure you want delete"))
	{
		loadinnerjforms(loading,url,updatediv);
	}
	else
	{
		return;
	}
}
function prof_delete_conent(loading,url,updatediv)
{
	if(window.confirm("Do you want to delete this record from your professional information?"))
	{
		loadinnerjforms(loading,url,updatediv);
	}
	else
	{
		return;
	}
}
function sci_delete_conent(loading,url,updatediv)
{
	if(window.confirm("Do you want to delete this record from your scientific information?"))
	{
		loadinnerjforms(loading,url,updatediv);
	}
	else
	{
		return;
	}
}
function contact_delete_conent(loading,url,updatediv)
{
	if(window.confirm("Do you want to delete this record from your contact information?"))
	{
		loadinnerjforms(loading,url,updatediv);
	}
	else
	{
		return;
	}
}