/*
	Developed By vikas kumar(Web Developer) 	
	Feel free to contact 
	Email Id: vicky.vikas.kr@gmail.com
	Mobile No: +919650980302
*/
function checkRegistration()
{
	flag=0;
	with(document.frm)
	{
		if(!isValidMail(email.value))
		{
			flag--;
			email.className='inp_err';
			$('#email_img_ok').fadeOut(200);
			$('#email_img_error').fadeIn(200);
			$('#email_text').fadeOut(300);
			$('#email_text').html("Please Enter Your Email. For example: example@gmail.com");
			$('#email_text').fadeIn(300);				
		}
		else
		{
			flag++;
			$('#email_img_error').fadeOut(200);
			$('#email_img_ok').fadeIn(200);			
			email.className='inp_ok';
			$('#email_text').fadeOut(300);
		}
		if(password.value=='')
		{
			flag--;
			password.className='inp_err';
			$('#password_img_ok').fadeOut(200);
			$('#password_img_error').fadeIn(200);
			$('#password_text').fadeOut(300);
			$('#password_text').html("Password can not be blank and at least 6 character long.");
			$('#password_text').fadeIn(300);						
		}
		else
		{
			flag=0;
			flag++;
			$('#password_img_error').fadeOut(200);
			$('#password_img_ok').fadeIn(200);			
			password.className='inp_ok';
			$('#password_text').fadeOut(300);
		}
		if(password.value.length < 6)
		{	
			flag--;
			password.className='inp_err';
			$('#password_img_ok').fadeOut(200);
			$('#password_img_error').fadeIn(200);
			$('#password_text').fadeOut(300);
			$('#password_text').html("Password must not be less than 6 character.");
			$('#password_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#password_img_error').fadeOut(200);
			$('#password_img_ok').fadeIn(200);			
			password.className='inp_ok';
			$('#password_text').fadeOut(300);
		}
		if(password.value=='' || conf_password.value!=password.value)
		{	
			flag--;
			conf_password.className='inp_err';
			$('#conf_password_img_ok').fadeOut(200);
			$('#conf_password_img_error').fadeIn(200);
			$('#conf_password_text').fadeOut(300);
			$('#conf_password_text').html("Password does not match.");
			$('#conf_password_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#conf_password_img_error').fadeOut(200);
			$('#conf_password_img_ok').fadeIn(200);			
			conf_password.className='inp_ok';
			$('#conf_password_text').fadeOut(300);
		}
		if(name.value=='')
		{	
			flag--;
			name.className='inp_err';
			$('#name_img_ok').fadeOut(200);
			$('#name_img_error').fadeIn(200);
			$('#name_text').fadeOut(300);
			$('#name_text').html("Name can not be blank.");
			$('#name_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#name_img_error').fadeOut(200);
			$('#name_img_ok').fadeIn(200);			
			name.className='inp_ok';
			$('#name_text').fadeOut(300);
		}
		if(state.value=='')
		{	
			flag--;
			state.className='inp_err';
			$('#state_img_ok').fadeOut(200);
			$('#state_img_error').fadeIn(200);
			$('#state_text').fadeOut(300);
			$('#state_text').html("Please select your state.");
			$('#state_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#state_img_error').fadeOut(200);
			$('#state_img_ok').fadeIn(200);			
			state.className='inp_ok';
			$('#state_text').fadeOut(300);
		}
		if(city.value=='')
		{	
			flag--;
			city.className='inp_err';
			$('#city_img_ok').fadeOut(200);
			$('#city_img_error').fadeIn(200);
			$('#city_text').fadeOut(300);
			$('#city_text').html("City can not be blank.");
			$('#city_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#city_img_error').fadeOut(200);
			$('#city_img_ok').fadeIn(200);			
			city.className='inp_ok';
			$('#city_text').fadeOut(300);
		}
		if(code.value=='')
		{	
			flag--;
			code.className='inp_err';
			$('#code_img_ok').fadeOut(200);
			$('#code_img_error').fadeIn(200);
			$('#code_text').fadeOut(300);
			$('#code_text').html("Please enter code which has been displyed on the above image.");
			$('#code_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#code_img_error').fadeOut(200);
			$('#code_img_ok').fadeIn(200);			
			city.className='inp_ok';
			$('#code_text').fadeOut(300);
		}
		if(flag==7)
			return true;
		else
			return false;
	}	
}
function classifiedForm()
{	
	with(document.classified_form)
	{
		if(document.classified_form.title)
		{
			if(title.value=='')
			{				
				title.className='inp_err';
				$('#title_img_ok').fadeOut(200);
				$('#title_img_error').fadeIn(200);
				$('#title_text').fadeOut(300);
				$('#title_text').html("Please Enter your classified title.");
				$('#title_text').fadeIn(300);
				title.focus();
				return false;
			}			
		}
		if(company_name)
		{
			if(company_name.value=='')
			{				
				company_name.className='inp_err';
				$('#company_name_img_ok').fadeOut(200);
				$('#company_name_img_error').fadeIn(200);
				$('#company_name_text').fadeOut(300);
				$('#company_name_text').html("Please Enter Company Name.");
				$('#company_name_text').fadeIn(300);
				company_name.focus();
				return false;
				
			}			
		}
		if(document.classified_form.position)
		{
			if(position.value=='')
			{				
				position.className='inp_err';
				$('#position_img_ok').fadeOut(200);
				$('#position_img_error').fadeIn(200);
				$('#position_text').fadeOut(300);
				$('#position_text').html("Please Enter Position.");
				$('#position_text').fadeIn(300);
				position.focus();
				return false;
			}			
		}
		if(document.classified_form.experience_year || document.classified_form.experience_month)
		{
			if(experience_year.value=='0' && experience_month.value=='0')
			{							
				$('#experience_img_ok').fadeOut(200);
				$('#experience_img_error').fadeIn(200);
				$('#experience_text').fadeOut(300);
				$('#experience_text').html("Please Select Experience.");
				$('#experience_text').fadeIn(300);
				experience_year.focus();
				return false;
			}			
		}
		if(document.classified_form.salary_from || document.classified_form.salary_to)
		{
			if(salary_from.value=='0' && salary_to.value=='0')
			{							
				$('#salary_img_ok').fadeOut(200);
				$('#salary_img_error').fadeIn(200);
				$('#salary_text').fadeOut(300);
				$('#salary_text').html("Please Select Salary.");
				$('#salary_text').fadeIn(300);	
				salary_from.focus();
				return false;
			}			
		}
		if(document.classified_form.title)
		{
			if(details.value=='')
			{	
				flag--;
				details.className='inp_err';
				$('#details_img_ok').fadeOut(200);
				$('#details_img_error').fadeIn(200);
				$('#details_text').fadeOut(300);
				$('#details_text').html("Please Enter your classified desctiption.");
				$('#details_text').fadeIn(300);
				details.focus();
				return false;
			}			
		}
		if(document.classified_form.price)
		{
			if(!CheckDigits(price.value))
			{				
				price.className='inp_err';
				$('#price_img_ok').fadeOut(200);
				$('#price_img_error').fadeIn(200);
				$('#price_text').fadeOut(300);
				$('#price_text').html("Please Enter the price in Rs.");
				$('#price_text').fadeIn(300);
				price.focus();
				return false;
			}			
		}
		if(!isValidMail(email.value))
		{			
			email.className='inp_err';
			$('#email_img_ok').fadeOut(200);
			$('#email_img_error').fadeIn(200);
			$('#email_text').fadeOut(300);
			$('#email_text').html("Please Enter Your Email. For example: example@gmail.com");
			$('#email_text').fadeIn(300);				
		}		
		if(code.value=='')
		{			
			code.className='inp_err';
			$('#code_img_ok').fadeOut(200);
			$('#code_img_error').fadeIn(200);
			$('#code_text').fadeOut(300);
			$('#code_text').html("Please enter code which has been displyed on the above image.");
			$('#code_text').fadeIn(300);	
			code.focus();
			return false;
		}		
	}
}
function checkLogin(full_path)
{
	with(document.login)
	{
		if(username.value=='- Enter Your Email Address -' || password.value=='Password')
		{
			$('#errordiv_login').fadeOut(300);
			$('#errordiv_login').fadeIn(300);
			return false;
		}
		else
		{
			$('#errordiv_login').fadeOut(500);			
			$("#main_error").html("<img src='"+full_path+"/public/images/ajax-loader.gif'/>");
			$('#main_error').fadeIn(500);
			$.post(
					full_path+"/ajax/login",
					{username: username.value,password: password.value},					
					function(response)
					{
						if(response=='go')						
							window.location.href=full_path+'/myprofile';						
						else
						{
							$('#main_error').html("<div class='errordiv' id='errordiv_login'></div>");
							$("#errordiv_login").html(response);
						}
					}						
				);			
		}		
	}
	return false;
}
function sendSuggestion(full_path)
{
	with(document.suggestion_form)
	{
		if(email.value=='- Enter Your Email Address -')
		{
			$('#suggestion_login').fadeOut(300);
			$('#suggestion_login').fadeIn(300);
			return false;
		}
		else if(!isValidMail(email.value))
		{
			$('#suggestion_login').fadeOut(300);
			$('#suggestion_login').html("Enter a valid email address.");
			$('#suggestion_login').fadeIn(300);
			return false;
		}
		else
		{
			$('#suggestion_login').fadeOut(500);						
			$.post(
					full_path+"/ajax/suggestion",
					{email: email.value,suggestion: suggestion.value},					
					function(response)
					{
						if(response=='sent')						
						{							
							$("#suggestion_login").html('Your suggestion has been sent successfully.');
							$('#suggestion_login').fadeIn(300);
						}						
					}						
				);			
		}		
	}
	return false;
}
function getContent(baseurl,page_url)
{
	$("#conlounge").hide();
	$("#aboutcontent").html("<img src='"+baseurl+"/public/images/ajax-loader.gif'/>");
	if(page_url!='ContactUs')
	{
		$.post(
				baseurl+"/ajax/staticpage",
				{page_url: page_url},					
				function(response)
				{
					if(response)
					{						
						$("#aboutcontent").html(response);
						$("#aboutcontent").fadeIn(500);
						//$("#aboutcontent").html(response);
					}
				}						
			);
	}
	else
	{
		$("#aboutcontent").hide();
		$("#conlounge").fadeIn(500);
	}
}
function showSubCategory(baseurl,id)
{		
	document.getElementById('subcategory').selectedIndex=1;
	if(document.getElementById('category').value!=""){
	$.post(
			baseurl+"/ajax/subcategory",
			{main_catid: id},					
			function(response)
			{				
				if(response)
					$("#subcate").html(response);					
			}						
		);
	}
}
function showSubCategoryChange(baseurl,id)
{	
	document.getElementById('change_subcategory').selectedIndex=1;	
	if(document.getElementById('change_category').value!=""){
	$.post(
			baseurl+"/ajax/subcategorychange",
			{main_catid: id},					
			function(response)
			{				
				if(response)
					$("#change_subcate").html(response);					
			}						
		);
	}
}
function isValidMail(mail)
{
	m=new String(mail);
	var mailLength=m.length
	var totalDOT=0;
	var totalROUTE=0;
	var totalSPACE=0;	
	if(m.charAt(0)=='@' || m.charAt(0) == '.')	
		return false;		
	 
	for(ctr=1;ctr<=mailLength;ctr++)
	{	if(m.charAt(ctr)=='@')		
			totalROUTE++;
		if(m.charAt(ctr)=='.')
			totalDOT++;
		if(m.charAt(ctr)==' ')
			totalSPACE++;
	}
	if(totalROUTE!=1)
		return false;
	if(totalDOT<1)
		return false;
	if(totalSPACE>0)
		return false;

	for(ctr=0;ctr<=mailLength;ctr++)
	{	
		if (m.charAt(ctr)=='`')	return false;	
		else if (m.charAt(ctr)=='!')	return false;	
		else if (m.charAt(ctr)==' ') 	return false;	
		else if (m.charAt(ctr)=='#')	return false;	
		else if (m.charAt(ctr)=='$')	return false;	
		else if (m.charAt(ctr)=='%')	return false;	
		else if (m.charAt(ctr)=='^')	return false;	
		else if (m.charAt(ctr)=='&')	return false;	
		else if (m.charAt(ctr)=='*')	return false;	
		else if (m.charAt(ctr)=='(')	return false;	
		else if (m.charAt(ctr)==')')	return false;	
		else if (m.charAt(ctr)=='+')	return false;	
		else if (m.charAt(ctr)=='=')	return false;	
		else if (m.charAt(ctr)=='|')	return false;	
		else if (m.charAt(ctr)=='\\')	return false;	
		else if (m.charAt(ctr)=='{')	return false;	
		else if (m.charAt(ctr)=='}')	return false;	
		else if (m.charAt(ctr)=='[')	return false;	
		else if (m.charAt(ctr)==']')	return false;	
		else if (m.charAt(ctr)==':')	return false;
		else if (m.charAt(ctr)==';')	return false;	
		else if (m.charAt(ctr)=='"')	return false;	
		else if (m.charAt(ctr)=="'")	return false;	
		else if (m.charAt(ctr)=='<')	return false;	
		else if (m.charAt(ctr)=='>')	return false;	
		else if (m.charAt(ctr)==',')	return false;	
		else if (m.charAt(ctr)=='?')	return false;	
		else if (m.charAt(ctr)=='/')	return false;	
	}
	return true;
}
function CheckDigits(TheNumber)
{
	var valid = 1
	var GoodChars = "0123456789"
	var i = 0
	if (TheNumber=="")
	{
		// Return false if number is empty
		valid = 0
	}
	for (i =0; i <= TheNumber.length -1; i++)
	{
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1)
		{
			// Note: Remove the comments from the following line to see this
			// for loop in action.
			// alert(TheNumber.charAt(i) + " is no good.")
			valid = 0
		} // End if statement
	} // End for loop
	return valid
}

