function emptyMessageBox(id)
{
	document.getElementById(id).value = "";
}
function redirectPage()
  {
	setTimeout("location.href='/'", 2000);
  }



function addPhoto(txtPhotoCount)
{
	var idDivPhoto;
	if(document.getElementById(txtPhotoCount).value < 10)
	{
		idDivPhoto = parseInt(document.getElementById(txtPhotoCount).value) + 1;
		document.getElementById(txtPhotoCount).value = idDivPhoto;
		document.getElementById("divPhoto" + idDivPhoto).style.display = "";
	}
	if(document.getElementById(txtPhotoCount).value == 10)
	{
		document.getElementById("divAddPhoto").style.display = "none";
	}
}

function targetUploadingPhoto()
{
	document.getElementById("photoLoader").style.display = "";
	document.getElementById('frmAddPhoto').target = 'frmAddPhoto_target'; //'frmAddPhoto_target' is the name of the iframe
}
function uplAlbumPhoto(txtPhotoCount)
{
	for(i=1; i<=parseInt(document.getElementById(txtPhotoCount).value);i++)
	{
		alert(document.getElementById("Photo" + i).value);	
	}
	
}

function deleteAlbum(rid,aid)
{
	if(confirm('Are you sure to delete the album and its all photos permanently?'))
	{
		window.location = "deleteAlbum.asp?rid="+ rid +"&aid="+ aid + ""	
	}
	else
	{
	}
}
function deleteownprofile(refuser,delete1,status)
{
	if(confirm('Are you sure to delete Your Accoount permanently? It will delete all your photos, videos, blogs, album etc!'))
	{
		window.location = "/membre/admin3.html?refuser="+ refuser +"&delete="+ delete1 +"&status="+status+"" 	
	}
	else
	{
	}
}


function deleteAlbumPhoto(rid,aid,pid)
{
	if(confirm('Are you sure to delete the photo permanently?'))
	{
		window.location = "deleteAlbumPhoto.asp?rid="+ rid +"&aid="+ aid +"&pid="+ pid +""	
	}
	else
	{
	}
}

function submitProfilePhoto()
{
	var c,str, msg, ext;
	c=0;
	str = document.form2.file.value;
	msg = "Please, check following fields:";
	
	i = str.lastIndexOf(".")
	ext = str.substring(i+1);

	if(document.getElementById("ckhAcceptTerms").checked)
	{
		
	}
	else
	{
		msg = msg + "\nAccept terms and conditions."
		c = 1;
	}
	if(str=="")
	{
		msg = msg + "\nBrowse your photo."
		c = 1;
	}
	else
	{
		if(ext=="jpg" || ext=="jpeg" || ext=="JPG" || ext=="JPEG" || ext=="GIF" || ext=="BMP")
		{
		}
		else
		{
			msg = msg + "\nOnly jpg, gif or bmp images can be uploaded.";
			c = 1;
		}
	}
	

	
	if(c>0)
	{
		alert(msg);	
		return false;
	}
	else
	{
		return true;
	}

}

function setSendFriendRequestRidProfile(rid,imgPath,typeRequest,nm)
{			
			//document.dlgForm.HDDrid.value = rid; 
			//document.getElementById('label').innerHTML = document.dlgForm.HDDrid.value;
			document.getElementById('tpid').value = rid;
			document.getElementById('sendFRimg').src = imgPath;
			document.getElementById('typeRequest').value = typeRequest;

			document.getElementById('sendFRnm1').innerHTML = nm;
			document.getElementById('sendFRnm2').innerHTML = nm;
} 

function setSendFriendRequestRid(rid,imgPath,typeRequest,nm)
{			
			//document.dlgForm.HDDrid.value = rid; 
			//document.getElementById('label').innerHTML = document.dlgForm.HDDrid.value;
			document.getElementById('tid').value = rid;
			document.getElementById('sendFRimg').src = imgPath;
			document.getElementById('typeRequest').value = typeRequest;

			document.getElementById('sendFRnm1').innerHTML = nm;
			document.getElementById('sendFRnm2').innerHTML = nm;
} 
function setSendAdvanceFriendRequestRid(rid,imgPath,curX,maxX,curSqlRequete,nm)
{
			//document.dlgForm.HDDrid.value = rid; 
			//document.getElementById('label').innerHTML = document.dlgForm.HDDrid.value;
			document.getElementById('tid').value = rid;
			document.getElementById('sendFRimg').src = imgPath;
			document.getElementById('curX').value = curX;
			document.getElementById('maxX').value = maxX;
			document.getElementById('curSqlRequete').value = curSqlRequete;
			
			document.getElementById('sendFRnm1').innerHTML = nm;
			document.getElementById('sendFRnm2').innerHTML = nm;
} 

function large(k)
{	
	document.getElementById('message' +k).style.display = "none";
	document.getElementById('small' + k).style.display = "none";
	document.getElementById('large' + k).style.display = "";
}
function small1(k)
{	

	document.getElementById('large' + k).style.display = "none";
	document.getElementById('small' + k).style.display = "";
	document.getElementById('message' + k).style.display = "none";
}	
function showmessage(k,i)
{
	for (j=0;j<=i;j++)
	{
		if(document.getElementById('message' + j))
		{
			document.getElementById('message' + j).style.display = "none";	
		}
	}  
	document.getElementById('message' + k).style.display = "";
}

