// JavaScript Document
/*  *//////////////////////////////
function refrech()
{
    MembersBar();
}

/*  *//////////////////////////////
/*
function SearchMapLoction()
{
	var opt = {
		method:'post', 
		postBody:'action=showMapLoc&'+ Form.serialize('search_map_form'),
		onSuccess: function(t) { 
		    //var data = t.responseText.split("|");
			//$('title').innerHTML = data[0];
			$('maps').innerHTML = t.responseText;
		},
		onLoading: function() {  
		    $('maps').innerHTML = '<div class="show-load"></div>';
		}
	}

	new Ajax.Request('libraries/comajax.php', opt);
}
*/

/* *//////////////////////////////
function showFullOnline(index)
{
	var opt = {
		method:'post', 
		postBody:'action=onlineMembersFull&index='+index,
		onSuccess: function(t) { 
		    var data = t.responseText.split("|");
			$('online_title').innerHTML = data[0];
			$('online_list').innerHTML = data[1];
		},
		onLoading: function() {  
		    $('online_list').innerHTML = '<div class="show-load"></div>';
		}
	}

	new Ajax.Request('libraries/comajax.php', opt);
}
/* *//////////////////////////////
function showOnline(index)
{
	var opt = {
		method:'post', 
		postBody:'action=onlineMembers&index='+index,
		onSuccess: function(t) { 
			$('mlist').innerHTML = t.responseText;
		},
		onLoading: function() {  
		    $('mlist').innerHTML = '<div class="show-load-small"></div>';
		}
	}

	new Ajax.Request('libraries/comajax.php', opt);
}
/*  *//////////////////////////////
function showPhotoFull(pid)
{
   	var opt = {
		method:'post', 
		postBody:'action=displayFullPhoto&id=' + pid ,
		onSuccess: function(t) {
			Element.hide('fullscreen');
			$('fullscreen').innerHTML = t.responseText;
			Modalbox.show($('fullscreen'), {title:'Photo', width:'800', height:'600'});
		},
		onLoading: function() {	}
	}
	new Ajax.Request('libraries/comajax.php', opt);	

}

/*  *//////////////////////////////
function hidePanelMessage()
{
  Element.hide('PanelMessage');	
}

/* User Sign Out Account*//////////////////////////////
function signout()
{
	var opt = {
		method:'post', 
		postBody:'action=signout',
		onSuccess: function (t) {
		   window.location = 'main.php';
		},
		onLoading: function() {  }
	}

	new Ajax.Request('libraries/comajax.php', opt);  
}

