// JavaScript Document var url="getcustomer.asp?sid=" + Math.random() + "&q=" + str


	var xmlHttp
	
	
	
	function addFriendRequest(friend_id)
	{
		
		var url="./add_to_friend_request_ajax.php?add_friend=" + friend_id; 
										
		xmlHttp=GetXmlHttpObject(friendRequestCheck)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	
	function friendRequestCheck() 
	{ 
				
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			
			if(xmlHttp.responseText == 1)
			{
				alert('Add to friend request sent successfully !!');	
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('You have already sent the add to friend request !!');
			}
		
		} 
	}
	
	function flagVideo(video_id,status,user)
	{ 
	
		var url="./flag_videos_ajax.php?video=" + video_id + "&vote_status=" + status; 
						
		xmlHttp=GetXmlHttpObject(flagVideoCheck)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function flagVideoCheck() 
	{ 
				
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
				alert('You cast a vote !!');	
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('You have already voted !!');
			}
		
		} 
	}
	
	
	
	function addVideosToPlaylist(play_list,video_id)
	{ 
	
		var url="./play_list_management_ajax.php?list=" + play_list + "&video=" + video_id;
												
		xmlHttp=GetXmlHttpObject(addPlaylistCheck)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function addPlaylistCheck() 
	{ 
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
									
				alert('Successfully added the video to the selected playlist !!');	
			
			}
					
			
		} 
	}
	
	
	
	
	var vgroup_name = "";
	var vlimit = "";
	var vpage = ""; 
	
	function addVideosToGroup(videos_list,group_id,group_name,limit,page)
	{ 
	
		var url="./group_videos_management_ajax.php?list=" + videos_list + "&group=" + group_id;
		
		vgroup_name = group_name;
		vlimit = limit;
		vpage = page;
				
		xmlHttp=GetXmlHttpObject(addVideosCheck)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function addVideosCheck() 
	{ 
				
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
									
				alert('Successfully added the selected videos to the group !!');	
							
				window.location = "./view_group.php?group_name=" + vgroup_name + "&limit=" + vlimit + "&page=" + vpage;
				
			}
					
			
		} 
	} 
	
	
	
	
	
	function listManage(list)
	{ 
	
		var url="./list_management_ajax.php?list_name=" + list;
														
		xmlHttp=GetXmlHttpObject(listCheck)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function listCheck() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 

									
			if(xmlHttp.responseText == 1)
			{
								
								
				alert('List Name already exists !!');								
									
			}
			else
			{
				
				document.frmMyFriends1.submit();
				alert('List Added Successfully !!');
				//document.frmMyFriends.submit();
				
				//window.location = './user_main.php';
			}
			
			
		} 
	} 
	
	
	
	
	function listManageUser(list)
	{ 
	
		var url="./list_management_ajax.php?list_name=" + list;
														
		xmlHttp=GetXmlHttpObject(listCheckUser)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function listCheckUser() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 

									
			if(xmlHttp.responseText == 1)
			{
								
								
				alert('List Name already exists !!');								
									
			}
			else
			{
				
				document.frmMyList1.submit();
				alert('List Added Successfully !!');
				//document.frmMyFriends.submit();
				
				//window.location = './user_main.php';
			}
			
			
		} 
	} 
	
	
	
	function acceptFriendRequestInvitation(code,status)
	{
		
		var url="./accept_friend_request_invitation_ajax.php?accept_code=" + code + "&status=" + status;
																						
		xmlHttp=GetXmlHttpObject(checkFriendRequestInvitationStatus)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	
	
	function checkFriendRequestInvitationStatus() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
			
				alert('Congratulations you have accepted the invitation !!');
				window.location = './user_friend_request.php';
									
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('You have rejected the invitation !!');
				window.location = './user_friend_request.php';
			}
			
			
		} 
	}
	
	
	
	function acceptFriendInvitation(status,key_code)
	{ 
	
		var url="./accept_invitation_ajax.php?status=" + status + "&accept_code=" + key_code;
														
		xmlHttp=GetXmlHttpObject(checkInviteStatus)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function checkInviteStatus() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
			
				alert('Congratulations you have accepted the invitation !!');
				window.location = './user_main.php';
									
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('You have rejected the invitation !!');
				window.location = './user_main.php';
			}
			
			
		} 
	}
	
	
	
	
	function acceptFriendInvitationGroup(status,key_code)
	{ 
	
		var url="./accept_invitation_group_ajax.php?status=" + status + "&accept_code=" + key_code;
		
		xmlHttp=GetXmlHttpObject(checkInviteStatusGroup)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	} 
	
	
	
	function checkInviteStatusGroup() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
									
			if(xmlHttp.responseText == 1)
			{
			
				alert('Congratulations you have accepted the invitation !!');								
									
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('You have rejected the invitation !!');
				
			}
			
			
		} 
	}
	
	
	
	
	function addToList(friends,list)
	{
		
		var url="./addto_list_ajax.php?friends_id=" + friends + "&list_id=" + list;
																		
		xmlHttp=GetXmlHttpObject(buildFriendsList)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	
	function buildFriendsList() 
	{ 
	
	
			
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 

									
			if(xmlHttp.responseText == 1)
			{
				document.frmMyFriends2.submit();
				alert('Successfully added the selected Contacts to list  !!');								
				
			}
						
			
		} 
	} 
	
	
	
	
	
	
	function GetXmlHttpObject(handler)
	{ 
		var objXmlHttp=null
	
		if (navigator.userAgent.indexOf("Opera")>=0)
		{
			alert("This feature doesn't work in Opera") 
			return 
		}
		if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			} 
			try
			{ 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler 
				return objXmlHttp
			} 
			catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
		} 
			if (navigator.userAgent.indexOf("Mozilla")>=0)
			{
				objXmlHttp=new XMLHttpRequest()
				objXmlHttp.onload=handler
				objXmlHttp.onerror=handler 
				return objXmlHttp
			}
	} 
