/*
 * Interface elements for jQuery - http://interface.eyecon.ro
 *
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 */
 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('6.15={3o:d(e){7 x=0;7 y=0;7 1Q=1A;7 A=e.L;8(6(e).H(\'Q\')==\'U\'){1E=A.1a;2y=A.O;A.1a=\'1F\';A.Q=\'1Y\';A.O=\'2e\';1Q=26}7 4=e;2P(4){x+=4.3B+(4.1I&&!6.3p.41?F(4.1I.2X)||0:0);y+=4.3x+(4.1I&&!6.3p.41?F(4.1I.2Z)||0:0);4=4.4e}4=e;2P(4&&4.4a&&4.4a.39()!=\'V\'){x-=4.1D||0;y-=4.1s||0;4=4.2x}8(1Q){A.Q=\'U\';A.O=2y;A.1a=1E}q{x:x,y:y}},4E:d(4){7 x=0,y=0;2P(4){x+=4.3B||0;y+=4.3x||0;4=4.4e}q{x:x,y:y}},35:d(e){7 w=6.H(e,\'1T\');7 h=6.H(e,\'36\');7 1e=0;7 1o=0;7 A=e.L;8(6(e).H(\'Q\')!=\'U\'){1e=e.1z;1o=e.2s}u{1E=A.1a;2y=A.O;A.1a=\'1F\';A.Q=\'1Y\';A.O=\'2e\';1e=e.1z;1o=e.2s;A.Q=\'U\';A.O=2y;A.1a=1E}q{w:w,h:h,1e:1e,1o:1o}},4P:d(4){q{1e:4.1z||0,1o:4.2s||0}},58:d(e){7 h,w,22;8(e){w=e.2a;h=e.29}u{22=D.Y;w=2z.3c||2N.3c||(22&&22.2a)||D.V.2a;h=2z.31||2N.31||(22&&22.29)||D.V.29}q{w:w,h:h}},3P:d(e){7 t,l,w,h,1J,1R;8(e&&e.2E.39()!=\'V\'){t=e.1s;l=e.1D;w=e.3j;h=e.3e;1J=0;1R=0}u{8(D.Y&&D.Y.1s){t=D.Y.1s;l=D.Y.1D;w=D.Y.3j;h=D.Y.3e}u 8(D.V){t=D.V.1s;l=D.V.1D;w=D.V.3j;h=D.V.3e}1J=2N.3c||D.Y.2a||D.V.2a||0;1R=2N.31||D.Y.29||D.V.29||0}q{t:t,l:l,w:w,h:h,1J:1J,1R:1R}},3L:d(e,1U){7 4=6(e);7 t=4.H(\'2j\')||\'\';7 r=4.H(\'2k\')||\'\';7 b=4.H(\'2n\')||\'\';7 l=4.H(\'2l\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)};u q{t:t,r:r,b:b,l:l}},56:d(e,1U){7 4=6(e);7 t=4.H(\'3w\')||\'\';7 r=4.H(\'3u\')||\'\';7 b=4.H(\'3s\')||\'\';7 l=4.H(\'3t\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)};u q{t:t,r:r,b:b,l:l}},4Z:d(e,1U){7 4=6(e);7 t=4.H(\'2Z\')||\'\';7 r=4.H(\'3G\')||\'\';7 b=4.H(\'3y\')||\'\';7 l=4.H(\'2X\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)||0};u q{t:t,r:r,b:b,l:l}},3T:d(2i){7 x=2i.53||(2i.52+(D.Y.1D||D.V.1D))||0;7 y=2i.51||(2i.54+(D.Y.1s||D.V.1s))||0;q{x:x,y:y}},3h:d(12,3g){3g(12);12=12.3F;2P(12){6.15.3h(12,3g);12=12.5a}},59:d(12){6.15.3h(12,d(4){S(7 1j 1q 4){8(2R 4[1j]===\'d\'){4[1j]=20}}})},57:d(4,27){7 1b=$.15.3P();7 3l=$.15.35(4);8(!27||27==\'4Y\')$(4).H({X:1b.t+((1i.3S(1b.h,1b.1R)-1b.t-3l.1o)/2)+\'K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*\\)$/.2A(16))q{r:Z(M[1])*2.55,g:Z(M[2])*2.55,b:Z(M[3])*2.55};u 8(M=/^#([a-1H-1B-9])([a-1H-1B-9])([a-1H-1B-9])$/.2A(16))q{r:F("1C"+M[1]+M[1]),g:F("1C"+M[2]+M[2]),b:F("1C"+M[3]+M[3])};u 8(M=/^#([a-1H-1B-9]{2})([a-1H-1B-9]{2})([a-1H-1B-9]{2})$/.2A(16))q{r:F("1C"+M[1]),g:F("1C"+M[2]),b:F("1C"+M[3])};u q 3z==26?1A:{r:B,g:B,b:B}};6.E.4n={3y:1,2X:1,3G:1,2Z:1,5S:1,5B:1,36:1,N:1,5W:1,5X:1,2n:1,2l:1,2k:1,2j:1,62:1,2T:1,61:1,6w:1,1f:1,5Y:1,5Z:1,3s:1,3t:1,3u:1,3w:1,38:1,5Q:1,X:1,1T:1,2O:1};6.E.49={5P:1,5G:1,5H:1,5F:1,5E:1,16:1,5C:1};6.E.25=[\'5D\',\'5I\',\'5J\',\'5O\'];6.E.3k={\'3d\':[\'24\',\'3W\'],\'2B\':[\'24\',\'3f\'],\'2D\':[\'2D\',\'\'],\'2C\':[\'2C\',\'\']};6.3Q.4b({5N:d(1h,1G,P,2v){q k.2d(d(){7 2t=6.1G(1G,P,2v);7 e=28 6.4m(k,2t,1h)})},37:d(1G,2v){q k.2d(d(){7 2t=6.1G(1G,2v);7 e=28 6.37(k,2t)})},5M:d(14){q k.1V(d(){8(k.1n)6.3m(k,14)})},5K:d(14){q k.1V(d(){8(k.1n)6.3m(k,14);8(k.2d&&k.2d[\'E\'])k.2d.E=[]})}});6.4b({37:d(C,o){7 z=k,4o;z.14=d(){8(6.43(o.2M))o.2M.3Z(C)};z.2h=3O(d(){z.14()},o.1k);C.1n=z},P:{4q:d(p,n,4j,4d,1k){q((-1i.5L(p*1i.63)/2)+0.5)*4d+4j}},4m:d(C,o,1h){7 z=k,4o;7 y=C.L;7 44=6.H(C,"2K");7 1O=6.H(C,"Q");7 G={};z.2L=(28 46()).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1P 1q 1c){k.2Q(1P,1c[1P])}}u 8(p==\'3X\'){8(D.2S)S(7 i=0;i<D.2S.1m;i++){7 1K=D.2S[i].1K||D.2S[i].6i||20;8(1K){S(7 j=0;j<1K.1m;j++){8(1K[j].6h==\'.\'+1h[p]){7 1X=28 69(\'\\.\'+1h[p]+\' {\');7 1g=1K[j].L.68;7 1c=6.30(1g.1t(1X,\'\').1t(/}/g,\'\'));S(1P 1q 1c){k.2Q(1P,1c[1P])}}}}}}u{k.2Q(p,1h[p])}}y.Q=1O==\'U\'?\'1Y\':1O;y.2K=\'1F\';z.14=d(){7 t=(28 46()).48();8(t>o.1k+z.2L){4h(z.2h);z.2h=20;S(p 1q G){8(p=="1f")6.1j(y,"1f",G[p][1]);u 8(2R G[p][1]==\'2V\')y[p]=\'1N(\'+G[p][1].r+\',\'+G[p][1].g+\',\'+G[p][1].b+\')\';u y[p]=G[p][1]+(p!=\'2O\'&&p!=\'34\'?\'K\':\'\')}8(o.2G||o.2H)S(7 p 1q C.1r)8(p=="1f")6.1j(y,p,C.1r[p]);u y[p]="";y.Q=o.2G?\'U\':(1O!=\'U\'?1O:\'1Y\');y.2K=44;C.1n=20;8(6.43(o.2M))o.2M.3Z(C)}u{7 n=t-k.2L;7 2c=n/o.1k;S(p 1q G){8(2R G[p][1]==\'2V\'){y[p]=\'1N(\'+F(6.P[o.P](2c,n,G[p][0].r,(G[p][1].r-G[p][0].r),o.1k))+\',\'+F(6.P[o.P](2c,n,G[p][0].g,(G[p][1].g-G[p][0].g),o.1k))+\',\'+F(6.P[o.P](2c,n,G[p][0].b,(G[p][1].b-G[p][0].b),o.1k))+\')\'}u{7 2W=6.P[o.P](2c,n,G[p][0],(G[p][1]-G[p][0]),o.1k);8(p=="1f")6.1j(y,"1f",2W);u y[p]=2W+(p!=\'2O\'&&p!=\'34\'?\'K\':\'\')}}}};z.2h=3O(d(){z.14()},13);C.1n=z},3m:d(C,14){8(14)C.1n.2L-=67;u{2z.4h(C.1n.2h);C.1n=20;6.65(C,"E")}}});6.30=d(1g){7 1c={};8(2R 1g==\'66\'){1g=1g.39().40(\';\');S(7 i=0;i<1g.1m;i++){1X=1g[i].40(\':\');8(1X.1m==2){1c[6.45(1X[0].1t(/\\-(\\w)/g,d(m,c){q c.6a()}))]=6.45(1X[1])}}}q 1c};6.1u={3K:d(o){q k.1V(d(){7 4=k;4.f={10:6(o.10,k),23:6(o.23,k),21:6.15.3o(k),T:o.T,2p:o.2p,1Z:o.1Z,3Y:o.3Y,17:o.17,2T:o.2T};6.1u.2J(4,0);6(2z).2F(\'6b\',d(){4.f.21=6.15.3o(4);6.1u.2J(4,0);6.1u.3i(4)});6.1u.3i(4);4.f.10.2F(\'6g\',d(){6(4.f.2p,k).1S(0).L.Q=\'1Y\'}).2F(\'6f\',d(){6(4.f.2p,k).1S(0).L.Q=\'U\'});6(D).2F(\'6e\',d(e){7 2g=6.15.3T(e);7 19=0;8(4.f.17&&4.f.17==\'3M\')7 2o=2g.x-4.f.21.x-(4.1z-4.f.T*4.f.10.1W())/2-4.f.T/2;u 8(4.f.17&&4.f.17==\'38\')7 2o=2g.x-4.f.21.x-4.1z+4.f.T*4.f.10.1W();u 7 2o=2g.x-4.f.21.x;7 3D=1i.3C(2g.y-4.f.21.y-4.2s/2,2);4.f.10.1V(d(2m){11=1i.6c(1i.3C(2o-2m*4.f.T,2)+3D);11-=4.f.T/2;11=11<0?0:11;11=11>4.f.1Z?4.f.1Z:11;11=4.f.1Z-11;3a=4.f.2T*11/4.f.1Z;k.L.1T=4.f.T+3a+\'K\';k.L.N=4.f.T*2m+19+\'K\';19+=3a});6.1u.2J(4,19)})})},2J:d(4,19){8(4.f.17)8(4.f.17==\'3M\')4.f.23.1S(0).L.N=(4.1z-4.f.T*4.f.10.1W())/2-19/2+\'K\';u 8(4.f.17==\'N\')4.f.23.1S(0).L.N=-19/4.f.10.1W()+\'K\';u 8(4.f.17==\'38\')4.f.23.1S(0).L.N=(4.1z-4.f.T*4.f.10.1W())-19/2+\'K\';4.f.23.1S(0).L.1T=4.f.T*4.f.10.1W()+19+\'K\'},3i:d(4){4.f.10.1V(d(2m){k.L.1T=4.f.T+\'K\';k.L.N=4.f.T*2m+\'K\'})}};6.3Q.6d=6.1u.3K;',62,456,'||||el||jQuery|var|if|||||function||fisheyeCfg|||||this||||options||return||||else||||||es|255|elem|document|fx|parseInt|props|css|tp|oldStyle|px|style|result|left|position|easing|display|wrs|for|itemWidth|none|body|vp|top|documentElement|parseFloat|items|distance|nodeEl||step|iUtil|color|halign|margins|toAdd|visibility|clientScroll|newStyles|cs|wb|opacity|styles|prop|Math|attr|duration|nmp|length|animationHandler|hb|old|in|orig|scrollTop|replace|iFisheye|128|parseColor|wr|curCSS|offsetWidth|false|F0|0x|scrollLeft|oldVisibility|hidden|speed|fA|currentStyle|iw|cssRules|139|0px|rgb|oldDisplay|np|restoreStyle|ih|get|width|toInteger|each|size|rule|block|proximity|null|pos|de|container|border|cssSides|true|axis|new|clientHeight|clientWidth|case|pr|queue|absolute|namedColors|pointer|timer|event|marginTop|marginRight|marginLeft|nr|marginBottom|posx|itemsText|test|sideEnd|offsetHeight|opt|src|callback|png|parentNode|oldPosition|window|exec|borderColor|padding|margin|nodeName|bind|hide|show|192|positionContainer|overflow|startTime|complete|self|zIndex|while|getValues|typeof|styleSheets|maxWidth|211|object|pValue|borderLeftWidth|oldFloat|borderTopWidth|parseStyle|innerHeight|sizes|relative|fontWeight|getSize|height|pause|right|toLowerCase|extraWidth|169|innerWidth|borderWidth|scrollHeight|Color|func|traverseDOM|positionItems|scrollWidth|cssSidesEnd|windowSize|stopAnim|floatVal|getPosition|browser|img|224|paddingBottom|paddingLeft|paddingRight|230|paddingTop|offsetTop|borderBottomWidth|notColor|fxCheckTag|offsetLeft|pow|posy|240|firstChild|borderRightWidth|165|140|wid|build|getMargins|center|toggle|setInterval|getScroll|fn|break|max|getPointer|emptyGIF|images|Width|className|valign|apply|split|opera||isFunction|oldOverflow|trim|Date||getTime|colorCssProps|tagName|extend|144|delta|offsetParent|insertBefore|styleFloat|clearInterval|indexOf|firstNum|107|245|fxe|cssProps|values|10000|linear|azure|dl|220|iframe|ul|beige|table|button|form|appendChild|fxWrapper|listStyle|cssFloat|getPositionLite|id|msie|ol|wrapper|div|aqua|td|filter|progid|fixPNG|getSizeLite|horizontally|DXImageTransform|Microsoft|tr|prototype|Array|AlphaImageLoader|black|vertically|getBorder||pageY|clientX|pageX|clientY||getPadding|centerEl|getClient|purgeEvents|nextSibling|tbody|caption|float|w_|buildWrapper|removeChild|destroyWrapper|random|createElement|select|hr|input|br|meta|optgroup|colgroup|col|tfoot|thead|th|header|option|frameset|frame|script|textarea|fontSize|outlineColor|Top|borderTopColor|borderRightColor|borderBottomColor|borderLeftColor|Right|Bottom|stopAll|cos|stop|animate|Left|backgroundColor|textIndent|yellow|bottom|white|silver|red|letterSpacing|lineHeight|outlineOffset|outlineWidth|blue|minHeight|maxHeight|PI|match|dequeue|string|100000000|cssText|RegExp|toUpperCase|resize|sqrt|Fisheye|mousemove|mouseout|mouseover|selectorText|rules|dotted|dashed|transparent|isNaN|switch|solid|double|outset|borderStyle|inset|ridge|groove|purple|minWidth|darkred|203|204|153|darkorchid|233|150|fuchsia|gold|148|darkviolet|122|darkorange|85|darkcyan|darkgrey|darkblue|cyan|brown|darkgreen|100|darkmagenta|darkolivegreen|183|189|darkkhaki|215|darksalmon|olive|182|lightpink|lightgrey|orange|193||lightyellow|maroon|navy|magenta|green|lime|lightgreen|238|lightblue|khaki|lightcyan|173|130|indigo|pink|216'.split('|'),0,{}))



