// JavaScript Document
var loader="<table width='300px' height='190px'><tr><td align='center' valign='middle'><img src='./images/ajax-loader.gif'/></td></tr></table>";
function submitOnEnter(e,mode) {
            var ENTER_KEY = 13;
            var code = "";
            if (window.event) // IE
            {
                code = e.keyCode;
            }
            else if (e.which) // Netscape/Firefox/Opera
            {
                code = e.which;
            }
            
            if (code == ENTER_KEY) {
	             if ( mode == 'LOGIN')
	              {
	                     changeRemember('login.action');
	                     return false;
	              }
	              else if ( mode == 'FORGOT_LOGIN')
				  {
	                     forgotLoginIdActions('resendLoginId.action');
						 return false;
	              }
				  else if ( mode == 'FORGOT_PASSWORD')
				  {
	                     resetPasswordAction();
						 return false;
	              }
				  else if ( mode == 'REGISTER')
				  {
	                     registrationFunction();
						 return false;
	              }
				  else if ( mode == 'CHANGE_PASSWORD')
				  {
	                     changePassword('changePasswordFromSettings.action');
						 return false;
	              }
				  else if ( mode == 'CREATE_ALBUM')
	              {
	                    javascript:addAlbum('createAlbum.action');
                		return false;
	              }
	              else if ( mode == 'ADD_BUDDY')
				  {
	                     addingBuddy('addBuddyAction.action');
						 return false;
	              }
	              else if ( mode == 'INVITE_BUDDY')
				  {
	                     invitingBuddy('inviteBuddyAction.action');
						 return false;
	              }
	              else if ( mode == 'EDIT_ALBUM')
				  {
	                     editAlbumAction('editAlbum.action');
						 return false;
	              }
	              else if ( mode == 'SHARE_ALBUM')
				  {
	                     shareAlbumAction('shareAlbum.action');
						 return false;
	              }
	              else if ( mode == 'EDIT_SHARE_FILE')
				  {
	                    updateShareFile('updateShareFile.action');
						return false;
	              }
	              else if ( mode == 'EDIT_SHARE_ALBUM')
				  {
	                     updateShareAlbum('updateShareAlbum.action');
						return false;
	              }
	              else if ( mode == 'EDIT_FILE')
				  {
	                    editFileActions('editFileAction.action',"");
						return false;
	              }
	              else if ( mode == 'SHARE_FILE')
				  {
	                    shareFileAction('shareFileAction.action');
						return false;
	              }
	              else if ( mode == 'EDIT_USER_PROFILE')
				  {
				  		updateUserDetailsAction('UpdateUserDetailsAction.action');
						return false;
	              }
	              else if( mode == 'SHARE_SELECTED_ALBUM')
	              {
	              		shareSelectedAlbumAction('shareSelectedAlbum.action');
	              		return false;
	              }
	              else if( mode == 'EDIT_BUDDY')
	              {
	              		updateContactInfo('UpdateBuddyDataAction.action');
	              		return false;
	              }	
				  else if(mode == 'INVITE_BUDDY_ADDRESS_BOOK')
	              {
	              		inviteBuddyGetAddressBook();
	              		return false;
	              }
	              else if(mode == 'CREATE_TRIP')
	              {
	              		addTrip();
	              		return false;
	              }
	              else if(mode == 'UPDATE_ADD_FROM_MAP')
	              {
	              	   	updateAddressFromMap();
		              	return false;
	              }
	              else if(mode == 'RESEND_ACTIVATION')
	              {
	              	   	resendActivationMail('resendActivation.action');
		              	return false;
	              }
	              else if(mode == 'SEARCH_USER')
	              {
	              	   	getUserMailSearch();
		              	return false;
	              }
	              else if(mode == 'SEARCH_PLACE')
	              {
	              	   	searchPlaces(null,'0');
		              	return false;
	              }
	              else if(mode == 'CREATE_VISTA_POINT')
	              {
	              	   	addTripPoint();
		              	return false;
	              }
	              
	              
	              
              
            }
      }



function forgotPassword(url) {
var loginDiv = document.getElementById('loginDiv');
loginDiv.innerHTML = loader;
new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{	    					
				var response = transport.responseText || "Internal error occured in the server. Please try again later";
				loginDiv.innerHTML = response; // Put the response into the 'album' div
				document.reset_password_form.userId.focus();			
		},
		onFailure: function()
		{
			loginDiv.innerHTML= "Unable to load page.  ";
		}
	});

}
function forgotLoginId(url) {
document.getElementById('loginDiv').innerHTML = loader;
new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
			document.Forgot_Login_form.email.focus();
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please refresh the browser window";
		}
	});
}

function resetPasswordAction(){
var userId="";
var email="";
var userIdObj=document.reset_password_form.userId;
var emailObj=document.reset_password_form.email;
if(userIdObj != null && userIdObj != "undefined") {
		userId = userIdObj.value;
	}
	if(emailObj != null && emailObj != "undefined") {
		email = emailObj.value;
	}
url='resetPassword.action?userId='+userId+'&email='+email;
document.getElementById('loginDiv').innerHTML = loader;
new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please refresh the browser window";
		}
	});
}

function forgotLoginIdActions(url){
var email="";
var emailObj=document.Forgot_Login_form.email;
if(emailObj != null && emailObj != "undefined") {
		email = emailObj.value;
	}
url=url+'?email='+email;
document.getElementById('loginDiv').innerHTML = loader;
new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please refresh the browser window";
		}
	});

}

