/*
function hidestatus(){
	window.status=''
	return true
}
if (document.layers){
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
	document.onmouseover=hidestatus
	document.onmouseout=hidestatus
}*/
//----------------------------------------------------------------- Find Friend Page 2
function checkAll(field){
	for (i = 0; i < field.length; i++)
		field[i].checked = true ;
}
function uncheckAll(field){
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
}
//----------------------------------------------------------------- MailBox Page
function checkMailCompose(){
	if(document.msg.to.value == 'nothing'){
		alert('No To?');
		document.msg.to.focus();
		return false;
	}
	if(document.msg.subject.value == ''){
		alert('No Subject?');
		document.msg.subject.focus();
		return false;
	}
	if(document.msg.message.value == ''){
		alert('No message?');
		document.msg.message.focus();
		return false;
	}
	return true;
}
//----------------------------------------------------------------- Feedback Page
function checkFeedback(){
	if(document.add.feedback_firstname.value == ""){
		alert("First Name is missing");
		document.add.feedback_firstname.focus();
		return false;
	}
	if(document.add.feedback_lastname.value == ""){
		alert("Last Name is missing");
		document.add.feedback_lastname.focus();
		return false;
	}
	if(document.add.feedback_lastname.value == ""){
		alert("Last Name is missing");
		document.add.feedback_lastname.focus();
		return false;
	}
	if(document.add.feedback_email.value == ""){
		alert("E-Mail Address Missing");
		document.add.feedback_email.focus();
		return false;
	}
	if(!isEmailAddr(document.add.feedback_email.value)){
		alert("Please provide correct email address in the form: yourname@yourdomain.com");
		document.add.feedback_email.focus();
		return false;
	}
	if(document.add.feedback_description.value == ""){
		alert("Your Message is missing. Please provide your message");
		document.add.feedback_description.focus();
		return false;
	}
}
//----------------------------------------------------------------- Contact Us Page
function checkContactUs(){
	if(document.add.contact_firstname.value == ""){
		alert("First Name is missing");
		document.add.contact_firstname.focus();
		return false;
	}
	if(document.add.contact_lastname.value == ""){
		alert("Last Name is missing");
		document.add.contact_lastname.focus();
		return false;
	}if(document.add.contact_email.value == ""){
		alert("E-Mail Address Missing");
		document.add.contact_email.focus();
		return false;
	}
	if(!isEmailAddr(document.add.contact_email.value)){
		alert("Please provide correct email address in the form: yourname@yourdomain.com");
		document.add.contact_email.focus();
		return false;
	}
	if(document.add.contact_description.value == ""){
		alert("Your Message is missing. Please provide your message");
		document.add.contact_description.focus();
		return false;
	}
}
//----------------------------------------------------------------- Blog Page -->> Print Blog
function popblogprint(printpage) {
	var pURL=printpage;
	pInfo='toolbar=0,';
	pInfo+='location=0,';
	pInfo+='directories=0,';
	pInfo+='status=1,';
	pInfo+='menubar=0,';
	pInfo+='scrollbars=1,';
	pInfo+='resizable=1,';
	pInfo+='width=750,';
	pInfo+='height=500';
	window.open(pURL, 'bigPop', pInfo);
}
function hideing(divname){
	$(divname).style.visibility = 'hidden';
	$(divname).style.position='absolute';
}
function showing(divname){
	$(divname).style.visibility = 'visible';
	$(divname).style.position='static';
}
//----------------------------------------------------------------- Notice Board -->> Post Notice
function checkPostNotice(){
	if(document.add.notice_title.value == ""){
		alert("Notice Title Missing");
		document.add.notice_title.focus();
		return false;
	}
	if(document.add.notice_description.value == ""){
		alert("Notice Description Missing");
		document.add.notice_description.focus();
		return false;
	}
	if(document.add.notice_startdate.value == ""){
		alert("Notice Start date Missing");
		document.add.notice_startdate.focus();
		return false;
	}
	if(document.add.notice_enddate.value == ""){
		alert("Notice End date Missing");
		document.add.notice_enddate.focus();
		return false;
	}
	if(document.add.notice_startdate.value > document.add.notice_enddate.value){
		alert("End date should came after Start date");
		document.add.notice_startdate.focus();
		return false;
	}
}
function checkPostNoticeEdit(){
	if(document.add.notice_title.value == ""){
		alert("Notice Title Missing");
		document.add.notice_title.focus();
		return false;
	}
	if(document.add.notice_description.value == ""){
		alert("Notice Description Missing");
		document.add.notice_description.focus();
		return false;
	}
	if(document.add.notice_startdate.value == ""){
		alert("Notice Start date Missing");
		document.add.notice_startdate.focus();
		return false;
	}
	if(document.add.notice_enddate.value == ""){
		alert("Notice End date Missing");
		document.add.notice_enddate.focus();
		return false;
	}
	if(document.add.notice_startdate.value > document.add.notice_enddate.value){
		alert("End date should came after Start date");
		document.add.notice_startdate.focus();
		return false;
	}
}
//----------------------------------------------------------------- Profile Page
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) selObj.selectedIndex=0;
}
//----------------------------------------------------------------- Profile Page -->> Edit Summary -->> Cities List -->>auto_suj()