function CheckAlphabet(character)
{
	var valid = 1
	character=character.toUpperCase();

	var GoodChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ."
	var i = 0
	if (character=="")
	{
		// Return false if number is empty
		valid = 0
	}
	for (i =0; i <= character.length -1; i++)
	{
		if (GoodChars.indexOf(character.charAt(i)) == -1)
		{
			// Note: Remove the comments from the following line to see this
			// for loop in action.
			// alert(character.charAt(i) + " is no good.")
			valid = 0
		} // End if statement
	} // End for loop
	return valid
}
function trim(s)
{
	while (s.substring(0,1) == ' ')
	{
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ')
	{
		s = s.substring(0,s.length-1);
	}
	return s;
}
var activewindow;
function openWindow(windowname)
{	
	document.getElementById(windowname).style.top="150px";
	document.getElementById(windowname).style.left="300px";
	$('#'+activewindow).fadeOut(500);
	$('#'+windowname).fadeIn(500);
	activewindow=windowname;	
}
function checkRegistrationOnblur(control,message)
{
	if(control.name=='email')
	{
		if(!isValidMail(control.value))
		{
			control.className='inp_err';
			$('#'+control.name+'_img_ok').fadeOut(200);
			$('#'+control.name+'_img_error').fadeIn(200);
			$('#'+control.name+'_text').fadeOut(300);
			$('#'+control.name+'_text').html(message);
			$('#'+control.name+'_text').fadeIn(300);	
		}
		else
		{
			$('#'+control.name+'_img_error').fadeOut(200);
			$('#'+control.name+'_img_ok').fadeIn(200);			
			control.className='inp_ok';
			$('#'+control.name+'_text').fadeOut(300);
		}
	}
	else if(control.name=='price')
	{
		if(!CheckDigits(control.value))
		{
			control.className='inp_err';
			$('#'+control.name+'_img_ok').fadeOut(200);
			$('#'+control.name+'_img_error').fadeIn(200);
			$('#'+control.name+'_text').fadeOut(300);
			$('#'+control.name+'_text').html(message);
			$('#'+control.name+'_text').fadeIn(300);	
		}
		else
		{
			$('#'+control.name+'_img_error').fadeOut(200);
			$('#'+control.name+'_img_ok').fadeIn(200);			
			control.className='inp_ok';
			$('#'+control.name+'_text').fadeOut(300);
		}
	}
	else if(control.name=='password')
	{
		if(control.value=='' || control.value.length<6)
		{			
			control.className='inp_err';
			$('#'+control.name+'_img_ok').fadeOut(200);
			$('#'+control.name+'_img_error').fadeIn(200);
			$('#'+control.name+'_text').fadeOut(300);
			$('#'+control.name+'_text').html(message);
			$('#'+control.name+'_text').fadeIn(300);						
		}
		else
		{			
			$('#'+control.name+'_img_error').fadeOut(200);
			$('#'+control.name+'_img_ok').fadeIn(200);			
			control.className='inp_ok';
			$('#'+control.name+'_text').fadeOut(300);
		}
	}
	else if(control.name=='conf_password')
	{
		if(control.value=='' || document.frm.password.value != control.value)
		{			
			control.className='inp_err';
			$('#'+control.name+'_img_ok').fadeOut(200);
			$('#'+control.name+'_img_error').fadeIn(200);
			$('#'+control.name+'_text').fadeOut(300);
			$('#'+control.name+'_text').html(message);
			$('#'+control.name+'_text').fadeIn(300);						
		}
		else
		{			
			$('#'+control.name+'_img_error').fadeOut(200);
			$('#'+control.name+'_img_ok').fadeIn(200);			
			control.className='inp_ok';
			$('#'+control.name+'_text').fadeOut(300);
		}
	}
	else if(control.value=='')
	{			
		control.className='inp_err';
		$('#'+control.name+'_img_ok').fadeOut(200);
		$('#'+control.name+'_img_error').fadeIn(200);
		$('#'+control.name+'_text').fadeOut(300);
		$('#'+control.name+'_text').html(message);
		$('#'+control.name+'_text').fadeIn(300);						
	}
	else
	{			
		$('#'+control.name+'_img_error').fadeOut(200);
		$('#'+control.name+'_img_ok').fadeIn(200);			
		control.className='inp_ok';
		$('#'+control.name+'_text').fadeOut(300);
	}		
}
function changeLocation(full_path)
{	
	if(document.classified_form.state.value=='')
	{
		$('#errordiv_location').fadeOut(300);			
		$('#errordiv_location').fadeIn(300);		
	}
	else if(document.classified_form.city.value=='')
	{		
		$('#errordiv_location').fadeOut(300);			
		$('#errordiv_location').fadeIn(300);		
	}
	else
	{		
		$.post(
			full_path+"/ajax/changelocation",
			{state_id: document.classified_form.state.value,city: document.classified_form.city.value},					
			function(response)
			{				
				if(response)
				{					
					$('#errordiv_location').fadeOut(300);			
					$("#state_name").html(response);	
					$("#city_name").html(document.classified_form.city.value);	
					$('#changelocation').fadeOut(300);
				}								
			}						
		);
	}
	return false
}
function changeCategory(full_path,category)
{	
	if(document.classified_form.change_category.value=='')
	{
		$('#errordiv_category').fadeOut(300);			
		$('#errordiv_category').fadeIn(300);		
	}	
	else if(document.classified_form.change_subcategory.value=='')
	{
		$('#errordiv_category').fadeOut(300);			
		$('#errordiv_category').fadeIn(300);		
	}
	else
	{		
		$.post(
			full_path+"/ajax/changecategory",
			{category: document.classified_form.change_category.value,subcategory: document.classified_form.change_subcategory.value},					
			function(response)
			{				
				if(response)
				{
					response=response.split('brk');
					$('#errordiv_category').fadeOut(300);			
					$("#category_name").html(response[0]);	
					$("#subcategory_name").html(response[1]);	
					$('#changecategory').fadeOut(300);
					if(category != document.classified_form.change_category.value)
						window.location.href=full_path+'/classified';
				}								
			}						
		);
	}
	return false
}
//setCookie('image',img,1);
function setCookie(c_name,value,expiredays)
{
	//alert(value);
	var exdate=new Date();
	var path = '/';
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ 
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+
	( ( path ) ? "; path=" + path : "" )  ;
}
function getCookie(c_name)
{
	if(document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1)
		{
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function myProfileEdit(div_id)
{
	var action=$("#"+div_id+" a").html();
	if(action=='EDIT')
	{
		$("#"+div_id+" .your_detailsbg").hide();
		$("#"+div_id+" a").html('CANCEL');
		$("#"+div_id+" .currentt").fadeIn(800);	
	}
	else
	{		
		$("#"+div_id+" .currentt").hide();	
		$("#"+div_id+" .your_detailsbg").fadeIn(800);
		$("#"+div_id+" a").html('EDIT');
	}
}
function updateInfo(full_path,div_id,control_name)
{
	$.post(
			full_path+"/ajax/updateinfo",
			{field_name: control_name,field_value: $("#"+control_name).val()},					
			function(response)
			{				
				if(response)
				{
					$("#"+div_id+" span").html(response);
					myProfileEdit(div_id);
				}								
			}						
		);
}
function listAds(full_path,cate_id,page)
{	
	width=screen.width/2;
	height=screen.height/2;
	width=width-100;	
	document.getElementById("loader").style.left=width+"px"
	document.getElementById("loader").style.top=height+"px";
	$("#loader").show();
	var sortby=$("#sortby").val();
	
	if(document.getElementById('amount'))
		var price_range=$("#amount").val();
	else	
		var price_range="";
	
	if(document.getElementById('experience'))
		var experience_range=$("#experience").val();
	else	
		var experience_range="";
	if(document.getElementById('professional').checked==true)
		var professional=$("#professional").val();
	else	
		var professional="";
		
	if(document.getElementById('invividual').checked==true)
		var invividual=$("#invividual").val();
	else	
		var invividual="";	
		
	if(document.getElementById('yespic').checked==true)
		var yespic=$("#yespic").val();
	else	
		var yespic="";		
	
	$.post(
			full_path+"/ajax/listads",
			{cate_id: cate_id,sortby:sortby,price_range:price_range,professional:professional,invividual:invividual,yespic:yespic,experience_range:experience_range,page:page},					
			function(response)
			{				
				if(response)
				{
					$("#loader").hide();
					$("#listingleft").hide();
					$("#listingleft").html(response);
					$("#listingleft").slideDown('slow');
				}								
			}						
		);
}
function checkContactForm()
{
	flag=0;
	with(document.contact_form)
	{
		if(!isValidMail(email.value))
		{
			flag--;
			email.className='inp_err';
			$('#email_img_ok').fadeOut(200);
			$('#email_img_error').fadeIn(200);
			$('#email_text').fadeOut(300);
			$('#email_text').html("Please Enter Your Email. For example: example@gmail.com");
			$('#email_text').fadeIn(300);				
		}
		else
		{
			flag++;
			$('#email_img_error').fadeOut(200);
			$('#email_img_ok').fadeIn(200);			
			email.className='inp_ok';
			$('#email_text').fadeOut(300);
		}
		if(fullname.value=='')
		{
			flag--;
			fullname.className='inp_err';
			$('#fullname_img_ok').fadeOut(200);
			$('#fullname_img_error').fadeIn(200);
			$('#fullname_text').fadeOut(300);
			$('#fullname_text').html("Name can not be blank.");
			$('#fullname_text').fadeIn(300);						
		}
		else
		{
			flag=0;
			flag++;
			$('#fullname_img_error').fadeOut(200);
			$('#fullname_img_ok').fadeIn(200);			
			fullname.className='inp_ok';
			$('#fullname_text').fadeOut(300);
		}		
		if(subject.value=='')
		{	
			flag--;
			subject.className='inp_err';
			$('#subject_img_ok').fadeOut(200);
			$('#subject_img_error').fadeIn(200);
			$('#subject_text').fadeOut(300);
			$('#subject_text').html("Subject can not be blank.");
			$('#subject_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#subject_img_error').fadeOut(200);
			$('#subject_img_ok').fadeIn(200);			
			subject.className='inp_ok';
			$('#subject_text').fadeOut(300);
		}
		if(message.value=='')
		{	
			flag--;
			message.className='inp_err';
			$('#message_img_ok').fadeOut(200);
			$('#message_img_error').fadeIn(200);
			$('#message_text').fadeOut(300);
			$('#message_text').html("Message can not be blank.");
			$('#message_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#message_img_error').fadeOut(200);
			$('#message_img_ok').fadeIn(200);			
			message.className='inp_ok';
			$('#message_text').fadeOut(300);
		}		
		if(code.value=='')
		{	
			flag--;
			code.className='inp_err';
			$('#code_img_ok').fadeOut(200);
			$('#code_img_error').fadeIn(200);
			$('#code_text').fadeOut(300);
			$('#code_text').html("Please enter code which has been displyed on the image.");
			$('#code_text').fadeIn(300);						
		}
		else
		{
			flag++;
			$('#code_img_error').fadeOut(200);
			$('#code_img_ok').fadeIn(200);			
			city.className='inp_ok';
			$('#code_text').fadeOut(300);
		}
		if(flag==7)
			return true;
		else
			return false;
	}
}
function checkFacebookDetails()
{
	var flag=0;
	with(document.frm)
	{		
		if(!isValidMail(email.value))
		{
			flag--;
			email.className='inp_err';
			$('#email_img_ok').fadeOut(200);
			$('#email_img_error').fadeIn(200);
			$('#email_text').fadeOut(300);
			$('#email_text').html("Please Enter Your Email. For example: example@gmail.com");
			$('#email_text').fadeIn(300);				
		}
		else
		{
			flag++;
			$('#email_img_error').fadeOut(200);
			$('#email_img_ok').fadeIn(200);			
			email.className='inp_ok';
			$('#email_text').fadeOut(300);
		}
		if(flag==1)
			return true;
		else
			return false;
	}
}
function checkContactLister()
{
	var flag=0;
	with(document.contact_lister)
	{			
		if(name.value=="Your Full Name")
		{
			flag--;						
			$('#name_text').fadeOut(300);			
			$('#name_text').fadeIn(300);				
		}
		else
		{
			flag++;								
			$('#name_text').fadeOut(300);
		}
		if(!isValidMail(email.value))
		{
			flag--;						
			$('#email_text').fadeOut(300);			
			$('#email_text').fadeIn(300);				
		}
		else
		{
			flag++;								
			$('#email_text').fadeOut(300);
		}
		if(contact_message.value=="")
		{
			flag--;						
			$('#contact_message_text').fadeOut(300);			
			$('#contact_message_text').fadeIn(300);				
		}
		else
		{
			flag++;								
			$('#contact_message_text').fadeOut(300);
		}
		if(code.value=="")
		{
			flag--;						
			$('#code_text').fadeOut(300);			
			$('#code_text').fadeIn(300);				
		}
		else
		{
			flag++;								
			$('#code_text').fadeOut(300);
		}
		if(flag==4)
			return true;
		else
			return false;
	}
}
function postComment(full_path,classified_id,control_name)
{
	document.getElementById('postcomment_button').value='POSTING...';
	var div_id="recent_comments";
	$.post(
			full_path+"/ajax/postcomment",
			{classified_id:classified_id,comment: $("#"+control_name).val()},					
			function(response)
			{				
				if(response)
				{
					$('#postcomment').fadeOut(500);
					$("#"+div_id).slideUp('slow');
					$("#"+div_id).html(response);
					$("#"+div_id).slideDown('slow');
					
				}								
			}						
		);
}
function postCommentFromFavorite(full_path,classified_id,control_name)
{
	document.getElementById('postcomment_button').value='POSTING...';	
	$.post(
			full_path+"/ajax/postcomment",
			{classified_id:classified_id,comment: $("#"+control_name).val()},					
			function(response)
			{				
				if(response)
				{
					$('#postcomment').fadeOut(500);					
				}								
			}						
		);
}
function modifyPostCommentButton(full_path,adid)
{
	$("#post_button_new").html("<input type='button' class='sendbtn' value='POST >>' id='postcomment_button' onclick='postCommentFromFavorite(\""+full_path+"\","+adid+",\"comment\");'/>");
}
function checkLoginPage()
{
	var flag=0;
	with(document.login_page_frm)
	{		
		if(!isValidMail(login_username.value))
		{
			flag--;
			login_username.className='inp_err';
			$('#login_username_img_ok').fadeOut(200);
			$('#login_username_img_error').fadeIn(200);
			$('#login_username_text').fadeOut(300);
			$('#login_username_text').html("Please Enter Your Email. For example: example@gmail.com");
			$('#login_username_text').fadeIn(300);				
		}
		else
		{
			flag++;
			$('#login_username_img_error').fadeOut(200);
			$('#login_username_img_ok').fadeIn(200);			
			login_username.className='inp_ok';
			$('#login_username_text').fadeOut(300);
		}
		if(login_password.value=="")
		{
			flag--;
			login_password.className='inp_err';
			$('#login_password_img_ok').fadeOut(200);
			$('#login_password_img_error').fadeIn(200);
			$('#login_password_text').fadeOut(300);
			$('#login_password_text').html("Please Enter Your Password.");
			$('#login_password_text').fadeIn(300);				
		}
		else
		{
			flag++;
			$('#login_password_img_error').fadeOut(200);
			$('#login_password_img_ok').fadeIn(200);			
			login_password.className='inp_ok';
			$('#login_password_text').fadeOut(300);
		}
		if(flag==2)
			return true;
		else
			return false;
	}
}
function checkAll(checkedControl)
{
	controlName=checkedControl.name;
	total=document.getElementsByName(controlName);
	if(checkedControl.checked)
	{
		for(var i=0;i<total.length;i++)
		{
			total[i].checked=true;
		}
	}
	else
	{
		for(var i=0;i<total.length;i++)
		{
			total[i].checked=false;
		}
	}
}
function addToFavorite(full_path,classified_id)
{
	var div_id="addtofavorite";
	$("#"+div_id).html("<a href='javascript:void(0)'>Adding...</a>");
	$.post(
			full_path+"/ajax/adtofavorite",
			{classified_id:classified_id},					
			function(response)
			{				
				if(response)				
					$("#"+div_id).html(response);											
			}						
		);
}
function replyMessage(windowname,from_name,from_email)
{	
	document.getElementById(windowname).style.top="150px";
	document.getElementById(windowname).style.left="300px";
	$("#replyname").html("Reply to "+from_name);
	document.getElementById('to_email').value="Re: "+from_email;	
	$('#'+windowname).fadeIn(500);	
}
function readMessage(windowname,from_name,from_email,message)
{	
	document.getElementById(windowname).style.top="150px";
	document.getElementById(windowname).style.left="300px";
	$("#name_from").html(from_name);
	$("#message_read_full").html(message);	
	$('#'+windowname).fadeIn(500);	
}
function checkEmailElert(full_path)
{
	with(document.email_alert_frm)
	{
		if(alert_keyword.value=="- Enter Keywords -")
		{
			$("#errordiv_emailalert").fadeOut(500);
			$("#errordiv_emailalert").fadeIn(500);
			alert_keyword.focus();
			return false;
		}
		else if(!isValidMail(alert_email.value))
		{
			$("#errordiv_emailalert").fadeOut(500);
			$("#errordiv_emailalert").fadeIn(500);
			alert_email.focus();
			return false;
		}
		else if(alert_state.value=="")
		{
			$("#errordiv_emailalert").fadeOut(500);
			$("#errordiv_emailalert").fadeIn(500);
			alert_state.focus();
			return false;
		}
		else if(alert_type.value=="")
		{
			$("#errordiv_emailalert").fadeOut(500);
			$("#errordiv_emailalert").fadeIn(500);
			alert_type.focus();
			return false;
		}
		else
		{
			var div_id="email_alert_submit";
			document.getElementById(div_id).value="SUBSCRIBEING....";
			$.post(
					full_path+"/ajax/subscribealert",
					{keyword:alert_keyword.value,email:alert_email.value,state:alert_state.value,type:alert_type.value},					
					function(response)
					{				
						if(response)						
							$('#emailalert').fadeOut(500);																		
					}						
				);
			return false;			
		}
	}
	
}
function checkUnsubscribe(full_path)
{
	with(document.unsubscribe_frm)
	{
		if(!isValidMail(alert_email.value))
		{
			$("#unsubscribe_error").fadeOut(500);
			$("#unsubscribe_error").fadeIn(500);
			alert_email.focus();
			return false;
		}		
		else
		{
			var div_id="unsubscribe_submit";
			document.getElementById(div_id).value="SENDING....";
			$.post(
					full_path+"/ajax/unsubscribealert",
					{email:alert_email.value},					
					function(response)
					{				
						if(response=="Not Done")						
						{
							$("#unsubscribe_error").html("Email address does not exist.");
							document.getElementById(div_id).value="SEND";
							$("#unsubscribe_error").fadeOut(500);
							$("#unsubscribe_error").fadeIn(500);
						}
						else
							$('#unsubscribe').fadeOut(500);																		
					}						
				);
			return false;			
		}
	}
	
}