function changePassword(url)
{
	var newpassword="";
	var conpassword="";
	var oldpassword="";
	var newpasswordObj=document.getElementById("newpassword");
	var conpasswordObj=document.getElementById("conpassword");
	var oldpasswordObj=document.getElementById("oldpassword");
	if(newpasswordObj != null && newpasswordObj != "undefined") {
		newpassword = newpasswordObj.value;
	}
	if(conpasswordObj != null && conpasswordObj != "undefined") {
		conpassword = conpasswordObj.value;
	}
	if(oldpasswordObj != null && oldpasswordObj != "undefined") {
		oldpassword = oldpasswordObj.value;
	}
	if(newpassword.length==0 || conpassword.length==0 || conpassword.length==0)
	{
	document.getElementById('error').innerHTML="<div><ul><li><span>Required fields should be filled.</span></li></ul></div>";
	return false;
	}
	else if(newpassword.length < 6)
	{
	document.getElementById('error').innerHTML="<div><ul><li><span>Password should be atleast 6 characters in length</span></li></ul></div>";
	return false;
	}
	else if(newpassword != conpassword)
	{
	document.getElementById('error').innerHTML="<div><ul><li><span>Password and Confirm Password should match</span></li></ul></div>";
	return false;
	}
	else
	{
	url = url + '?oldpassword='+oldpassword+'&conpassword='+conpassword+'&newpassword='+newpassword;
	document.getElementById('albumcontainer').innerHTML=loader;
		new Ajax.Request(url,
		{
			method:'get', 
			onSuccess: function(transport)
			{
				var response = transport.responseText || "Internal error occured in the server. Please try again later";
				document.getElementById('albumcontainer').innerHTML = response; 
				document.getElementById('buddy_hide_ar_passwords').style.display = 'block';
				document.getElementById('buddy_hide_passwords').style.display = 'block';
				document.getElementById('buddy_show_ar_passwords').style.display = 'none'; 
				
				
			},
			onFailure: function()
			{
				document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
			}
		});	
}
}

function updatePasswordAction(){
		if(document.getElementById('pwd').value=="" || document.getElementById('re_pwd').value=="")
		{
		document.getElementById('updatePasswordDiv_Error').innerHTML="Must be enter password and re-password";return false;
		}
		else if(document.getElementById('pwd').value != document.getElementById('re_pwd').value)
		{
		document.getElementById('updatePasswordDiv_Error').innerHTML="Password and Confirm Password should match";return false;
		}
		else
		document.update_password_form.submit();
				
	}
function editUserDetailsAction(url,section) {
	var type="edit";
	url=url+'?type='+type+'&section='+section;
	document.getElementById('albumcontainer').innerHTML = loader;
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later.";
		}
	});
}

function afterUploadImage()
{
	setTimeOut(2000);
	userDetailsAction('UserDetailsAction.action','1');
}