/* Loading Members Status Bar *///////////////////////////////
function MembersBar()
{ 
	var opt = {
		method:'post', 
		postBody:'action=memberbar',
		asynchronous:true, 
		frequency: 100, //l00 seconds
		onSuccess: function(t) {
			if(t.responseText == 0)
			  window.location = "main.php";
			else { 
			  $('BarLeft').innerHTML = t.responseText;
			  Element.show('BarLeft');
			}
		},
		onLoading: function() {}
	}
	new Ajax.PeriodicalUpdater('BarLeft', 'libraries/comajax.php', opt);	
}	
/*  *//////////////////////////////
function addComment(fid,uid,type)
{
	 var myText = tinyMCE.activeEditor.getContent().replace(/\+/g, "&#43");
	 myText = myText.replace(/\\/g, "&#92");
	 myText = escape(myText);
	 
	 if (myText == ''){
		 return;
	 }
     var opt = {
		method:'post', 
		postBody:'action=addComment&id=' + fid + '&uid=' + uid + '&type=' + type + '&comment=' + myText,
		onSuccess: function(t) { 
			$('ucomment').innerHTML =t.responseText; 
			tinyMCE.execCommand("mceSetContent",false,'');
		},
		onLoading: function() { 
			$('ucomment').innerHTML ='<div class="show-load-small"></div>'; 
		}
	 }
	 new Ajax.Request('libraries/comajax.php', opt);
	 
}
/*  *//////////////////////////////
function delComment(fid,uid,type)
{	   
	   var opt = {
			method:'post', 
			postBody:'action=delComment&id=' + fid + '&uid=' + uid + '&type=' + type ,
			onSuccess: function(t) { 
			    Effect.Fade('user_comment_' + fid);
				$('comment_title').innerHTML = '<h2>Comments</h2>';
			},
			onLoading: function() {}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}

/*  *//////////////////////////////
function addFav(id,uid,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=addFav&id=' + id + '&uid=' + uid + '&type=' + type,
			onSuccess: function(t) { 
			    $('favorites' + id).innerHTML =  t.responseText;
				Effect.Highlight('favorites' + id);
			},
			onLoading: function() { }
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}
/*  *//////////////////////////////
function delFav(id,uid,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=delFav&id=' + id + '&uid=' + uid + '&type=' + type,
			onSuccess: function(t) { 
			    $('favorites' + id).innerHTML = t.responseText; 
				Effect.Highlight('favorites' + id);
			},
			onLoading: function() {}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}
/*  *//////////////////////////////
function rating(ncount,id,uid,units,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=rating&j=' + ncount + '&q=' + id + '&t=' + uid + '&c=' + units + '&type=' + type,
			onSuccess: function(t) { 
			    $('RatingBox_' + id).innerHTML = t.responseText;
			},
			onLoading: function() { 
			   $('RatingBox').innerHTML = '<div class="rate-load"></div>';
			}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}

/*  *//////////////////////////////

function loadViewType(type)
{
	if (type == 'MemberPhoto') MemberPhoto(0,0,$F('select_type'),0,0);
    else if (type == 'MemberStory') MemberStory(0,0,$F('select_type'));
    else if (type == 'MemberVideo') MemberVideo(0,0,$F('select_type'),0,0);  
	else if (type == 'MemberLink') MemberLink(0,0,$F('select_type'));  
	else if (type == 'MemberProfile') MemberProfile(0,0,0,0,$F('select_type'));
	else if (type == 'Gallery') Gallery(0,0,$F('select_type'));
}

/*  *//////////////////////////////
function showCommentPage(page,type,id,uid)
{
	   var opt = {
			method:'post', 
			postBody:'action=showCommentPage&page=' + page + '&type=' + type + '&id=' + id  + '&uid=' + uid,
			onSuccess: function(t) { 
				$('comment_list').innerHTML = t.responseText; 
			},
			onLoading: function() { 
			    $('comment_list').innerHTML = '<div class="show-load-small"></div>';
			}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}

/*  *//////////////////////////////
function postReply(id,pid,type)
{
	/*
	var myText = tinyMCE.activeEditor.getContent().replace(/\+/g, "&#43");
	myText = myText.replace(/\\/g, "&#92");
	myText = myText.replace(/'/g, "&#39");
	myText = escape(myText);

	if (myText == ''){
	   return;
	}
*/
	var opt = {
		method:'post', 
		postBody:'action=postReply&id=' + id + '&pid=' + id + '&type=' + type + '&con=' + $F('reply_' + id) + '&' + Form.serialize('post_reply_form_' + id),
		onSuccess: function(t) {  
		  $('postreply').innerHTML = t.responseText;
	//	  tinyMCE.activeEditor.setContent('');
		},
		onLoading: function() {	
		  $('postreply').innerHTML = '<div class="show-load"></div>';
		}
	}
	new Ajax.Request('libraries/comajax.php', opt);	

}
/*  *//////////////////////////////
function deleteReply(id,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=deleteReply&id=' + id + '&type=' + type ,
			onSuccess: function(t) { 
			     Effect.Fade('reply_' + id);
			},
			onLoading: function() { 
			}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}

/*  *//////////////////////////////
function showReply(page,id,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=showReply&page=' + page + '&id=' + id + '&type=' + type,
			onSuccess: function(t) { 
				$('postreply').innerHTML = t.responseText; 
			},
			onLoading: function() { 
			    $('postreply').innerHTML = '<div class="show-load-small"></div>';
			}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}
/* Refresh load country *//////////////////////////////
function loadRegion(t)
{
	   var opt = {
			method:'post', 
			postBody:'action=loadCountry&cid=' + t.value,
			onSuccess: function(t) {  			   
			    $('dcountry').innerHTML = t.responseText;
				$('dstates').innerHTML = '';
			},
			onLoading: function() {  }
		}
		new Ajax.Request('libraries/myspaceajax.php', opt);	
}
/*  *//////////////////////////////
function loadStates(t,type)
{
	   var opt = {
			method:'post', 
			postBody:'action=loadState&cid=' + t.value + '&type=' + type,
			onSuccess: function(t) {  	
			    var data = t.responseText.split("|");
			    $('dstates').innerHTML = data[0];
				$('ca').innerHTML = data[1];
			},
			onLoading: function() {  }
		}
		new Ajax.Request('libraries/myspaceajax.php', opt);	
}
/*  *//////////////////////////////
function loadCity(v,type)
{

	   var opt = {
			method:'post', 
			postBody:'action=loadCity&pid=' + v.value + '&type=' + type,
			onSuccess: function(t) {  		
			    $('dcity').innerHTML = t.responseText;
			},
			onLoading: function() {  }
		}
		new Ajax.Request('libraries/myspaceajax.php', opt);	
}
/*  *//////////////////////////////
function editorSetup(simple)
{
	if (simple){
		 tinyMCE.init({
			mode : "textareas",
			theme : "advanced", 
			width: "470",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",	
			theme_advanced_buttons1 : "bold,italic,underline",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : ""
		 });
	}
	else {
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			width: "480",
			height: "300", 
			theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,outdent,indent,separator,undo,redo,link,unlink,separator,image,code",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,
			extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
		});
	}
}
/*  *///////////////////////////////
function selectedAll(check_all_box, obj_set_name)
{
	var selection_status = check_all_box.checked;
    var checkboxes = document.getElementsByName(obj_set_name);
    var total_boxes = checkboxes.length;
	
	if(selection_status == false)
	{  
		for(i=0; i<total_boxes; i++)
		{
			current_value = checkboxes[i].checked;
			
			if(current_value == true)
			{
				checkboxes[i].checked = false;
			}
		}
	}
	else
	{
		for(i=0; i<total_boxes; i++)
		{
			current_value = checkboxes[i].checked;
			
			if(current_value == false)
			{
				checkboxes[i].checked = true;
			}
		}
	}
}
/*  *//////////////////////////////
function verifyCode(id,type)
{
	   if ($F('code' + type) == '') return;
	   
	   var opt = {
			method:'post', 
			postBody:'action=verifyCode&id=' + id + '&code=' + $F('code' + type) + '&type=' + type,
			onSuccess: function(t) {  	
			   var data = t.responseText.split("|");
			   if (data[0] == 1) viewPrivate(id,type);
			   if (data[0] == 0) $('code' + type).value = data[1];
			},
			onLoading: function() { 
			  //$F('code' + type).value = 'verify code ...';
			}
		}
		new Ajax.Request('libraries/comajax.php', opt);	
}