//----------------------------------------------------------------- Profile Page -->> Edit Summary -->> checkSummary()
function checkSummary(){
	if(document.edit.member_login.value == ""){
		alert("Screen Name field is empty.");
		document.edit.member_login.focus();
		return false;
	}
	if(document.edit.member_firstname.value == ""){
		alert("First name field is empty.");
		document.edit.member_firstname.focus();
		return false;
	}
	if(document.edit.member_lastname.value == ""){
		alert("Last name field is empty.");
		document.edit.member_lastname.focus();
		return false;
	}
	if(document.edit.members_profile_birthmonth.value == "nothing"){
		alert("Please Select Correct Month");
		document.edit.members_profile_birthmonth.focus();
		return false;
	}
	if(document.edit.members_profile_birthdate.value == "nothing"){
		alert("Please Select Correct Date");
		document.edit.members_profile_birthdate.focus();
		return false;
	}
	if(document.edit.members_profile_birthyear.value == "nothing"){
		alert("Please Select Correct Year");
		document.edit.members_profile_birthyear.focus();
		return false;
	}
	if(document.edit.members_profile_country.value == "nothing"){
		alert("Please Select Correct Country");
		document.edit.members_profile_country.focus();
		return false;
	}
}
//----------------------------------------------------------------- Profile Photo Page -->> displayPicCheck()
function displayPicCheck(){
	if(document.edit.member_photo_path.value == ""){
		alert("Please select an image to upload");
		document.edit.member_photo_path.focus();
		return false;
	}
	if(document.edit.member_photo_path.value != ""){
		val = document.edit.member_photo_path.value.substring(document.edit.member_photo_path.value.length-4,document.edit.member_photo_path.value.length);
		val = val.toLowerCase();
		if ((val!='.jpg') && (val!='.png') && (val!='.gif') && (val!='.jpeg')){
			alert ('Please upload JPG, PNG, or GIF images only');
			document.edit.member_photo_path.focus();
			return false;
		}
	}
}
//----------------------------------------------------------------- Community Page -->> checkCreateCommunity()
function checkCreateCommunity(){
	if(document.add.community_name.value == ""){
		alert("Name not given.");
		document.add.community_name.focus();
		return false;
	}
	if(document.add.community_category.value == "nothing"){
		alert("Category not given.");
		document.add.community_category.focus();
		return false;
	}
	if(document.add.community_group_pic.value == ""){
		alert("Please select an image to upload");
		document.add.community_group_pic.focus();
		return false;
	}
	if(document.add.community_group_pic.value != ""){
		val = document.add.community_group_pic.value.substring(document.add.community_group_pic.value.length-4,document.add.community_group_pic.value.length);
		val = val.toLowerCase();
		if ((val!='.jpg') && (val!='.png') && (val!='.gif') && (val!='.jpeg')){
			alert ('Please upload JPG, PNG, or GIF images only');
			document.add.community_group_pic.focus();
			return false;
		}
	}
	if(document.add.community_group_description.value == ""){
		alert("Description not given.");
		document.add.community_group_description.focus();
		return false;
	}
}
//----------------------------------------------------------------- Community Page -->> checkEditCommunity()
function checkEditCommunity(){
	if(document.add.community_name.value == ""){
		alert("Name not given.");
		document.add.community_name.focus();
		return false;
	}
	if(document.add.community_category.value == "nothing"){
		alert("Category not given.");
		document.add.community_category.focus();
		return false;
	}
	if(document.add.community_group_pic.value != ""){
		val = document.add.community_group_pic.value.substring(document.add.community_group_pic.value.length-4,document.add.community_group_pic.value.length);
		val = val.toLowerCase();
		if ((val!='.jpg') && (val!='.png') && (val!='.gif') && (val!='.jpeg')){
			alert ('Please upload JPG, PNG, or GIF images only');
			document.add.community_group_pic.focus();
			return false;
		}
	}
	if(document.add.community_group_description.value == ""){
		alert("Description not given.");
		document.add.community_group_description.focus();
		return false;
	}
}
//----------------------------------------------------------------- Friends Page -->> fan(friend_id, num, status)
function fan(friend_id, num, status){
	$('fan'+num).style.visibility="hidden";
	$('loadingfan'+num).innerHTML = '<img src="images/loading.gif" alt="" />';
	new Ajax.Updater('fan'+num, 'fanstatus.php?friend_id='+friend_id+'&status='+status+'&num='+num, {asynchronous:true,onComplete:function(){
	$('loadingfan'+num).innerHTML = '';
	$('fan'+num).style.visibility="visible";
	}});
}
//----------------------------------------------------------------- Edit Community Page -->> myWin(name)
function myWin(name){
	windowHandle = window.open('pic.php?n='+name,'UserPicture','height=130,width=250,screenX=10,screenY=10,top=10,left=150');
	windowHandle.focus();
}
//----------------------------------------------------------------- Scrapbook Page -->> Instance Reply Section
var ReplyObj=null;
function ScrapReply(user_id,mem_id,row,Fnct){
	if(Fnct=="canc"){
		document.getElementById('repfld'+user_id+row).innerHTML="";
		document.getElementById('edit'+user_id+row).style.display='inline';
		return;
	}else if(Fnct=="rep"){
		var fobj=document.forms['replyscrap'];
		var scrapfrm=user_id;
		var scrapto=mem_id;
		if(fobj.elements['reply_text'+scrapto].value!=""){
			var str=GetFrmElements(fobj);
			var url="postreply.php?text="+str+"&scrapto="+scrapto+"&scrapfrm="+scrapfrm+"&row="+row;
			
			ReplyObj=GetXmlHttpObject();
			if(ReplyObj==null){
				alert("Your Browser Is not supported");
				return;
			}
			ReplyObj.onreadystatechange=StateChangePostRply;
		}else{
			document.getElementById('error'+user_id+row).innerHTML="&nbsp;<b>Error:</b> You Cannot Post An Empty Scrap!&nbsp;";
			var t=setTimeout("AutoHide("+user_id+","+row+",'error')",5000);
			return;
		}
	}
	else{
		var scrapto=user_id;
		var scrapfrm=mem_id;
		var url="reply.php?scrapto="+scrapto+"&scrapfrm="+scrapfrm+"&row="+row;
		
		ReplyObj=GetXmlHttpObject();
		if(ReplyObj==null){
			alert("Your Browser Is not supported");
			return;
		}
		ReplyObj.onreadystatechange=StateChangeRply;
	}
	ReplyObj.open("GET",url,true);
	ReplyObj.send(null);
}
function AutoHide(user_id,row,txt){
	document.getElementById(txt+user_id+row).innerHTML="";
}
function StateChangePostRply(){
	if(ReplyObj.readyState==4){
		if(ReplyObj.status==200){
			var result=ReplyObj.responseText
			result=result.split("|");
			var user_id=result[0];
			var row=result[1];
			var btnid="mclose"+row;
			var btn="<input type='button' value='' class='button_closereplyscrap' title='Close' id="+btnid+" class='button' onclick='javascript:closebtn("+row+","+user_id+");' />";
			document.getElementById('repfld'+user_id+row).innerHTML="";
			document.getElementById('edit'+user_id+row).style.display='inline';
			document.getElementById('msg'+user_id+row).innerHTML="&nbsp;<b>Success!</b> Your message was successfully sent."+"&nbsp;"+btn;
			var t=setTimeout("AutoHide("+user_id+","+row+",'msg')",5000);
		}
	}
}
function closebtn(rowid,user_id){
	document.getElementById('msg'+user_id+rowid).innerHTML="";
}
function StateChangeRply(){
	if(ReplyObj.readyState==4){
		if(ReplyObj.status==200){
			var row;
			var scrapto;
			var scrapfrm;
			var divdata;
			var piped=ReplyObj.responseText;
			var scrapfields = piped.split("|");
			for(var o=0; o<scrapfields.length; o++){
				if(o==0){
					row=scrapfields[o];
				}else if(o==1){
					scrapto=scrapfields[o];
				}else if(o==2){
					scrapfrm=scrapfields[o];
				}else if(o==3){
					divdata=scrapfields[o];
				}
			}
			document.getElementById('edit'+scrapto+row).style.display='none';
			document.getElementById('repfld'+scrapto+row).innerHTML=divdata;
		}
	}
}
function GetFrmElements(fobj){
	var str="";
	for(var i=0; i<fobj.elements.length;i++){
		switch(fobj.elements[i].type){
			case "textarea":
				str=fobj.elements[i].value;
			break;
		}
	}
	return str;
}
//----------------------------------------------------------------- Function previewScrap() -->
function previewScrap(status){
	if(status!=""){
		param_new = 'status='+status;
		$('previewScrapWritten').style.visibility="hidden";
		$('previewScraploader').innerHTML = '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" alt="" />';
		new Ajax.Updater('previewScrapWritten', 'previewscrap.php', {method:'post',parameters:param_new,asynchronous:true,onComplete:function(){
		$('previewScraploader').innerHTML = '';
		$('AddPicture').innerHTML = '';
		$('previewScrapWritten').style.visibility="visible";
		}});
	}else{
		window.document.scarps.scrap_message.focus();
	}
}
//----------------------------------------------------------------- Function addpic() -->
function addpic(){
	$('previewScrapWritten').innerHTML = '';
	$('AddVideo').innerHTML = '';
	$('AddPicture').style.visibility="hidden";
	$('AddPictureloader').innerHTML = '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" alt="" />';
	new Ajax.Updater('AddPicture', 'addphoto.php', {method:'post',asynchronous:true,onComplete:function(){
		$('AddPictureloader').innerHTML = '';
		$('AddPicture').style.visibility="visible";
		}});
}
//----------------------------------------------------------------- Function addvideo() -->
function addvideo(){
	$('AddPicture').innerHTML = '';
	$('previewScrapWritten').innerHTML = '';
	$('AddVideo').style.visibility="hidden";
	$('AddVideoloader').innerHTML = '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" alt="" />';
	new Ajax.Updater('AddVideo', 'addvideo.php', {method:'post',asynchronous:true,onComplete:function(){
		$('AddVideoloader').innerHTML = '';
		$('AddVideo').style.visibility="visible";
		}});
}
//----------------------------------------------------------------- Video Page -->> Rate Video
function rateVideo(rating,videoid,memberid){
	$('rate').style.visibility="hidden";
	$('ratestatus').innerHTML = '<img src="images/loading.gif" alt="" />';
	new Ajax.Updater('rate', 'videorate.php?video_id='+videoid+'&rate='+rating+'&memberid='+memberid, {asynchronous:true,onComplete:function(){
	$('ratestatus').innerHTML = '';
	$('rate').style.visibility="visible";
	}});
}
//----------------------------------------------------------------- Video Page -->> Favourate Video
function favVideo(videoid,memberid){
	$('fav').style.visibility="hidden";
	$('favstatus').innerHTML = '<img src="images/loading.gif" alt="" />';
	new Ajax.Updater('fav', 'videofav.php?video_id='+videoid+'&m_id='+memberid, {asynchronous:true,onComplete:function(){
	$('favstatus').innerHTML = '';
	$('fav').style.visibility="visible";
	}});
}
//----------------------------------------------------------------- Video Page -->> Comments Video
function commentsAdd(comments,member_id,video_id){
	if(comments!=""){
		param_new = 'comments='+comments+'&member_id='+member_id+'&video_id='+video_id;
		$('CommentsUpdate').style.visibility="hidden";
		$('CommentsUpdateLoader').innerHTML = '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" alt="" />';
		new Ajax.Updater('CommentsUpdate', 'commentsupdate.php', {method:'post',parameters:param_new,asynchronous:true,onComplete:function(){
			$('CommentsUpdateLoader').innerHTML = '';
			$('CommentsUpdate').style.visibility="visible";
			}});
	}
	else{
		window.document.getElementById('videocomments_description').focus();
	}
}
//----------------------------------------------------------------- Blog Page -->> Blog Video
function commentBlogAdd(fobj,member_id,adminblog_id){
	var comments = fobj.elements['comments_description'].value;
	if(comments!=""){
		param_new = 'comments='+comments+'&member_id='+member_id+'&adminblog_id='+adminblog_id;
		$('CommentBlog').style.visibility="hidden";
		$('CommentBlogLoader').innerHTML = '<img src="images/loading.gif" alt="" />';
		new Ajax.Updater('CommentBlog', 'commentblogupdate.php', {method:'post',parameters:param_new,asynchronous:true,onComplete:function(){
			$('CommentBlogLoader').innerHTML = '';
			$('CommentBlog').style.visibility="visible";
			}});
	}
	else{
		fobj.elements['comments_description'].focus();
	}
}