function updateUserDetailsAction(url)
{

	var params="";
	var section=document.getElementById('section').value;
	if(section != null && section == 1)
	{
		var fName=document.getElementById('fName').value;
		if(fName.length == 0)
		{document.getElementById('errorMessage').innerHTML ='<ul><li>Please fill required fields.<br></li></ul>';return false;}
		if(fName.length>32)
		{document.getElementById('errorMessage').innerHTML ='<ul><li>First Name field should be less than 32 characters in length.<br></li></ul>';return false;}
		
		if(fName!=null && fName.length>0){
    		if(checkFirstName(fName)==false){   
    			document.getElementById('errorMessage').innerHTML='<ul><li>First Name allows either single space or dot in between charecters.<br></li></ul>';
    			return false;    			
    		}    	
    	}
    	
		var lName=document.getElementById('lName').value;
		if(lName.length != 0 &&  lName.length>32){document.getElementById('errorMessage').innerHTML ='<ul><li>Last Name should be less than 32 characters in length.<br></li></ul>';return false;}
    	if(lName!=null && lName.length>0){
    		if(checkLastName(lName)==false){   
    			document.getElementById('errorMessage').innerHTML='<ul><li>Last Name allows either single space or dot in between charecters.<br></li></ul>';
    			return false;
       		}
    	}
	
		var mName="";//document.getElementById('mName').value;
		var nName="";//document.getElementById('nName').value;		
		var gender=document.getElementById('gender').value;
		//var date=document.getElementById('date').value;
		//var month=document.getElementById('month').value;
		//var year=document.getElementById('year').value;		
		var sharePersonal=document.getElementById('sharePersonal').checked;
		//var dob=date+"/"+month+"/"+year;
		var dobCheck =new Date(document.getElementById('dateOfBirth').value);
		var dob=document.getElementById('dateOfBirth').value;
		var currentDate = new Date();
		currentDate.setDate(currentDate.getDate()-1)
		if (currentDate < dobCheck){			
			document.getElementById('errorMessage').innerHTML ='<ul><li>Date of Birth should be older than current date</li></ul>';
			return false;
		}
		params = params+'fName='+fName+'&lName='+lName+'&mName='+mName+'&nName='+nName+'&gender='+gender+'&dob='+dob;//date='+date+'&month='+month+'&year='+year;
		
		params = params+'&sharePersonal='+sharePersonal;//+'&shareVisitingAddress='+shareAddress2+'&shareCity='+shareCity+'&shareDOB='+shareDOB;
	}else if(section != null && section == 2)
	{
		var email=document.getElementById('email').value;
		var wEmail=document.getElementById('wEmail').value;
		if(wEmail != null && wEmail.length>0)
		{
			if (checkMail(wEmail)==false || wEmail.length>45)
			{
			document.getElementById('errorMessage').innerHTML ='<ul><li>Enter vaild Email Id with length no more than 45 characters.<br></li></ul>';
			return false;
			}
		}
		var hPhone=document.getElementById('hPhone').value;
		if(hPhone.length != 0 && hPhone.length>20){document.getElementById('errorMessage').innerHTML ='<ul><li>Home Phone length should be less than 20 characters.<br></li></ul>';return false;}
		var wPhone=document.getElementById('wPhone').value;
		if(wPhone.length != 0 && wPhone.length>20){document.getElementById('errorMessage').innerHTML ='<ul><li>Work Phone length should be less than 20 characters.<br></li></ul>';return false;}
		var cell=document.getElementById('cell').value;
		if(cell.length != 0 && cell.length>20){document.getElementById('errorMessage').innerHTML ='<ul><li>Mobile Phone length should be less than 20 characters.<br></li></ul>';return false;}
		

		/* validation removed 
		 if(cell!=null){    	    	
    		if(checkMobileNumber(cell)==false){   
    			document.getElementById('errorMessage').innerHTML='<ul><li>Enter Country code followed by Mobile number <br/> like 91XXXXXXXXXX or 1XXXXXXXXXX</li></ul>';
    			return false
   			   	}
    	} */
		
		var fNumber="";//document.getElementById('fNumber').value;		
		var shareContact=document.getElementById('shareContact').checked;		
		params = params+'email='+email+'&wEmail='+wEmail+'&hPhone='+hPhone+'&wPhone='+wPhone+'&cell='+cell+'&fNumber='+fNumber;
		params = params+'&shareContact='+shareContact; //+'&shareWorkEmail='+shareWEmail+'&sharePhoneNumbers='+sharePNumbers;
	}else if(section != null && section == 3)
	{
		var city="";//document.getElementById('city').value;
		var state="";//document.getElementById('state').value;
		var zip="";//document.getElementById('zip').value;
		var address1=document.getElementById('address1').value;
		if(address1.length != 0 && address1.length>90){document.getElementById('errorMessage').innerHTML ='<ul><li>Permanent Address length should be less than 90 characters.</li></ul>';return false;}
		var timezone1=document.getElementById('timezone1').value;
		if(timezone1.length != 0 && timezone1.length>50){document.getElementById('errorMessage').innerHTML ='<ul><li>Permanent Time Zone length should be less than 50 characters.<br></li></ul>';return false;}
		var address2=document.getElementById('address2').value;
		if(address2.length != 0 && address2.length>90){document.getElementById('errorMessage').innerHTML ='<ul><li>Visiting Address length should be less than 90 characters.</li></ul>';return false;}
		var timezone2=document.getElementById('timezone2').value;
		if(timezone2.length != 0 && timezone2.length>50){document.getElementById('errorMessage').innerHTML ='<ul><li>Visiting Time Zone length should be less than 50 characters.<br></li></ul>';return false;}
		var shareLocation=document.getElementById('shareLocation').checked;
		var shareVisitLocation="";//document.getElementById('shareVisitLocation').checked;
		params = params+'city='+city+'&state='+state+'&zip='+zip+'&address1='+address1+'&address2='+address2+'&homeTimeZome='+timezone1+'&visitingTimeZone='+timezone2+'&shareLocation='+shareLocation+'&shareVisitLocation='+shareVisitLocation;
	}
	else{
		params=params;
	}	
	url=url+'?'+params+'&section='+section;	
	document.getElementById('albumcontainer').innerHTML=loader;
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response; // Put the response into the 'album' div
			if(fName!=null && fName.length>0)
			document.getElementById('welcome').innerHTML='<strong>Welcome!  </strong>'+fName; 
			onLoadingDiv(section);
			profilePage();
			
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later.";
		}
	});
}
function resendActivationPage()
{
		var url ='resendActivationLink.jsp';
		document.getElementById('loginDiv').innerHTML=loader;
		new Ajax.Request(url,
		{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please try again later";
		}
		});
} 

function resendActivationMail(url) {
var username="";
var usernameObj=document.getElementById("username");
	if(usernameObj != null && usernameObj != "undefined") {
		username = usernameObj.value;
	}
		url = url + '?username='+username;
		
		document.getElementById('loginDiv').innerHTML=loader;
		new Ajax.Request(url,
		{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please try again later";
		}
		});
}


 //for File uploads
 var callbackForBuddyPicture =     
    {     
      cache:false,  
      success: function(o) {

      	if(o.responseText == "1")
      	{
      		document.getElementById("uploadImageErrors").innerHTML = "File does not exist";
      	}
      	else if(o.responseText == "2")
      	{
      		document.getElementById("uploadImageErrors").innerHTML = "File should be in image format";
      	}
      	else if(o.responseText == "3")
      	{
      		document.getElementById("uploadImageErrors").innerHTML = "File size should not exceed 800KB";
      	}
      	else
      	{
      		userDetailsAction('UserDetailsAction.action','1');
      		profilePage();
      	}
      }     
     }     
  	function afterBuddyPicture() {  

       var transaction = YAHOO.util.Connect.asyncRequest('GET', 'afterUploadUserPicture.action', callbackForBuddyPicture, null);   
    } 
    
    