function delMessage(m,fr,db,typ)
{
	if (confirm('Are you sure to delete all the messages permanently related to this threat?'))
	{
		//window.location = '/membre/deleteMessage.asp?m=' + m + '&forRefUser=' + fr + '&delBy=' + db + '&typ=' + typ + ''
		
		showData('deleteMessage.asp?m=' + m + '&forRefUser=' + fr + '&delBy=' + db + '&typ=' + typ + '','myInboxContent');
		if(typ == "i")
		{
			showData('divInbox.asp?asdf=44','myInboxContent');
		}
		if(typ == "o")
		{
			showData('divOutbox.asp?asdf=44','myInboxContent');
		}
	}
}

function delMF(rid,did,plr)
{
	if (confirm('Are you sure to delete history permanently?'))
	{
		showData('/membre/deleteMiniFeed.asp?rid='+ rid +'&did='+ did +'&plr='+ plr +'','myMiniFeedContent');
		showData('/membre/miniFeedInclude.asp?rid='+ rid +'&plr='+ plr +'','myMiniFeedContent');
	}
}

function delF(rid,frid,type)
{
	if (confirm('Are you sure to delete friend permanently?'))
	{
		window.location = "deleteFriend.asp?rid="+ rid +"&frid="+ frid + "&type="+ type +""	
	}
}

function delSelMessage(fr,db,typ)
{
		if (confirm('Are you sure to delete all the messages permanently?'))
		{
			var m, str, arrStr1;		
			//showData('deleteMessage.asp?m=' + m + '&forRefUser=' + fr + '&delBy=' + db + '&typ=' + typ + '','myInboxContent');
			str = ""
			str = document.getElementById("allMsgChkId").value;
			if (str.length > 0)
			{
				arrStr1 = str.split(";");
				for(i=0;i<=arrStr1.length-1;i++)
				{
					if(document.getElementById(arrStr1[i]).checked)
					{
						m = parseInt(arrStr1[i].replace("chk",""));
						showData('deleteMessage.asp?m=' + m + '&forRefUser=' + fr + '&delBy=' + db + '&typ=' + typ + '','myInboxContent');
					}
				}
				if(typ == "i")
				{
					showData('divInbox.asp?asdf=44','myInboxContent');
				}
				if(typ == "o")
				{
					showData('divOutbox.asp?asdf=44','myInboxContent');
				}
			}
		}
}

function changeMsgReadStatus(stat)
{
			var str, arrStr1;
			str = ""
			str = document.getElementById("allMsgChkId").value;
			if (str.length > 0)
			{
				arrStr1 = str.split(";");
				for(i=0;i<=arrStr1.length-1;i++)
				{
					if(document.getElementById(arrStr1[i]).checked)
					{
						m = parseInt(arrStr1[i].replace("chk",""));
						showData('changeMessageReadStatus.asp?m=' + m + '&stat=' + stat + '','myInboxContent');
					}
				}
			showData('divInbox.asp?asdf=44','myInboxContent');
			}
	
}

function selMsgInbox(typ)
{
	var str, arrStr1,i,arrStr2;
	if (typ == 1)  //all
	{
		str = ""
		str = document.getElementById("allMsgChkId").value;
		if (str.length > 0)
		{
			arrStr1 = str.split(";");
			for(i=0;i<=arrStr1.length-1;i++)
			{
				document.getElementById(arrStr1[i]).checked = true;
			}
		}
	}
	if (typ == 2) //read
	{
		str = "";
		str = document.getElementById("unreadMsgChkId").value;
		if (str.length > 0)
		{
			arrStr2 = str.split(";");
			for(i=0;i<=arrStr2.length-1;i++)
			{
				document.getElementById(arrStr2[i]).checked = false;
			}
		}
		
		str = ""
		str = document.getElementById("readMsgChkId").value;
		if (str.length > 0)
		{
			arrStr1 = str.split(";");
			for(i=0;i<=arrStr1.length-1;i++)
			{
				document.getElementById(arrStr1[i]).checked = true;
			}
		}
	}
	if (typ == 3) //unread
	{
		str = "";
		str = document.getElementById("readMsgChkId").value;
		if (str.length > 0)
		{
			arrStr2 = str.split(";");
			for(i=0;i<=arrStr2.length-1;i++)
			{
				document.getElementById(arrStr2[i]).checked = false;
			}
		}
		
		
		str = "";
		str = document.getElementById("unreadMsgChkId").value;
		if (str.length > 0)
		{
			arrStr1 = str.split(";");
			for(i=0;i<=arrStr1.length-1;i++)
			{
				document.getElementById(arrStr1[i]).checked = true;
			}
		}
	}
	if (typ == 4) //none
	{
		str = ""
		str = document.getElementById("allMsgChkId").value;
		if (str.length > 0)
		{
			arrStr1 = str.split(";");
			for(i=0;i<=arrStr1.length-1;i++)
			{
				document.getElementById(arrStr1[i]).checked = false;
			}
		}
	}
}

//----------------------------
var xmlHttp

function showData(str,div_id)
{ 

	xmlHttp=GetXmlHttpObject()


	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	
//	var url="getage.asp"
//	url=url+"?q="+str
	var url = str

	url=url+"&sid="+Math.random()

	xmlHttp.onreadystatechange=function() { stateChanged(div_id); }	

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}


function stateChanged(div_id) 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(div_id).innerHTML=xmlHttp.responseText ;
	} 

} 


function GetXmlHttpObject()
{   

	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	
	return objXMLHttp

}

//-----------------------------