var videoObject=null;
function UpdateVideo(fobj,videoId,spno){
	var v_title=fobj.elements['video_title'+videoId].value;
	var v_description=fobj.elements['video_description'+videoId].value;
	var v_id=videoId;
	if(v_id!=""){
		videoObject=GetXmlHttpObject();
		if(videoObject==null){
			alert("Please Update Your Browser");
			return;
		}
		var url="videoupdate.php?v_id="+v_id+"&v_description="+v_description+"&v_title="+v_title+"&spno="+spno;
		videoObject.onreadystatechange=StateChangeUpVd;
		videoObject.open("GET",url,true);
		videoObject.send(null);
	}
	else{
		fobj.elements['video_title'+videoId].focus();
	}
}
function StateChangeUpVd(){
	if(videoObject.readyState==4){
		if(videoObject.status==200){
			var str=videoObject.responseText;
			var spno;
			var vid;
			var divdata;
			var prtnostr = str;
			var partar = prtnostr.split("*");
			for(var o=1; o<partar.length; o++){
				if(o==1){
					spno=partar[o];
				}else if((o==2)){
					 vid=partar[o];
				}else{
					divdata=partar[o];
				}
			}
			document.getElementById('video_title'+vid).style.display='none';
			document.getElementById('video_description'+vid).style.display='none';
			document.getElementById('Submit'+vid).style.display='none';
			document.getElementById('VideoUpdate'+spno).innerHTML=divdata;
		}
	}
}
var xmlHttpShowProperties;
var v_id;
function UpdateVideoDescription(v_id,rownumber){
	xmlHttpShowProperties=GetXmlHttpObject();
	if (xmlHttpShowProperties==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	newidassign = "VideoUpdate"+rownumber;
	var url="videoedit.php?video_id="+v_id+"&spno="+rownumber;
	xmlHttpShowProperties.onreadystatechange=EditVideo;
	xmlHttpShowProperties.open("GET",url,true);
	xmlHttpShowProperties.send(null);
}
function EditVideo(){ 
	if (xmlHttpShowProperties.readyState==4 ){
		if(xmlHttpShowProperties.status==200){			
			document.getElementById(newidassign).innerHTML=xmlHttpShowProperties.responseText;
		}
	}
}
//----------------------------------------------- Getting XmlHttp Object
function GetXmlHttpObject(){
	var objXMLHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		objXMLHttp=new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer
		try{
			objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			try{
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return objXMLHttp;
}
function CautionFriendDelete(friend_firstname,friend_lastname,friend_id){
	answer = window.confirm("Are you sure you want to delete your Friend "+friend_firstname+" "+friend_lastname+"?");
	if(answer == true){
		location.replace("friends.php?del="+friend_id);
	}
}
function isEmailAddr(email){
	var result = false
	var theStr = new String(email)
	var index = theStr.indexOf("@");
	if (index > 0){
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}
function MM_openBrWindow(theURL,winName,type_features) {
	window.open(theURL,winName,type_features);
}