//function afterBuddyPicture()
//{
//	setTimeout("userDetailsAction('UserDetailsAction.action','1')",2000);
//}

function changeRemember(url)
  {
  var username="";
  var password="";
  var password_code="";
  var usernameObj=document.getElementById('username');
  var passwordObj=document.getElementById('password');
  if(usernameObj != null && usernameObj != "undefined") {
		username = usernameObj.value;
	}
	if(passwordObj != null && passwordObj != "undefined") {
		password = passwordObj.value;
	}
	
	for(var k=0;k<password.length ;k++)
    {
    	var value123 = password.charCodeAt(k);
    	//alert(value123);
    	password_code = password_code+","+value123;
    }
    
  var rem = document.loginForm.rememberMe.checked;
   if(rem == 'true' || rem)   
    document.loginForm.remember.value = '1';    
   else   
   document.loginForm.remember.value = '0';   
    url=url+'?username='+username+'&password='+password_code+'&rememberMe='+document.getElementById('rememberMe').value+'&remember='+document.getElementById('remember').value+"&time="+new Date().getTime();
	document.getElementById('loginDiv').innerHTML=loader;
  	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";

			if(response!=null && response == 'success')
			document.location.href=("layout.jsp?time="+new Date().getTime());
			else
			document.getElementById('loginDiv').innerHTML = response;
		},
		onFailure: function()
		{
			document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please try again later";
		}
	});
  }
 function changingPassword(url)
 {
 document.getElementById('albumcontainer').innerHTML = loader;
		new Ajax.Request(url,
		{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response; 
			generalMoreInformation(); 
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
		});
 
 }
function aapyaSignin()
{
	url='loginPage.action';
	document.getElementById('loginDiv').innerHTML=loader;
	new Ajax.Request(url,
		{
			method:'get', 
			onSuccess: function(transport)
			{
				var response = transport.responseText || "Internal error occured in the server. Please try again later";
				document.getElementById('loginDiv').innerHTML = response; // Put the response into the 'album' div
				document.loginForm.username.focus();
			},
			onFailure: function()
			{
				document.getElementById('loginDiv').innerHTML = "Unable to load the page. Please try again later";
			}
		});		
}
function reloadImage()
    {
    	var imageObject = document.getElementById("captchaDiv");
    	var currentTime = new Date()
    	var myCode = '<a href="javascript:reloadImage();"> <img src="captchaImage.action?time='+currentTime.getTime()+'" align="middle" border="1" id="captchaImage"  height=90 width=180 class="captcha" alt="Loading..."/></a>'
    	imageObject.innerHTML = myCode;
    	document.getElementById("inCaptchaChars").value = "";
    }
