/*
 * @Revision $Revision: 304 $
 * @Author $Author: piyali $
 * @Date $Date: 2008-11-17 11:16:08 +0530 (Mon, 17 Nov 2008) $
*/

$(document).ready(function()
 { 
 
 
 			var call_top_story=function ()
			{
					$.post("/outerprofilecss/ajax_top_story.php",function(data)
					  {
							$("#ajax_top_story").html(data);
																		   
					  });
			}
			call_top_story();
 
		 var call_gc=function ()
					{
							$.post("/outerprofilecss/ajax_gc.php",function(data)
							  {
									$("#ajax_gc").html(data);
																				   
							  });
					}
					call_gc();
 
 
 
 			
			 $("#cookie_not").click(function()
			 {
			
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(1);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  $("#view_full_profile_sign").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(1);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 
			 
			 $("#close_div_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeOut("slow",function()  
				{
					$("#login_pages").val('');
					$("#Layer4").hide();
				})
			 });
			 $("#cancel_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeOut("slow",function()  
				{
					$("#login_pages").val('');
					$("#Layer4").hide();
				})
			 });
			  $("#contact_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(2);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  
			   $("#sign_in_and_add").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(2);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  
			  
			  
			 $("#network_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(3);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 $("#send_msg").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(4);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  $("#scrapbook_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(5);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			   $("#member_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(6);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 $("#member_login_lnk").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(6);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 
			 $("#community_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(7);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 $("#community_login1").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(7);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			 $("#app_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(8);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  $("#app_login1").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(8);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  $("#mentor_login").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(9);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
			  $("#mentor_login1").click(function()
			 {
				$("#sign_in_fromprofile").fadeIn("slow",function()
				{
					$("#login_pages").val(8);
					$("#sign_in_fromprofile").focus();
					$("#Layer4").hide();
				})
			 });
 
  });  



$(document).ready(function()
 { 
 		
///////////////////////////////////login function///////////////////////////////////////////////////////////////////////		
function sign_in_function(e){
									$("#Layer4").removeClass().addClass('messagebox').text('Validating........').fadeIn(500);
									if($('#email_login').val()=="")
									{
											$("#Layer4").fadeTo(200,0.1,function()
													{
													  $(this).html('Please enter your email id').addClass('messageboxerror').fadeTo(900,1,
													  function()
													  {
													  $('#email_login').focus();
														return false;
													  });  
										
													});  
										
									}
									else if($('#email_login').val()!="")
									{
											var vallll=$('#email_login').val();
											var str=vallll.replace(/^\s+|\s+$/g,'');
											var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
											 if (!filter.test(str))
													{
														 
															$("#Layer4").fadeTo(200,0.1,function()
															{
															  $(this).html('Please enter a valid email id').addClass('messageboxerror').fadeTo(900,1,
															  function()
															  {
																
																$('#email_login').focus();
																});
												
															});
													}else if($('#password_login').val()=="")
													{
														$("#Layer4").fadeTo(200,0.1,function()
																	{
																	  $(this).html('Please enter your password').addClass('messageboxerror').fadeTo(900,1,
																	  function()
																	  {
																	  $('#password_login').val("");	
																	  $('#password_login').focus();
																		
																	  });  
														
																	});   
													}	else
													{
													if(document.getElementById("remember_me").checked==true)
													{
														var remme=1;
													}else if(document.getElementById("remember_me").checked==false)
													{
														var remme="";
													}
													
														$.post("/outerprofilecss/login_details_check.php",{ email:$('#email_login').val(),password:$('#password_login').val(),checkbox:remme,login_pages:$('#login_pages').val(),Submit:$('#Submit').val(),profile_id:$('#profile_id').val()} ,function(data)
															   {
															   	var errtext="Incorrect email id or password. Please try again.";
																var errtext1="Sorry some error is coming"						   
															   		if(data==errtext || data==errtext1)
																	{
																		$("#Layer4").fadeTo(200,0.1,function()
																			{
																			  $(this).html(data).addClass('messageboxerror').fadeTo(900,1,
																			  function()
																			  {
																			  $('#email_login').val("");
																			  $('#password_login').val("");	
																			  $('#email_login').focus();
																				return false;
																			  });  
																
																			});
																	}else
																	{
																	$("#Layer4").fadeTo(200,0.1,function()  //start fading the messagebox
																			{
																			  //add message and change the class of the box and start fading
																			  $(this).html('Loading....').addClass('messageboxok').fadeTo(900,1,
																			  function()
																			  {
																				 document.location=data;
																			  });
																
																			});
																	}
															  
															   
															   });
													   }
									
												
											
									}								
return false; 				
			}	    
		
//////////////////////////////////////////ends here/////////////////////////////////////////////////////////////////////		

 
 				$("#sign_in1").click(sign_in_function);
				$("#newmahi2").keypress(function (evt) 
					{
						//alert(evt.keyCode);
						if (evt.keyCode == 13) 
						{
						sign_in_function();
						}
					});		
				
				
///////////////////////////////////////////////////////ends for sign in part////////////////////////////////////////////////////////


$("#email_login").keypress(function(){
		$("#Layer4").hide();
		});
		$("#password_login").keypress(function(){
		$("#Layer4").hide();
		}); 	
		




///////////////////////////////////////////function for submit forward//////////////////////////////////////////////
function captcha_change()
{
$("#captcha_image_change").attr({src :'/news/captcha/CaptchaSecurityImages.php?'+ Date.parse(new Date().toString()) });  
}

function forward_form(e1)
{        
	
	$("#Layer5").removeClass().addClass('messagebox1').text('Validating........').fadeIn(500);
	///////////////////////////////////////////////rajib part//////////////////////////////////////////////////////////////////////////////////////					
	var sento_email=$("#sendto").val();
	var trim_sent_to=sento_email.replace(/^\s+|\s+$/g,'');
	var arr=sento_email.split(",");
	//alert(arr.length);
//////////////////////////send to email part/////////////////////////////////////////////////////////////
//////////////@@@@@@@@@@@@@@@@@@@@@@@starts here@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	if(arr.length > 0)
	{
		//alert("piyli");
		for(var i=0;i<arr.length;i++)
		  {
					if (arr[i].replace(/^\s+|\s+$/g,'')=="")
					{
						 $("#Layer5").fadeTo(200,0.1,function()
							{
								  $(this).html("Please enter receiver's email id").addClass('messageboxerror1').fadeTo(900,1,
								  function()
								  {
									  $('#sendto').val("");
									  $('#sendto').focus();
									  return false; 
									 
								  });  
								  
							});
						  return false; 
					
					}else
					{
							str=arr[i];
							var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
							if (!filter.test(str))
							{
								 $("#Layer5").fadeTo(200,0.1,function()
									{
										  $(this).html("Please enter a valid email id").addClass('messageboxerror1').fadeTo(900,1,
										  function()
										  {
											  $('#sendto').focus();
												return false;    
										  });  
										  
									});
								 return false; 
					
							}
							
					}
					
					//return false; 
			}
		//return false; 								
								
	}
	
//////////////////////////send to email part/////////////////////////////////////////////////////////////
//////////////@@@@@@@@@@@@@@@@@@@@@@@ends here@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

//alert("jajaj");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
var aaaa=$('#your_name').val();
var replace_name_space=aaaa.replace(/^\s+|\s+$/g,'');
var flag_for_special_char=false;
var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for (var i = 0; i < aaaa.length; i++)
 {
	if (iChars.indexOf(aaaa.charAt(i)) != -1)
	  {
		flag_for_special_char=true;
		break;
	  }
 }
if($("#your_name").val()=="" || replace_name_space=="")
{
	//alert($("#your_name").val());
			$("#Layer5").fadeTo(200,0.1,function()
			{
			  $(this).html('Please insert your name').addClass('messageboxerror1').fadeTo(900,1,
			  function()
			  {
			  $('#your_name').val("");
			  $('#your_name').focus();
				return false;    
			  });  
			});
return false; 
							
}else if(flag_for_special_char==false)
{
	//alert($("#your_name").val());
			$("#Layer5").fadeTo(200,0.1,function()
			{
			  $(this).html('Sorry! symbols or special characters are not allowed.').addClass('messageboxerror1').fadeTo(900,1,
			  function()
			  {
			  $('#your_name').val("");
			  $('#your_name').focus();
				return false;    
			  });  
			});
return false; 
							
}else if($("#your_email").val()=="")
{
			$("#Layer5").fadeTo(200,0.1,function()
			{
			  $(this).html('Please insert your email id').addClass('messageboxerror1').fadeTo(900,1,
				  function()
				  {
				  $('#your_email').val("");
				  $('#your_email').focus();
				  return false;    
				  });
			 });
return false;  
												
}else if($("#your_email").val()!="")
{
		var val_email=$('#your_email').val();
		var str=val_email.replace(/^\s+|\s+$/g,'');
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
		if (!filter.test(str))
		{
			$("#Layer5").fadeTo(200,0.1,function()
			{
				  $(this).html('Please enter a valid email id').addClass('messageboxerror1').fadeTo(900,1,
				  function()
				  {
					  $('#your_email').val("");
					$('#your_email').focus();
					return false;
				  });
							
		  	});
		return false;  
		}else if($("#subject_profile").val()=="")
		{
			$("#Layer5").fadeTo(200,0.1,function()
			{
			  $(this).html('Please insert subject').addClass('messageboxerror1').fadeTo(900,1,
			  function()
				  {
				   $('#subject_profile').focus();  
				   return false;    
				  });  
			});
		return false;  
		
		}else if($("#images_txt").val()=="")
		{
			$("#Layer5").fadeTo(200,0.1,function()
			{
				  $(this).html('Please the text from bottom image').addClass('messageboxerror1').fadeTo(900,1,
				  function()
				  {
					$('#images_txt').val("");
				   $('#images_txt').focus();  
					return false;    
				  });  
			});
		return false;  
		
		}else if($("#forward_msg").val().replace(/^\s+|\s+$/g,'')=="")
		{
			//alert("i m here");
			var return3=confirm("Send this message without text in message body?");
			if(return3==false)
			 {
				 $("#Layer5").hide();  
				$("#forward_msg").val("");
				$("#forward_msg").focus();
				 return false;
			 }else
			 {
			$.post("/outerprofilecss/emlprofile.php",{ adminid1:$('#adminid1').val(),subject:$('#subject_profile').val(),toaddress:$('#sendto').val(),fromaddress:$('#your_email').val(),fromname:$('#your_name').val(),message:$('#forward_msg').val(),name:$('#admin_name').val(),images_txt:$('#images_txt').val()} ,function(data)
															   {
																   var text="Please enter correct word from bottom image";
																   if(data==text)
																   { 
																  
																	  $("#Layer5").fadeTo(200,0.1,function()
																				{
																					  $(this).html(data).addClass('messageboxerror1').fadeTo(900,1,captcha_change,
																					  function()
																					  {
																					  	captcha_change;  
																					  });       
																				});
																   }else
																   {
																	   captcha_change();
																	    $("#Layer5").fadeTo(200,0.1,function()
																				{
																					  $(this).html(data).addClass('messageboxok1').fadeTo(900,1,
																					  function()
																					  {
																					   return false;    
																					  });  
																				});
																		$("#sendto").val("");
																		$("#your_name").val("");
																		$("#your_email").val("");
																		$("#forward_msg").val("");
																		$("#forward_msg").val("I found "+$("#admin_name").val()+"'s profile on SiliconIndia and thought you might be interested");
																		$("#images_txt").val("");
																   }
															   });
															   
			}
															
	}else
	{
		$.post("/outerprofilecss/emlprofile.php",{ adminid1:$('#adminid1').val(),subject:$('#subject_profile').val(),toaddress:$('#sendto').val(),fromaddress:$('#your_email').val(),fromname:$('#your_name').val(),message:$('#forward_msg').val(),name:$('#admin_name').val(),images_txt:$('#images_txt').val()} ,function(data)
															   {
																   var text="Please enter correct word from bottom image";
																   if(data==text)
																   {
																	  $("#Layer5").fadeTo(200,0.1,function()  
																				{
																					  $(this).html(data).addClass('messageboxerror1').fadeTo(900,1,captcha_change,
																					  function()     
																					  {
																					   return false;    
																					  });  
																				});
																   }else
																   {
																	    $("#Layer5").fadeTo(200,0.1,function()
																				{
																					  $(this).html(data).addClass('messageboxok1').fadeTo(900,1,
																					  function()
																					  {
																					  $("#forward_profile").hide(9500);
																					  });  
																				});
																		
																 }
															
															});
															   
	}
						
						
						
						
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			
			}
				
			
					
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////					


					

					

return false;
										
										

}




//////////////////////////////////////////ends here////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////starts for forward part/////////////////////////////////////////////////////////
$("#forward_profile_user1").click(function()
										   {
											   $("#Layer5").hide();
											   $("#forward_profile").show(captcha_change);
										   }
										   );

$("#close_profile_box,#close_forward_box123").click(function()
										   {
											   $("#Layer5").hide();
											   $("#forward_profile").hide(captcha_change);
										   }
								  );


/*$("#close_forward_box123").click(function()
										   {
											   $("#forward_profile").hide(captcha_change);
										   }
								  );*/  


$("#forward_submit").click(forward_form);  
  
$("#forward_profile").keypress(function(event)
					{ 
						if(event.keyCode==13 && $("#focus_on_msg").val()==0) 
					 	{
							forward_form();
						  
						}
					});

$("#sendto,#your_name,#your_email,#subject_profile,#forward_msg,#images_txt").keypress(function(){
		$("#Layer5").hide();
		});




////////////////////////////////////////////////////ends for forward part//////////////////////////////////////////////////////////////

////////////////////////////////////auto complete for searching member //////////////////////////////////////////////////////////////////

function load_data(e)
{
	  
	var tot_url="/outerprofilecss/auto_member_search.php"; 
	if(!$(".ac_results").is(':visible') && (e!=38 || e!=40 || e!=46 || e!=9 ) && e!=8 )
	{
			$.post(tot_url,{key:$("#search_member_from_outside").val()} ,function(data)
			{
				if(data.length > 0)
				{
						$(".ac_results").html(data);
						$(".ac_results").show();
					
							$("#sss").val(1);
						$(".ac_results li").click(
							function()
							{
								//var val2=$(this).attr('id').replace("scroll_","") ;
								var val1=$(this).attr('id').replace(/_/g," ") ;
								val1=val1.replace(/_/g," ") ;
								val1=val1.replace(/_/g," ") ;
								$("#search_member_from_outside").focus(function (){$(this).val(val1)}); 
								$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
								$("#search_member_from_outside").val(val1);
								$(".ac_results").hide();
								$(".ac_results").html("");
								//form_submit_for_mem_search();
							})
						
						setTimeout("$('.ac_results').hide();",90000); 
					
				}else
				{
						$(".ac_results").hide();
						$(".ac_results").html("");
				}
			});
							
	}else if($(".ac_results").is(':visible') && e!=38 && e!=40 && e!=46 && e!=9 && $("#search_community").val()!='')
	{
			$.post(tot_url,{key:$("#search_member_from_outside").val()} ,function(data)
			{
				if(data.length > 0)
				{
					$(".ac_results").html(data);
					$(".ac_results").show();
					$("#sss").val(1);
					$(".ac_results li:first").select();
					$(".ac_results li").click(
						function()
						{
							//var val2=$(this).attr('id').replace("scroll_","") ;
							var val1=$(this).attr('id').replace(/_/g," ") ;
							val1=val1.replace(/_/g," ") ;
							val1=val1.replace(/_/g," ") ;
							$("#search_member_from_outside").focus(function (){$(this).val(val1)});
							$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
							$("#search_member_from_outside").val(val1);
							$(".ac_results").hide();
							$(".ac_results").html("");
							//form_submit_for_mem_search();
							
						})
					 setTimeout("$('.ac_results').hide();",90000); 
				}else
				{
					$(".ac_results").hide();
					$(".ac_results").html("");
				}
				
			});  
			
	}else if($(".ac_results").is(':visible') && (e==38 || e==40 || e==46 || e==9 || e==8 ))
	{
		
		if(e==8)
		{
			$(".ac_results").hide();
			$(".ac_results").html("");
		}else if(e==40)
		{
			
				/*checkForScroll(e,"dvtoscroll", "num") ;*/
		
			var tra=$("#sss").val();
            var sss=$(".ac_results ul li").size();
		//	alert($(".ac_results ul li").size())
			if(tra > $(".ac_results ul li").size())
			{
				$("#sss").val(1);
				tra=1;
			}
			if(tra < 0 || tra==0)
			{
				tra=1;
			}
						
			
			if(tra==1)
			{
				$(".num"+tra).addClass('hoverstyle');  
				var val1=$(".num"+tra).attr('id').replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				$("#search_member_from_outside").focus(function (){$(this).val(val1)});
				$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
				$("#search_member_from_outside").val(val1);
				
				$("#sss").val(parseInt(tra)+1);
				$(".num"+sss).removeClass('hoverstyle');  		
				
			}
			else
			{
				
				$(".num"+tra).addClass('hoverstyle'); 
			
				var val1=$(".num"+tra).attr('id').replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				$("#search_member_from_outside").focus(function (){$(this).val(val1)});
				$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
				$("#search_member_from_outside").val(val1);
				$("#sss").val(parseInt(tra)+1);
				
				
			}
			
			var tt=parseInt(tra)-1;
			$(".num"+tt).removeClass('hoverstyle');  
			
			
		
		}else if(e==38)
		{
			
				/*checkForScroll(e,"dvtoscroll", "num") ;*/
		
			var tra=$("#sss").val();
			var sss=$(".ac_results ul li").size();
		//	alert($(".ac_results ul li").size())
			var dd=parseInt(sss)-1;   
			if(tra > $(".ac_results ul li").size())
			{
				
				$("#sss").val(dd);
				tra=dd;
			
			}
			
			if(tra < 0 || tra==0)
			{
				tra= $(".ac_results ul li").size();
			}
			if(tra!=1)
			{
				$(".num"+1).removeClass('hoverstyle');  
			}
			if(tra==1 )
			{
				$(".num"+tra).addClass('hoverstyle');  
				var val1=$(".num"+tra).attr('id').replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				$("#search_member_from_outside").focus(function (){$(this).val(val1)});
				$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
				$("#search_member_from_outside").val(val1);
				
				$("#sss").val(parseInt(tra)-1);
				$(".num"+sss).removeClass('hoverstyle');  		
				
			}
			else
			{
				var piyali=tra;/*parseInt(tra)-1;*/
				$(".num"+piyali).addClass('hoverstyle'); 
				var val1=$(".num"+piyali).attr('id').replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				val1=val1.replace(/_/g," ") ;
				$("#search_member_from_outside").focus(function (){$(this).val(val1)});
				$("#search_member_from_outside").blur(function (){$(this).val(val1)});   
				$("#search_member_from_outside").val(val1);
				$("#sss").val(parseInt(tra)-1);
				
				
			}
			
			var tt=parseInt(tra)+1;
			var tt1=parseInt(tra)-1;
			$(".num"+tt).removeClass('hoverstyle');  
			$(".num"+tt1).removeClass('hoverstyle');  
			
			
		
		}
		
	}else
	{
		$(".ac_results").hide();
		$(".ac_results").html("");
	}

}




$("#search_member_from_outside").keyup(function(e)
							{
								val11=$(this).val();
								$(this).focus(function (){$(this).val(val11)});
								$(this).blur(function (){$(this).val(val11)});								
								e1=e.keyCode;
								load_data(e1);
							});





////////////////////////////////////////////////ends here////////////////////////////////////////////////////////////////////////////////

	   });  