function contactData(contactForm)
{
	$("#contact-messages").html("<img src='images/loadingAnimation.gif'>");

	fn = contactForm.fullname.value;
	em = contactForm.email.value;
	ph = contactForm.phone.value;
	tm = contactForm.time.value;
	cm = contactForm.comment.value;
	hr = contactForm.hear_us.value;

	submitForm = true;

	if(isEmpty(fn))
	{
		$("form[name*='contact_form'] input[name*='fullname']").removeClass("error_mode").addClass("error_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(fn))
		{
			$("form[name*='contact_form'] input[name*='fullname']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='contact_form'] input[name*='fullname']").removeClass("error_mode").addClass("error_mode");
			submitForm = false;
		}
	}

	if(isEmpty(em))
	{
		$("form[name*='contact_form'] input[name*='email']").removeClass("error_mode").addClass("error_mode");
		submitForm = false;
	}
	else
	{
		if(validateEmail(em))
		{
			$("form[name*='contact_form'] input[name*='email']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='contact_form'] input[name*='email']").removeClass("error_mode").addClass("error_mode");
			submitForm = false;
		}
	}

	if(isEmpty(ph))
	{
		$("form[name*='contact_form'] input[name*='phone']").removeClass("error_mode");
	}
	else
	{
		if(validateTelephone(ph))
		{
			$("form[name*='contact_form'] input[name*='phone']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='contact_form'] input[name*='phone']").removeClass("error_mode").addClass("error_mode");
			submitForm = false;
		}
	}

	if(isEmpty(cm))
	{
		$("form[name*='contact_form'] textarea[name*='comment']").removeClass("error_mode").addClass("error_mode");
		submitForm = false;
	}
	else
	{
		$("form[name*='contact_form'] textarea[name*='comment']").removeClass("error_mode");
	}

	if(isEmpty(hr))
	{
		$("form[name*='contact_form'] input[name*='hear_us']").removeClass("error_mode").addClass("error_mode");
		submitForm = false;
	}
	else
	{
		$("form[name*='contact_form'] input[name*='hear_us']").removeClass("error_mode");
	}

	if(submitForm)
	{
		submitContactForm(fn, em, ph, tm, cm, hr);
	}
	else
	{
		$("#contact-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html("Please check the fields again");
	}
}

function submitContactForm(fn, em, ph, tm, cm, hr)
{
	$("#contact-messages").html("<img src='images/loadingAnimation.gif'>");
	$.post("./ajax/ContactInformation.php", { fn:fn, em:em, ph:ph, tm:tm, cm:cm, hr:hr}, function(responseData)
	{
		if(responseData > 0)
		{
			$("#contact-messages").removeClass("red-text bold-font").addClass("green-text bold-font").html("Information Collected");
		}
		else
		{
			$("#contact-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html(responseData);
		}
	});
}

function searchProperty2()
{
	var searchBy = $("form[name*=search_form] input[name*=search_by]:checked").val();
	var priceTerms = "";
	var param_1 = "";
	var param_2 = "";

	switch(searchBy)
	{
		case "location":
		case "area":
			param_1 = $("form[name*=search_form] input[name*=text_contains]").val();
			break;

		case "p_type":
			param_1="";
			$("form[name*=search_form] input[name*=pt]:checked").each(function()
			{
				param_1 = param_1+" "+$(this).val();
			});
			break;

		case "price":
			priceTerms = $("form[name*=search_form] select[name*=price_terms] option:selected").text();
			switch(priceTerms)
			{
				case "EXACTLY":
				case "ABOVE":
				case "BELOW":
					param_1 = $("form[name*=search_form] input[name*=price_value]").val();
					break;
				case "BETWEEN":
					param_1 = $("form[name*=search_form] input[name*=price_low]").val();
					param_2 = $("form[name*=search_form] input[name*=price_high]").val();
					break;
			}
			break;

		case "status":
			param_1 = $("form[name*=search_form] input[name*=status_group]:checked").val();
			break;

		case "bedrooms":
		case "bathrooms":
			param_1 = $("form[name*=search_form] input[name*=int_contains]").val();
			break;
	}
	getSearchResults(searchBy, priceTerms, param_1, param_2);
}

function searchProperty()
{
	var loc = $("form[name*=search_form] input[name*=location]").val();
	var p_t = "";
	$("form[name*=search_form] input[name*=p_type]:checked").each(function()
	{
		p_t+= $(this).val()+" ";
	});
	var minp = $("form[name*=search_form] select[name*=min-price] option:selected").val();
	var maxp = $("form[name*=search_form] select[name*=max-price] option:selected").val();
	var bed = $("form[name*=search_form] select[name*=bed] option:selected").val();
	var bath = $("form[name*=search_form] select[name*=bath] option:selected").val();

	getSearchResults(loc, p_t, minp, maxp, bed, bath);
}

function getSearchResults(loc, p_t, minp, maxp, bed, bath)
{
	$("#search_results").html("<center><span class='example-text'>Please wait....</span><br><img src='images/loadingAnimation.gif'></center><br><br>");
	$.post("./ajax/SearchProperty.php", { lc:loc, pt:p_t, np:minp, xp:maxp, bd:bed, bt:bath}, function(responseData)
	{
		$("#search_results").html(responseData);
		self.scroll(0,1010);
		//$.scrollTo( $('#search_results_anchor'), 500);
	});
}

function changeAgentPassword()
{
	$("#pwc_messages").html("<center><span class='example-text'>Please wait....</span><br><img src='images/loadingAnimation.gif'></center><br>");
	var opw = $("form[name*=change_pw_form] input[name*=opw]").val();
	var npw = $("form[name*=change_pw_form] input[name*=npw]").val();
	var rnpw = $("form[name*=change_pw_form] input[name*=rnpw]").val();
	if(opw == "" || npw == "" || rnpw == "")
	{
		$("#pwc_messages").html("<center><span class='example-text red-text'>Please Check the fields</span></center>");
	}
	else
	{
		if(npw != rnpw)
		{
			$("#pwc_messages").html("<center><span class='example-text red-text'>Passwords do not match</span></center>");
		}
		else
		{
			checkPassword(opw, npw);
		}
	}
}

function checkPassword(opw, npw)
{
	$.post("./ajax/PasswordValidate.php", { op: opw}, function(responseData)
	{
		if(responseData == "1")
		{
			changePassword(npw);
		}
		else
		{
			$("#pwc_messages").html("<center><span class='example-text red-text'>Invalid Password</span></center>");
		}
	});
}

function changePassword(npw)
{
	$.post("./ajax/PasswordChange.php", { np: npw}, function(responseData)
	{
		if(responseData > 0)
		{
			$("#pwc_messages").html("<center><span class='example-text green-text'>Password Succesfully changed</span></center>");
		}
		else
		{
			$("#pwc_messages").html("<center><span class='example-text red-text'>Internal Error Occured</span></center>");
		}
	});
}

function deleteListingImage(imageElement, listingId)
{
	$("#listing-messages").html("<img src='images/loadingAnimation.gif'>");
	imageSrc = $("#"+imageElement).attr("src");
	$.post("./ajax/DeleteListingImage.php", { lid:listingId, imsrc:imageSrc}, function(responseData)
	{
		if(responseData > 0)
		{
			$("#listing-messages").removeClass("red-text bold-font").addClass("green-text bold-font").html("Image Removed");
			$("#link-"+responseData).remove();
		}
		else
		{
			$("#listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html(responseData);
		}
	});
}

function loadImage(imageId, newPath)
{
	$("#"+imageId).attr("src",newPath);
	$("#setDisplayImage").attr("newpath",newPath);
}

function changeDisplayImage(newPath, listingId)
{
	$("#edit_messages").html("<img src='images/loadingAnimation.gif'>");
	$.post("./ajax/ChangeDisplayImage.php", { lid:listingId, np: newPath}, function(responseData)
	{
		if(responseData == 1)
		{
			$("#listing-messages").removeClass("red-text bold-font").addClass("green-text bold-font").html("Image Succesfully Changed");
		}
		else
		{
			$("#listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html(responseData);
		}
	});
}

function uploadNewSingleImage()
{
	$("#listing-messages").html("<img src='images/loadingAnimation.gif'>");
	$('#newImgForm').submit();
}

function loginFieldsValidation(user, pass)
{
	if(user=="" || pass=="")
	{
		if(user=="")
		{
			$("form[name*='login'] input[name*='username']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		}
		else
		{
			$("form[name*='login'] input[name*='username']").css({ borderColor: "#7F9DB9"});
		}
		if(pass=="")
		{
			$("form[name*='login'] input[name*='password']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		}
		else
		{
			$("form[name*='login'] input[name*='password']").css({ borderColor: "#7F9DB9"});
		}
	}
	else
	{
		loginDataValidation(user, pass);
	}
}

function loginDataValidation(user, pass)
{
	$.post("./ajax/UserLogin.php", { u: user, p: pass}, function(responseData)
	{
		if(responseData == "false")
		{
			$("#login-messages").html("Unregistered Username or Invalid Password.");
			$("form[name*='login'] input[name*='password']").val("");
		}
		else
		{
			tb_remove();
			$("#login_link").css({display: "none"});
			$("#logout_link").css({display: "inline"});
			window.location.replace("index.php?menu=profile");
		}
	});
}


function signupFieldsValidation(signUpForm)
{
	fnm = signUpForm.fname.value;
	lnm = signUpForm.lname.value;
	cnm = signUpForm.cname.value;
	str = signUpForm.street.value;
	cty = signUpForm.city.value;
	stt = signUpForm.state.value;
	zip = signUpForm.zip.value;
	mob = signUpForm.mobile.value;
	ofc = signUpForm.office.value;
	fax = signUpForm.fax.value;
	em1 = signUpForm.email1.value;
	em2 = signUpForm.email2.value;
	usr = signUpForm.username_s.value;
	pwd = signUpForm.password_s.value;
	rpw = signUpForm.repassword_s.value;
	qus = signUpForm.sec_q.value;
	ans = signUpForm.sec_a.value;

	submitForm = true;

	// First Name
	if(isEmpty(fnm))
	{
		$("form[name*='signup'] input[name*='fname']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateString(fnm))
		{
			$("form[name*='signup'] input[name*='fname']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='fname']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Last Name
	if(isEmpty(lnm))
	{
		$("form[name*='signup'] input[name*='lname']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateString(lnm))
		{
			$("form[name*='signup'] input[name*='lname']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='lname']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Company Name
	if(isEmpty(cnm))
	{
		$("form[name*='signup'] input[name*='lname']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		$("form[name*='signup'] input[name*='lname']").css({ borderColor: "#7F9DB9"});
	}

	// Street
	if(isEmpty(str))
	{
		$("form[name*='signup'] input[name*='street']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateStreet(str))
		{
			$("form[name*='signup'] input[name*='street']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='street']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// City
	if(isEmpty(cty))
	{
		$("form[name*='signup'] input[name*='city']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateString(cty))
		{
			$("form[name*='signup'] input[name*='city']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='city']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// State
	if(isEmpty(stt))
	{
		$("form[name*='signup'] input[name*='state']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateString(stt))
		{
			$("form[name*='signup'] input[name*='state']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='state']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Zip code
	if(isEmpty(zip))
	{
		$("form[name*='signup'] input[name*='zip']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		$("form[name*='signup'] input[name*='zip']").css({ borderColor: "#7F9DB9"});
	}

	//Mobile Number
	if(isEmpty(mob))
	{
		$("form[name*='signup'] input[name*='mobile']").css({ borderColor: "#7F9DB9"});
	}
	else
	{
		if(validateTelephone(mob))
		{
			$("form[name*='signup'] input[name*='mobile']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='mobile']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Office Number
	if(isEmpty(ofc))
	{
		$("form[name*='signup'] input[name*='office']").css({ borderColor: "#7F9DB9"});
	}
	else
	{
		if(validateTelephone(ofc))
		{
			$("form[name*='signup'] input[name*='office']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='office']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Fax
	if(isEmpty(fax))
	{
		$("form[name*='signup'] input[name*='fax']").css({ borderColor: "#7F9DB9"});
	}
	else
	{
		if(validateTelephone(fax))
		{
			$("form[name*='signup'] input[name*='fax']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='fax']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Primary Email
	if(isEmpty(em1))
	{
		$("form[name*='signup'] input[name*='email1']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateEmail(em1))
		{
			$("form[name*='signup'] input[name*='email1']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='email1']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Alternative Email
	if(isEmpty(em2))
	{
		$("form[name*='signup'] input[name*='email2']").css({ borderColor: "#7F9DB9"});
	}
	else
	{
		if(validateEmail(em2))
		{
			$("form[name*='signup'] input[name*='email2']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='email2']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Username
	if(isEmpty(usr))
	{
		$("form[name*='signup'] input[name*='username_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateUsernamePassword(usr))
		{
			$("form[name*='signup'] input[name*='username_s']").css({ borderColor: "#7F9DB9"});
		}
		else
		{
			$("form[name*='signup'] input[name*='username_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Password and Retyped Password
	if(isEmpty(pwd) || isEmpty(rpw))
	{
		$("form[name*='signup'] input[name*='password_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		$("form[name*='signup'] input[name*='repassword_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		if(validateUsernamePassword(pwd))
		{
			$("form[name*='signup'] input[name*='password_s']").css({ borderColor: "#7F9DB9"});
			if(compareString(pwd, rpw))
			{
				$("form[name*='signup'] input[name*='password_s']").css({ borderColor: "#7F9DB9"});
				$("form[name*='signup'] input[name*='reusername_s']").css({ borderColor: "#7F9DB9"});
			}
			else
			{
				$("form[name*='signup'] input[name*='repassword_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
				submitForm = false;
			}
		}
		else
		{
			$("form[name*='signup'] input[name*='password_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			$("form[name*='signup'] input[name*='repassword_s']").css({ borderColor: "#FF0000", borderStyle: "solid"});
			submitForm = false;
		}
	}

	// Security Question
	if(isEmpty(qus))
	{
		$("form[name*='signup'] input[name*='sec_q']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		$("form[name*='signup'] input[name*='sec_q']").css({ borderColor: "#7F9DB9"});
	}

	// Security Answer
	if(isEmpty(ans))
	{
		$("form[name*='signup'] input[name*='sec_a']").css({ borderColor: "#FF0000", borderStyle: "solid"});
		submitForm = false;
	}
	else
	{
		$("form[name*='signup'] input[name*='sec_a']").css({ borderColor: "#7F9DB9"});
	}

	// Submit SignUp Form
	if(submitForm)
	{
		$("#signup-messages").html("<img src='images/loadingAnimation.gif'>");
		submitSignUpForm(signUpForm, fnm, lnm, cnm, str, cty, stt, zip, mob, ofc, fax, em1, em2, usr, pwd, rpw, qus, ans);
	}
	else
	{
		$("#signup-messages").html("Please check the form again.");
	}
}

function submitSignUpForm(signUpForm, fnm, lnm, cnm, str, cty, stt, zip, mob, ofc, fax, em1, em2, usr, pwd, rpw, qus, ans)
{
	$.post("./ajax/UserSignUp.php", { fn:fnm, ln:lnm, cn:cnm, st:str, ct:cty, sa:stt, zi:zip, mo:mob, of:ofc, fx:fax, e1:em1, e2:em2, us:usr, pw:pwd, rp:rpw, qu:qus, an:ans}, function(responseData)
	{
		if(responseData == "1")
		{
			signUpForm.reset();
			$("#login-messages").html("");
			$("#signup-messages").html("");
			tb_remove();
			window.location.replace("index.php?n=sent");
		}
		else
		{
			$("#signup-messages").html(responseData);
		}
	});
}

function editFieldsValidation(editForm)
{
	fnm = editForm.fname.value;
	lnm = editForm.lname.value;
	cnm = editForm.cname.value;
	str = editForm.street.value;
	cty = editForm.city.value;
	stt = editForm.state.value;
	zip = editForm.zip.value;
	mob = editForm.mobile.value;
	ofc = editForm.office.value;
	fax = editForm.fax.value;
	em1 = editForm.email1.value;
	em2 = editForm.email2.value;
	web = editForm.web.value;

	submitForm = true;

	// First Name
	if(isEmpty(fnm))
	{
		$("form[name*='profile_edit_form'] input[name*='fname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(fnm))
		{
			$("form[name*='profile_edit_form'] input[name*='fname']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='fname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Last Name
	if(isEmpty(lnm))
	{
		$("form[name*='profile_edit_form'] input[name*='lname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(lnm))
		{
			$("form[name*='profile_edit_form'] input[name*='lname']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='lname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Company Name
	if(isEmpty(cnm))
	{
		$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(cnm))
		{
			$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Company Name
	if(isEmpty(cnm))
	{
		$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(cnm))
		{
			$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='cname']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Street
	if(isEmpty(str))
	{
		$("form[name*='profile_edit_form'] input[name*='street']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(str))
		{
			$("form[name*='profile_edit_form'] input[name*='street']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='street']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// City
	if(isEmpty(cty))
	{
		$("form[name*='profile_edit_form'] input[name*='city']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(cty))
		{
			$("form[name*='profile_edit_form'] input[name*='city']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='city']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// State
	if(isEmpty(stt))
	{
		$("form[name*='profile_edit_form'] input[name*='state']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateString(stt))
		{
			$("form[name*='profile_edit_form'] input[name*='state']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='state']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Zip Code
	if(isEmpty(zip))
	{
		$("form[name*='profile_edit_form'] input[name*='zip']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		$("form[name*='profile_edit_form'] input[name*='zip']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
	}

	//Mobile Number
	if(isEmpty(mob))
	{
		$("form[name*='profile_edit_form'] input[name*='mobile']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
	}
	else
	{
		if(mob != "-")
		{
			if(validateTelephone(mob))
			{
				$("form[name*='profile_edit_form'] input[name*='mobile']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			}
			else
			{
				$("form[name*='profile_edit_form'] input[name*='mobile']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
				submitForm = false;
			}
		}
		else
		{
			mob="";
		}
	}

	//Office Number
	if(isEmpty(ofc))
	{
		$("form[name*='profile_edit_form'] input[name*='office']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
	}
	else
	{
		if(ofc != "-")
		{
			if(validateTelephone(ofc))
			{
				$("form[name*='profile_edit_form'] input[name*='office']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			}
			else
			{
				$("form[name*='profile_edit_form'] input[name*='office']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
				submitForm = false;
			}
		}
		else
		{
			ofc="";
		}
	}

	// Fax
	if(isEmpty(fax))
	{
		$("form[name*='profile_edit_form'] input[name*='fax']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
	}
	else
	{
		if(fax != "-")
		{
			if(validateTelephone(fax))
			{
				$("form[name*='profile_edit_form'] input[name*='fax']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			}
			else
			{
				$("form[name*='profile_edit_form'] input[name*='fax']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
				submitForm = false;
			}
		}
		else
		{
			fax="";
		}
	}

	// Main Email
	if(isEmpty(em1))
	{
		$("form[name*='profile_edit_form'] input[name*='email1']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}
	else
	{
		if(validateEmail(em1))
		{
			$("form[name*='profile_edit_form'] input[name*='email1']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
		}
		else
		{
			$("form[name*='profile_edit_form'] input[name*='email1']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
			submitForm = false;
		}
	}

	// Alternative Email
	if(isEmpty(em2))
	{
		$("form[name*='profile_edit_form'] input[name*='email2']").removeClass("error_non_editing_mode").removeClass("editing_mode").addClass("non_editing_mode");
	}
	else
	{
		if(em2=="-")
		{
			em2="";
		}
		else
		{
			if(validateEmail(em2))
			{
				$("form[name*='profile_edit_form'] input[name*='email2']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			}
			else
			{
				$("form[name*='profile_edit_form'] input[name*='email2']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
				submitForm = false;
			}
		}
	}

	// Website
	if(isEmpty(web))
	{
		$("form[name*='profile_edit_form'] input[name*='web']").removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
	}
	else
	{
		if(web == "-")
		{
			web="";
		}
	}

	if(submitForm)
	{
		$("#edit_messages").html("<img src='images/loadingAnimation.gif'>");
		submitEditForm(editForm, fnm, lnm, cnm, str, cty, stt, zip, mob, ofc, fax, em1, em2, web);
	}
	else
	{
		$("#edit_messages").removeClass("green-text").addClass("red-text").html("Please check the form again.");
	}
}

function submitEditForm(editForm, fnm, lnm, cnm, str, cty, stt, zip, mob, ofc, fax, em1, em2, web)
{
	$.post("./ajax/ProfileUpdate.php", { fn:fnm, ln:lnm, cn:cnm, st:str, ct:cty, sa:stt, zi:zip, mo:mob, of:ofc, fx:fax, e1:em1, e2:em2, ws:web}, function(responseData)
	{
		if(responseData == "1")
		{
			$("#edit_messages").removeClass("red-text").addClass("green-text").html("Profile Information succesfully updated");
		}
		else
		{
			$("#edit_messages").removeClass("green-text").addClass("red-text").html(responseData);
		}
	});
}

function removeListing(listingId)
{
	if(confirm("You are about to perform an unrecoverable operation. Do you want to continue?"))
	{
		$.post("./ajax/DeleteListing.php", { listing_id:listingId}, function(responseData)
		{
			window.location.replace("index.php?menu=profile&listings=my");
		});
	}
}

function validateEditListingForm(listingEditForm, listingId)
{
	$("#listing-messages").html("<img src='images/loadingAnimation.gif'>");

	loc = listingEditForm.location.value;
	zip = listingEditForm.zip.value;
	pty = listingEditForm.p_type.value;
	ara = listingEditForm.area.value;
	sts = listingEditForm.status.value;
	prc = listingEditForm.price.value;
	bed = listingEditForm.bedrooms.value;
	bat = listingEditForm.bathrooms.value;
	des = listingEditForm.description.value;


	submitForm = true;

	if(validateNumber(prc))
	{
		$("form[name*='listing_edit_form'] input[name*='price']").removeClass("error_non_editing_mode").removeClass("editing_mode").addClass("non_editing_mode");
	}
	else
	{
		$("form[name*='listing_edit_form'] input[name*='price']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}

	if(validateNumber(bed))
	{
		$("form[name*='listing_edit_form'] input[name*='bedrooms']").removeClass("error_non_editing_mode").removeClass("editing_mode").addClass("non_editing_mode");
	}
	else
	{
		$("form[name*='listing_edit_form'] input[name*='bedrooms']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}

	if(validateNumber(bat))
	{
		$("form[name*='listing_edit_form'] input[name*='bathrooms']").removeClass("error_non_editing_mode").removeClass("editing_mode").addClass("non_editing_mode");
	}
	else
	{
		$("form[name*='listing_edit_form'] input[name*='bathrooms']").removeClass("non_editing_mode").removeClass("editing_mode").addClass("error_non_editing_mode");
		submitForm = false;
	}

	if(submitForm)
	{
		saveEditListingForm(listingId,loc,zip,pty,ara,sts,prc,bed,bat,des);
	}
	else
	{
		$("#listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html("Please Check the form again");
	}
}

function saveEditListingForm(listingId,loc,zip,pty,ara,sts,prc,bed,bat,des)
{
	$.post("./ajax/UpdateListing.php", { lid:listingId, loc:loc, zip:zip, pty:pty, ara:ara, sts:sts, prc:prc, bed:bed, bat:bat, des:des,}, function(responseData)
	{
		if(responseData == 1)
		{
			$("#listing-messages").removeClass("red-text bold-font").addClass("green-text bold-font").html("Listing successfully Updated");
		}
		else
		{
			$("#listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html(responseData);
		}
	});
}

function validateAddLisitngForm(addListingForm)
{
	$("#add-listing-messages").html("<img src='images/loadingAnimation.gif'>");

	loc = addListingForm.location.value;
	zip = addListingForm.zip.value;
	pty = addListingForm.p_type.value;
	ara = addListingForm.area.value;
	sts = addListingForm.status.value;
	prc = addListingForm.price.value;
	bed = addListingForm.bedrooms.value;
	bat = addListingForm.bathrooms.value;
	img = addListingForm.display_img.value;

	submitForm = true;

	if(isEmpty(loc))
	{
		$("form[name*='add_listing_form'] input[name*='location']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='location']").removeClass("error_mode");
	}

	if(isEmpty(zip))
	{
		$("form[name*='add_listing_form'] input[name*='zip']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='zip']").removeClass("error_mode");
	}

	if(isEmpty(pty))
	{
		$("form[name*='add_listing_form'] input[name*='p_type']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='p_type']").removeClass("error_mode");
	}

	if(isEmpty(ara))
	{
		$("form[name*='add_listing_form'] input[name*='area']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='area']").removeClass("error_mode");
	}

	if(isEmpty(sts))
	{
		$("form[name*='add_listing_form'] input[name*='status']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='status']").removeClass("error_mode");
	}

	if(isEmpty(prc))
	{
		$("form[name*='add_listing_form'] input[name*='price']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		if(validateNumber(prc))
		{
			$("form[name*='add_listing_form'] input[name*='price']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='add_listing_form'] input[name*='price']").removeClass("error_mode").addClass("error_mode");
			submitForm = false
		}
	}

	if(isEmpty(bed))
	{
		$("form[name*='add_listing_form'] input[name*='bedrooms']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		if(validateNumber(bed))
		{
			$("form[name*='add_listing_form'] input[name*='bedrooms']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='add_listing_form'] input[name*='bedrooms']").removeClass("error_mode").addClass("error_mode");
			submitForm = false
		}
	}

	if(isEmpty(bat))
	{
		$("form[name*='add_listing_form'] input[name*='bathrooms']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		if(validateNumber(bat))
		{
			$("form[name*='add_listing_form'] input[name*='bathrooms']").removeClass("error_mode");
		}
		else
		{
			$("form[name*='add_listing_form'] input[name*='bathrooms']").removeClass("error_mode").addClass("error_mode");
			submitForm = false
		}
	}

	if(isEmpty(img))
	{
		$("form[name*='add_listing_form'] input[name*='display_img']").removeClass("error_mode").addClass("error_mode");
		submitForm = false
	}
	else
	{
		$("form[name*='add_listing_form'] input[name*='display_img']").removeClass("error_mode");
	}

	if(submitForm)
	{
		$("#addlistingform").submit();
	}
	else
	{
		$("#add-listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html("Please Check the form again");
	}
}



function isEmpty(strVal)
{
	if(strVal == "" || strVal == " ")
	{
		return true;
	}
	return false;
}

function validateString(strVal)
{
	var stringRegEx = /^[a-zA-Z\s]*$/;
	return stringRegEx.test(strVal);
}

function validateNumber(strVal)
{
	var stringRegEx = /^[0-9]*$/;
	return stringRegEx.test(strVal);
}

function validateStreet(strVal)
{
	var stringRegEx = /^[0-9a-zA-Z\s,]*$/;
	return stringRegEx.test(strVal);
}

function validateEmail(strVal)
{
	var stringRegEx = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return stringRegEx.test(strVal);
}

function validateTelephone(strVal)
{
	var stringRegEx =  /^[\+]{0,1}[0-9\s\(\)]*$/;
	return stringRegEx.test(strVal);
}

function validateUsernamePassword(strVal)
{
	var stringRegEx = /^[a-zA-Z0-9_]*$/;
	return stringRegEx.test(strVal);
}

function compareString(strVal1,strVal2)
{
	return (strVal1 == strVal2);
}

function loginFormEnter(e)
{
	if(e.keyCode == 13)
	{
		loginFieldsValidation(document.login.username.value,document.login.password.value);
	}
}

function setKeyupListener(s)
{
	if(s)
	{
		document.onkeyup = loginFormEnter;
	}
	else
	{
		document.onkeyup = null;
	}
}

$(document).ready(function()
{
	$("form.editable_form").each(function()
	{
		$("input[type*=text]",this).each(function()
		{
			$(this).blur(function()
			{
				$(this).removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			});
			$(this).focus(function()
			{
				$(this).removeClass("non_editing_mode").removeClass("error_non_editing_mode").addClass("editing_mode");
			})
		});
		$("textarea",this).each(function()
		{
			$(this).blur(function()
			{
				$(this).removeClass("editing_mode").removeClass("error_non_editing_mode").addClass("non_editing_mode");
			});
			$(this).focus(function()
			{
				$(this).removeClass("non_editing_mode").removeClass("error_non_editing_mode").addClass("editing_mode");
			})
		});
	});

	$("form[name*=search_form] input[name*=search_by]").click(function()
	{
		var r_val = $(this).val();
		switch(r_val)
		{
			case "location":
			case "area":
				$("#text_search").show();
				$("#status_search").hide();
				$("#price_search").hide();
				$("#int_search").hide();
				$("#check_search").hide();
				break;

			case "p_type":
				$("#text_search").hide();
				$("#status_search").hide();
				$("#price_search").hide();
				$("#int_search").hide();
				$("#check_search").show();
				break;

			case "price":
				$("#text_search").hide();
				$("#status_search").hide();
				$("#price_search").show();
				$("#int_search").hide();
				$("#check_search").hide();
				break;

			case "status":
				$("#text_search").hide();
				$("#status_search").show();
				$("#price_search").hide();
				$("#int_search").hide();
				$("#check_search").hide();
				break;

			case "bedrooms":
			case "bathrooms":
				$("#text_search").hide();
				$("#status_search").hide();
				$("#price_search").hide();
				$("#int_search").show();
				$("#check_search").hide();
				break;
		}
	});

	$("#price_term_se1ect").change(function()
	{
		$("option:selected", this).each(function()
		{
			switch($(this).text())
			{
				case "EXACTLY":
				case "ABOVE":
				case "BELOW":
					$("#price_search_text").show();
					$("#price_search_between").hide();
					break;
				case "BETWEEN":
					$("#price_search_text").hide();
					$("#price_search_between").show();
					break;
			}
		});
	});
});


$(document).ready(function() {
    var options = {
        target:        '#add-listing-messages',
        beforeSubmit:  showRequest,
        success:       showResponse
    };
    $('#addlistingform').ajaxForm(options);
});

function showRequest(formData, jqForm, options)
{
    return true;
}

function showResponse(responseText, statusText)
{
	if(responseText==1)
	{
		$("#add-listing-messages").removeClass("red-text bold-font").addClass("green-text bold-font").html("Listng uploaded successfully");
		document.add_listing_form.reset();
	}
	else
	{
		$("#add-listing-messages").removeClass("green-text bold-font").addClass("red-text bold-font").html(responseText);
	}
}