function registrationFunction()
    {
	document.getElementById("errorDiv").innerHTML="";
	var username = document.r_form.username.value;	 
    var password = document.r_form.password.value;
    var repassword = document.r_form.repassword.value;
    var firstName = document.r_form.firstName.value;
    var lastName = document.r_form.lastName.value;
    var cellphone = document.r_form.cellphone.value;
   // var personalEmail = username;//document.r_form.personalEmail.value;
   var personalEmail =document.r_form.personalEmail.value;
    var inCaptchaChars = document.r_form.inCaptchaChars.value;
    var timezone = document.r_form.timezone.value;
    var password_code = "";
    var repassword_code = "";
    
   if(username=="" ||username.length==0||password=="" ||password.length==0||repassword=="" ||repassword.length==0||firstName=="" ||firstName.length==0||cellphone=="" ||cellphone.length==0||personalEmail=="" ||personalEmail.length==0)
    {
    	document.getElementById("errorDiv").innerHTML="Please fill in required fields <br>";
    	reloadImage();
    	return false;
    }

    if(username.length<3)
    {
    document.getElementById("errorDiv").innerHTML="User Name should be atleast 3 characters in length<br>";
    reloadImage();
    	return false;
    }

    if(username.length>50)
    {
    document.getElementById("errorDiv").innerHTML="User Id should not exceed 50 characters in length<br>";
    reloadImage();
    	return false;
    }
   
    if (checkMail(personalEmail)==false){
    	document.getElementById("errorDiv").innerHTML="Email should be a valid email format<br>";
		//document.r_form.username.value="";
		document.r_form.personalEmail.focus();
		reloadImage();
		return false
	}
   
    if(password!="" &&password.length>0 && repassword!="" &&repassword.length>0)
    {

    	if(password!=repassword)
    	{
    	
    	document.getElementById("errorDiv").innerHTML="Password and Confirm Password should match. Please try again<br>";
    	reloadImage();
    	return false;
    	}
    }
    if(password.length<6)
    {
    document.getElementById("errorDiv").innerHTML="Password should be atleast 6 characters in length<br>";
    	reloadImage();
    	return false;
    }
    if(password.length>32)
    {
    document.getElementById("errorDiv").innerHTML="Password should be more than 32 characters in length<br>";
    	reloadImage();
    	return false;
    }
    if(password!=null && password.length>0 ){
    	var filter = " \'\" "
		for (var i = 0; i < password.length; i++) {
  			if (filter.indexOf(password.charAt(i)) != -1) 
  			{
  				document.getElementById("errorDiv").innerHTML="Password should not contain quotation characters<br>";
  				reloadImage();
  				return false;
  			}
		} 
    }
    
    for(var k=0;k<password.length ;k++)
    {
    	var value123 = password.charCodeAt(k);
    	//alert(value123);
    	password_code = password_code+","+value123;
    }
    
    for(var k=0;k<repassword.length ;k++)
    {
    	var value123 = repassword.charCodeAt(k);
    	//alert(value123);
    	repassword_code = repassword_code+","+value123;
    }
    
    
    if(firstName.length>32)
    {
    document.getElementById("errorDiv").innerHTML="First Name should not be more than 32 characters in length<br>";
    reloadImage();
    	return false;
    }
    
    if(firstName!=null && firstName.length>0){
    	if(checkFirstName(firstName)==false){   
    		document.getElementById("errorDiv").innerHTML="First Name allows either single space or dot in between charecters.<br>";
    		document.r_form.firstName.value="";
		document.r_form.firstName.focus();
  			reloadImage();
			return false;
	   	}
    }
    
    if(lastName.length>32){
    document.getElementById("errorDiv").innerHTML="Last Name should not be more than 32 characters in length<br>";
    reloadImage();
    	return false;
    }
    if(lastName!=null && lastName.length>0){
    	if(checkLastName(lastName)==false){   
    		document.getElementById("errorDiv").innerHTML="First Name allows either single space or dot in between charecters.<br>";
    		document.r_form.lastName.value="";
		document.r_form.lastName.focus();
  			reloadImage();
			return false;
	   	}
    }
    
   	if(cellphone.length > 20){
   		document.getElementById("errorDiv").innerHTML="Mobile Phone number should not be more than 20 digits in length";
   		reloadImage();
   		return false;
   	}

   /*	validation removed 
   	if(cellphone!=null && cellphone.length>0){
    	if(checkMobileNumber(cellphone)==false){   
    		document.getElementById("errorDiv").innerHTML="Enter Country code followed by Mobile Number<br/> like 91XXXXXXXXXX or 1XXXXXXXXXX";
   			reloadImage();
   			return false;
	   	}
    }
    */
   
    if(inCaptchaChars.length==0 || inCaptchaChars=="")
    {
    	document.getElementById("errorDiv").innerHTML="Please enter the security code <br>";
    	reloadImage();    	
    	return false;
    }
    var regId=document.r_form.regId.value;
  	var hidCaptchaID=document.r_form.hidCaptchaID.value;
    var url='registration.action?username='+username+'&password='+password_code+'&repassword='+repassword_code+'&firstName='+firstName+'&lastName='+lastName+'&cellphone='+cellphone+'&personalEmailAddress='+personalEmail+'&inCaptchaChars='+inCaptchaChars+'&hidCaptchaID='+hidCaptchaID+'&regId='+regId+'&timeZone='+timezone+'&time='+new Date().getTime();
   
	new Ajax.Request(url,
	{
		method:'get', 
		onLoading: function() {
		document.getElementById("errorDiv").innerHTML="Processing the registration request...";
		 },
 
		onSuccess: function(transport)
		{
		var response = transport.responseText || "Internal error occured in the server. Please try again later";
		 if(response=="PasswordFailure")	
		{
		document.getElementById('errorDiv').innerHTML = "Password and Confirm Password should match.";
		reloadImage();
		document.r_form.password.value="";
        document.r_form.repassword.value="";
        document.r_form.inCaptchaChars.value="";
		}
		else if(response=="SecurityCodeFailure")	
		{
		document.getElementById('errorDiv').innerHTML = "Security code does not match. Please try again";
		reloadImage();
		document.r_form.password.value="";
        document.r_form.repassword.value="";
        document.r_form.inCaptchaChars.value="";
		}
		else if(response=="ExistingFailure")	
		{
		document.getElementById('errorDiv').innerHTML = "Specified Email Id already exists. Please try with different id";
		reloadImage();
		document.r_form.password.value="";
        document.r_form.repassword.value="";
        document.r_form.inCaptchaChars.value="";
		}
		else if(response=="Failure")	
		{
		document.getElementById('errorDiv').innerHTML = "Registration not sucessful. Please try again later";
		reloadImage();
		document.r_form.password.value="";
        document.r_form.repassword.value="";
        document.r_form.inCaptchaChars.value="";
		}
		else if(response=="RIDInactive")	
		{
		document.getElementById('errorDiv').innerHTML = "This invitation is already used. Please sign up normally";
		reloadImage();
		document.r_form.password.value="";
        document.r_form.repassword.value="";
        document.r_form.inCaptchaChars.value="";
        document.r_form.regId.value="";
		}
		else
		{
		document.getElementById('loginDiv').innerHTML = response;
		document.getElementById('layer1').style.visibility="hidden";
		}
		},
		onFailure: function()
		{
			document.getElementById('errorDiv').innerHTML = "Unable to load the page. Please try again later";
		}
	});
}

