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);
					}
					});
					document.getElementById('delete_enable').style.display ="none";
					document.getElementById('delete_disable').style.display ="block";
			}
		}
		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);
					}
					});
					document.getElementById('delete_enable').style.display ="none";
					document.getElementById('delete_disable').style.display ="block";
			}
		}
}
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;
	}
}


/* Add New 26-08-2010 */

function loadjforms(url,divname)
{
	url = Url.encode(url);
	document.getElementById(divname).innerHTML =" ";
	document.getElementById(divname).innerHTML = "<div style='width: 100%; text-align: center'><img src='"+httpurl+"img/loading.gif' style='margin-top: 62px;margin-bottom: 56px' alt='Loading'></div>";
		$.ajax({
		url: httpurl+url,
		cache: false,
		data: "param=value",
		success: function(html){
		//document.getElementById(divname).style.display = "none";
		document.getElementById(divname).innerHTML ="";
/*		for(i=10;i<=10;i++)
		{
		$("#"+divname).animate({opacity: "0."+i}, "slow");
		}*/
		//$("#"+divname).animate({opacity: "1"}, "slow");
		//$("#"+divname).animate({opacity: "show"}, "slow");	
		$('#'+divname) .html(html);
		}
		});
}

 var return_value=1;
 function showandhide(updatediv,no_val,url)
{
	//var tentitive = document.getElementById(updatediv).checked;
	//alert(url);
	if(no_val==return_value)
	{
		if(document.getElementById(updatediv).style.display == 'block')
		{
			//document.getElementById(updatediv).style.display ="none";
			$("#"+updatediv).slideUp("slow");
			document.getElementById(updatediv+"_up").innerHTML = "<img src='"+httpurl+"img/edit_arrow.gif' border='0' style='padding: 5px 10px 0px 0px; float: left;'>";

		}
		else
		{
			//alert("ok");
			document.getElementById(updatediv).style.display ="block";
			document.getElementById(updatediv+"_up").innerHTML = "<img src='"+httpurl+"img/up.gif' border='0' style='padding: 5px 10px 0px 0px; float: left;' >";
			loadjforms(url,updatediv);
		}
		return return_value=0;
	}
	else{
		//alert("no");
		if(document.getElementById(updatediv).style.display == 'none')
		{
			document.getElementById(updatediv).style.display ="block";
			document.getElementById(updatediv+"_up").innerHTML = "<img src='"+httpurl+"img/up.gif' border='0' style='padding: 5px 10px 0px 0px; float: left;'>";
			loadjforms(url,updatediv);
		}
		else
		{
			$("#"+updatediv).slideUp("slow");
			document.getElementById(updatediv).innerHTML ="";
			//document.getElementById(updatediv).style.display ="none";
			document.getElementById(updatediv+"_up").innerHTML = "<img src='"+httpurl+"img/edit_arrow.gif' border='0' style='padding: 5px 10px 0px 0px; float: left;'>";
			
		}
	}
}
function edit_submit(div_name,post_value,post_url)
{
	showandhide(div_name,post_value,post_url);
}

	function alphanumericOnlyNew(val,restrictChars){  // allow only letters and numbers  and space
  		if(restrictChars=='')			
			illegalChars= /[\`\~\!\@\#\$\%\^\&\*\(\)\_\-\+\=\{\}\<\>\|\'\,\.\?\/\;\:\\\"\[\]]/;
		else 
			illegalChars = restrictChars;
		
		if(illegalChars.test(val) ){  		 
			return false;
		}	  	
	 }  

/* End Add New 26-08-2010 */

	function onAJaxSubmit(loading_div,loading_image,divid,url,cache,type,data,success_fn){ 			
		
		if(loading_div!=''){
				var loading_image='';
				loading_image!='' ? loading_image = loading_image : loading_image ='loading.gif';				
				document.getElementById(loading_div).style.display ='block';
				document.getElementById(loading_div).innerHTML = "<div style='width: 100%; text-align: center'><img src='../image/"+loading_image +" style='margin-top: 62px;margin-bottom: 56px' alt='Loading'></div>";
		}
		if(url!=''){
			
			 cache!='' ? cache = cache : cache = false;
			 type!='' ? type = type : type = 'GET';
			 data!='' ? data = data : data = "param=value";
			
			 //alert("loading_div :" + loading_div + "\n  loading_image : "+  loading_image  + "\n  divid : "+  divid + " \n URL : "+  url +   "\n  cache : "+  cache + " \n type : "+  type +    " \n data : "+  data +    " \n success_fn : "+  success_fn );
			
			if(divid!=''){
				if(document.getElementById(divid).style.display =='none')
				document.getElementById(divid).style.display ='block';
			}
			
			$.ajax({
				url:  url,
				type: type,
				cache: cache,
				data: data,	
				success:  function(html){ 
						  	if(loading_div!=''){
								document.getElementById(loading_div).innerHTML = "";
								document.getElementById(loading_div).style.display ='none';
							}
								
							if(success_fn!=""){
								success_fn(html,divid);
							} else {  
								$("#"+divid).html(html).animate({opacity: "9.7"}, "slow");
							}						
						}// end success
			});
		} // end  if(url!='')
	}