/*

added new method of checkMail for Email id validation
 function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var msg="Invalid E-mail ID";
		if (str.indexOf(at)==-1){
		  document.getElementById("errorDiv").innerHTML=msg;
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 document.getElementById("errorDiv").innerHTML=msg;
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   document.getElementById("errorDiv").innerHTML=msg;
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		  document.getElementById("errorDiv").innerHTML=msg;
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("errorDiv").innerHTML=msg;
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById("errorDiv").innerHTML=msg;
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    document.getElementById("errorDiv").innerHTML=msg;
		    return false
		 }

 		 return true					
	}
	
*/	
function clearData()
{

	 reloadImage();
	 document.r_form.username.value="";
	 document.r_form.password.value="";
	 document.r_form.repassword.value="";
	 document.r_form.firstName.value=""; 
	 document.r_form.lastName.value="";
	 document.r_form.cellphone.value="";
	 //document.r_form.personalEmailAddress.value="";
	 document.r_form.inCaptchaChars.value="";
	 document.getElementById("errorDiv").innerHTML="";
	 
}
function closeDialog(val)
{
	userDetailsAction('UserDetailsAction.action',val);	
}
function onLoadingDiv(val)
{
	//alert(val);
	if(val == 1)	
		document.getElementById("diaplayDiv").innerHTML = document.getElementById("personal").innerHTML; 	
	else if(val == 2)	
		document.getElementById("diaplayDiv").innerHTML = document.getElementById("communication").innerHTML;
	else if(val == 3)
		document.getElementById("diaplayDiv").innerHTML = document.getElementById("location").innerHTML;
}
function closeWindow()
 { 
  window.close(); 
 }	
 function callMethod(status)
{
	if(status=='busy')
	document['statusImag'].src='images/busy.gif';
	else if(status=='available')
	document['statusImag'].src='images/buddyonline.gif';
	else if(status=='offline')
	document['statusImag'].src='images/buddy_offline.gif';
	changeUserAvailabilityStatus(status);
}	
function changeUserAvailabilityStatus(status)
{
var url='changeUserAvailabilityStatus.action?status='+status+'&time='+new Date().getTime();
//alert(url);
	new Ajax.Request(url,
	{
	method:'get', 
	onSuccess: function(transport)
	{
		var response = transport.responseText || "Internal error occured in the server. Please try again later";
		//document.getElementById('albumcontainer').innerHTML = response; 
	},
	onFailure: function()
	{
		document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
	}
	});

}


function get_radio_value()
{
var rad_val='DEVICE';
for (var i=0; i < document.myform.priority.length; i++)
   {
   if (document.myform.priority[i].checked)
      {
      var rad_val = document.myform.priority[i].value;
      }
   }
   
   var url='updateIMMessagePriority.action?devicePriority='+rad_val+'&time='+new Date().getTime();
	//alert(url);
	new Ajax.Request(url,
	{
	method:'get', 
	onSuccess: function(transport)
	{
		var response = transport.responseText || "Internal error occured in the server. Please try again later";
		//document.getElementById('albumcontainer').innerHTML = response; 
	},
	onFailure: function()
	{
		document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
	}
	});
}
function downloadMobileClient()
{
var phone_model="";
var modeOfDownload="";
	var symbianPath="";
	var symbianPathObj=document.getElementById('symbian');
	if(symbianPathObj != null && symbianPathObj != "undefined") {
			symbianPath = symbianPathObj.value;
		}
	var windowsMobilePath="";
	var windowsMobilePathObj=document.getElementById('windowsmobile');
	if(windowsMobilePathObj != null && windowsMobilePathObj != "undefined") {
			windowsMobilePath = windowsMobilePathObj.value;
		}
	var iphonePath="";
	var iphonePathObj=document.getElementById('iphone');
	if(iphonePathObj != null && iphonePathObj != "undefined") {
			iphonePath = iphonePathObj.value;
		}
	var blackBerryPath="";
	var blackBerryPathObj=document.getElementById('blackberry');
	if(blackBerryPathObj != null && blackBerryPathObj != "undefined") {
			blackBerryPath = blackBerryPathObj.value;
		}
for (var i=0; i < document.downloadForm.phone_model.length; i++)
   {
   if (document.downloadForm.phone_model[i].checked)
      {
      phone_model = document.downloadForm.phone_model[i].value;
      //alert(phone_model);
      }
   }
	for (var j=0; j < document.downloadForm.modeOfDownload.length; j++)
   {
   if (document.downloadForm.modeOfDownload[j].checked)
      {
      modeOfDownload = document.downloadForm.modeOfDownload[j].value;
      //alert(modeOfDownload);
      }
   }
	if(modeOfDownload == 'ota')
	{
	 document.getElementById('pc').style.display='none';
	 document.getElementById('ota').style.display='none';
	 document.getElementById('download').style.display='none';
	 document.getElementById('phone').style.visibility='visible';
	 document.getElementById('sendSMS').style.visibility='visible';
	
	 document.getElementById('sendSMS').style.display='block';   
	}
	else if(modeOfDownload == 'pc')
	{
		var displayURL="";
		
		if(phone_model=='symbian')
			{
			if(symbianPath != 'Coming soon')
			displayURL=' <br><br><br> <a href='+symbianPath+' class="urlLink" target="_blank"> Download </a> Symbian S60 3rd edition<br><br>Or<br> Copy and past the below url in browser addressbar <br> <font class="url">'+symbianPath+'</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 150px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			else
			displayURL='  <br><br><br> <font class="manage">Symbian S60 3rd edition</font> <br><br> <font class="url">Coming soon</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 170px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			
			}
		else if(phone_model=='windowsmobile')
			{
			if(windowsMobilePath != 'Coming soon')
			displayURL='  <br><br><br> <a href='+windowsMobilePath+' class="urlLink" target="_blank"> Download </a> Windows Mobile 6, 6.1 <br><br>Or<br> Copy and past the below url in addressbar <br> <font class="url"> '+windowsMobilePath+'</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 150px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			else
			displayURL='  <br><br><br> <font class="manage">Windows Mobile 6, 6.1</font><br><br> <font class="url">Coming soon</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 170px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			}
		else if(phone_model=='iphone')
			{
			if(iphonePath != 'Coming soon')
			displayURL='  <br><br><br> <a href='+iphonePath+' class="urlLink" target="_blank"> Download </a> iPhone <br><br>Or<br> Copy and past the below url in browser addressbar <br> <font class="url"> '+iphonePath+'</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 150px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
		else
			displayURL='  <br><br><br> <font class="manage">iPhone</font> <br><br> <font class="url">Coming soon</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 170px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			}
		else if(phone_model=='blackberry')
			{
			if(blackBerryPath != 'Coming soon')			
			displayURL='  <br><br><br> <a href='+blackBerryPath+' class="urlLink" target="_blank"> Download  </a> BlackBerry <br><br>Or<br> Copy and past the below url in browser addressbar <br> <font class="url"> '+blackBerryPath+'</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 150px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			else
			displayURL='  <br><br><br> <font class="manage">Blackberry </font><br><br> <font class="url">Coming soon</font><br><br><br><div class="button" style="margin-right:10px;padding-left: 170px;;"><a><span><input type="button" value="Cancel"  onclick="javascript:changingPassword(\'downloadMobileClient.jsp\');" ></span></a> </div>';
			}
		document.getElementById('albumarea').innerHTML=displayURL;
	}			
}

function sendSMS_downloadMobileClient(){
	
	var phoneNumber="";
	var phoneNumberObj=document.getElementById('phone_number');
	if(phoneNumberObj!=null && phoneNumberObj!='undefined'){
		phoneNumber = document.getElementById('phone_number').value;
		document.getElementById('phoneError').style.display='block';
		
		/* validation removed
		if(checkMobileNumber(phoneNumber)==false){
			
			document.getElementById('phoneErrorDiv').innerHTML = '<ul><li>Enter Country code followed by Mobile Number<br> like 91XXXXXXXXXX or 1XXXXXXXXXX</li></ul>';
			return false;
		}
		*/
	}
	
	var phoneModel="";
	 var smsMessage="";
	for (var i=0; i < document.downloadForm.phone_model.length; i++)
   {
   if (document.downloadForm.phone_model[i].checked)
      {
      phoneModel = document.downloadForm.phone_model[i].value;
      smsMessage = document.getElementById(phoneModel).value;
      //alert(phoneModel);
      //alert(smsMessage);
      }
   }
  
  var url = "sendSMSMessage.action";
	url=url+"?phoneNumber="+phoneNumber+"&sms_message="+smsMessage;	
	
	new Ajax.Request(url,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText;
			document.getElementById('albumarea').innerHTML = '<br><br><br><br><br>'+response+'to the Mobile Number   '+phoneNumber;		
			
		},
		onFailure:function()
		{
			document.getElementById('albumcontainer').innerHTML = '<br><br><br><br><br>'+'Unable to send SMS';
		}
	});
	
}

function checkMail(email){
    var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (pattern.test(email)) {
    return true;
    }
    return false;
 }

function checkFirstName(firstName){
	var pattern = /^([a-zA-Z])+((\.)?|(\s)?)([a-zA-Z])+$/;    
   	if(pattern.test(firstName)){
   		return true;
   	}
   	return false;	   

} 

function checkLastName(lastName){
	var pattern = /^([a-zA-Z])+((\.)?|(\s)?)([a-zA-Z])+$/;
   	if(pattern.test(lastName)){
   		return true;
   	}
   	return false;
} 

/*  valid mobilenumber check   919866111656(country code and number)
function checkMobileNumber(mobileNumber){
	var pattern = /^((((\d{1})|(\d{2})){1})(\d{10}){1})$/;
	//var pattern = /^((\+)?(\d{2}[-]))?(\d{10}){1}?$/; 
   	if(pattern.test(mobileNumber)){
   		return true;
   	}
   	return false;	   

 }
*/ 
 
function displayDatePicker(){
	var calendar;
	var dob = document.getElementById('dateOfBirth');
	document.getElementById('dateOfBirth').blur();
	calendar = new Epoch('epoch_popup','popup', dob);
	document.getElementById('dateOfBirth').focus();
	
}
function generalMoreInformation()
{
var url='moreInformation.jsp';
new Ajax.Request(url,
	{
		method:'get', // Use the 'GET' method		
		onSuccess: function(transport)
		{  
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('rightcontainer').innerHTML = response;
						 
		},
		onFailure: function()
		{
			document.getElementById('rightcontainer').innerHTML = "Unable to load the page. Please try again later ";
		}
	});
}
function updateNotificationEmails()
{
	var notifyForm = document.notificationForm;
	var shareAlbum ="no";
	var shareTrip = "no";
	if ( notifyForm.shareAlbum.checked) shareAlbum = "yes";
	if ( notifyForm.shareTrip.checked) shareTrip = "yes";
	var url='updateEmailNotification.action?emailNotifyWhenShareAlbum='+shareAlbum+'&emailNotifyWhenShareTrip='+shareTrip;
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{			
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			if(response != null && response == 'updated')
			{
			document.getElementById('notificationerror').innerHTML = 'Email Notifications updated successfully';
			}
			else
			document.getElementById('albumcontainer').innerHTML = response; // Put the response into the 'album' div
			
				
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});	
	
}

function updateAddressFromMap()
{
var address="";
var addressObj=document.getElementById('addressFromMap');
	if(addressObj != null && addressObj != "undefined") {
			address = addressObj.value;
		}
if(address == 'Address, city, state, zip')
{
document.getElementById('invalid').innerHTML='Enter valid address.';return false;
}
else
{
var url='updateAddressAction.action?'+'address2='+address;
new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{			
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			if(response != null && response=='updated')
			{
			document.getElementById('addressPopup').style.visibility='hidden';
			pollC('unique_1', 'load');
			}			
				
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});	
}
}

function home_tab()
{
	homePage_subTab();
	//homePage();
	homePageRightTile();
	 getUserLatestUpdates();
	searchBuddyOnFocus();
	//hideDiv('displaybuddies');
	hideDiv('minus');
	showDiv('plus');
	hideDiv('managabuddyrow');
  	hideDiv('search');
  	profilePage();
  	showDiv('downloadrow');
  	
	
}
function homePage_subTab(){
    var url='sub_Header_Home.jsp';
	new Ajax.Request(url,
	{
		method:'get', // Use the 'GET' method
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			 document.getElementById('home').innerHTML = response;						
						
		},
		onFailure: function()
		{
			document.getElementById('home').innerHTML = "Unable to load the page. Please try again";
		}
	});
}
function homePageRightTile()
{
	var url='homeRightTile.jsp';
	new Ajax.Request(url,
	{
	method:'get', // Use the 'GET' method
	onSuccess: function(transport)
	{
		var response = transport.responseText || "Internal error occured in the server. Please try again later";
		document.getElementById('rightcontainer').innerHTML = response;
					
	},
	onFailure: function()
	{
		document.getElementById('rightcontainer').innerHTML = "Unable to load the page. Please try again later";
	}
	});
}
function homePage() {
	var url='home.action';
	document.getElementById('albumcontainer').innerHTML = loader;
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{			
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});
	
} 
function getUserMailSearch(){
		
	var searchMailId = "";
	var searchMailIdObj=document.getElementById('search_email');
	if(searchMailIdObj != null && searchMailIdObj != "undefined") {
		searchMailId = searchMailIdObj.value;
	}
	
	if(searchMailId.length == 0 ||searchMailId.length>=45 || checkMail(searchMailId)==false )
	{
		document.getElementById('search-results').innerHTML = "";
		document.getElementById('errorDiv').innerHTML = '<br/>Enter valid Email Id ';return false;
	}
	else
	{
		url='getSerachUser.action';
		url=url+'?searchMailId='+searchMailId;
		
		document.getElementById('errorDiv').innerHTML = "";
				
		new Ajax.Request(url,
		{
			method:'get', 
			onSuccess: function(transport)
			{
				var response = transport.responseText || "Internal error occured in the server. Please try again later";								
				document.getElementById('search-results').innerHTML = response;				
			},
			onFailure: function()
			{
				document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please refresh the browser window";
			}
		});
	}
	document.getElementById('search_email').value="";
}

function getUserLatestUpdates(){

	var url='getUserUpdates.action';
	document.getElementById('albumcontainer').innerHTML = loader;
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response; // Put the response into the 'album' div
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please refresh the browser window";
		}
	});

} 

function getProfilePercentage() {
	var url='profilePercentage.action';
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{			
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			var color=response;		   //For progress bar
		  	var colorStatus=1.2*color;
		  	document.getElementById('percentage').innerHTML=color;
		   	document.getElementById('progressbar').style.width=colorStatus;
			
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});
	
}
function profilePage()
{
var url='myProfile.jsp';
	new Ajax.Request(url,
	{
		method:'get', 
		onSuccess: function(transport)
		{			
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('profile').innerHTML = response;
			getProfilePercentage();
			
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});
}  
function changeTheme(color)
{
	//document.location.href=("layout.jsp?time="+new Date().getTime()+'&color='+color);

	//document.location.href=("changeTheme.action?color="+color);
	var url='changeTheme.action?color='+color;
	new Ajax.Request(url,
	{
		method:'get',
		onSuccess: function(transport)
		{			
			document.location.href=("layout.jsp?time="+new Date().getTime());
					
			
		},
		onFailure: function()
		{
			document.location.href=("layout.jsp?time="+new Date().getTime());
		}
	});

} 

function sendMailsToUsers()
{
	var url='aapyaAdminForMails.jsp';
		document.getElementById('albumcontainer').innerHTML = loader;
	new Ajax.Request(url,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response;
			
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});
}
function sendMailsAction()
{
	var subject = "";
	var mailBody = "";
	var subjectObj=document.getElementById('subject');
	if(subjectObj != null && subjectObj != "undefined") {
		subject = subjectObj.value;
	}
	
	var mailBodyObj=document.getElementById('mailBody');
	if(mailBodyObj != null && mailBodyObj != "undefined") {
		mailBody = mailBodyObj.value;
	}
	var url='sendUpdatesToAllUsers.action?'+'subject='+subject+'&body='+mailBody;
	document.getElementById('albumcontainer').innerHTML = loader;
	new Ajax.Request(url,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText || "Internal error occured in the server. Please try again later";
			document.getElementById('albumcontainer').innerHTML = response;
			
		},
		onFailure: function()
		{
			document.getElementById('albumcontainer').innerHTML = "Unable to load the page. Please try again later";
		}
	});
}
