$('#hdralerts').ready(function(){
	var flashvars = {};
    var params = {
    	wmode: "opaque",
    	menu: "false"
    };
	swfobject.embedSWF("http://www.thepropertypalace.com.au/_img/alerts.swf", "hdrswf", "974", "100", "9.0.0", "http://www.thepropertypalace.com.au/_rsc/expressInstall.swf",flashvars,params);
});
alertsReset= function(){
	$('input, select, textarea').removeClass();
}
alertsSend = function(form){
	$('input, select, textarea').removeClass();
	window['wok'] = 0;
	window['werr'] = '';
	window['wfoc'] = '';
	if(form.ytitle.selectedIndex <= 0){
		window['wok'] = 0;
		window['werr'] += '\t- Your Title\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'ytitle';
		}
		$('#ytitle').removeClass('valid');
		$('#ytitle').addClass('error');
	} else {
		$('#ytitle').removeClass('error');
		$('#ytitle').addClass('valid');
	}
	if(form.yfname.value == '' || form.yfname.value == 'first name'){
		window['wok'] = 1;
		window['werr'] += '\t- Your First Name\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'yfname';
		}
		$('#yfname').removeClass('valid');
		$('#yfname').addClass('error');
	} else {
		$('#yfname').removeClass('error');
		$('#yfname').addClass('valid');
	}
	if(form.ylname.value == '' || form.ylname.value == 'surname'){
		window['wok'] = 1;
		window['werr'] += '\t- Your Surname\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'ylname';
		}
		$('#ylname').removeClass('valid');
		$('#ylname').addClass('error');
	} else {
		$('#ylname').removeClass('error');
		$('#ylname').addClass('valid');
	}
	if(form.ycm.selectedIndex <= 0){
		window['wok'] = 1;
		window['werr'] += '\t- Your Preferred Contact Method\n';
		if(window['wfoc'] == ''){
			window['wfoc'] = 'ycm';
		}
		$('#ycm').removeClass('valid');
		$('#ycm').addClass('error');
	} else if(form.ycm.value=='Email'){
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!filter.test(form.yemail.value)){
			window['wok'] = 1;
			window['werr'] += '\t- Your Email Address\n';
			if(window['wfoc']==''){
				window['wfoc'] = 'yemail';
			}
			$('#yemail').removeClass('valid');
			$('#yemail').addClass('error');
		} else {
			$('#yemail').removeClass('error');
			$('#yemail').addClass('valid');
		}
	} else if(form.ycm.value=='SMS'){
		var tel = /^[0-9 ]+$/;
		if(!tel.test(form.ymtel.value)){
			window['wok'] = 1;
			window['werr'] += '\t- Your Mobile Contact Number\n';
			if(window['wfoc']==''){
				window['wfoc'] = 'ymtel';
			}
			$('#ymtel').removeClass('valid');
			$('#ymtel').addClass('error');
		} else {
			$('#ymtel').removeClass('error');
			$('#ymtel').addClass('valid');
		}
	} else {
		$('#ycm').removeClass('error');
		$('#ycm').addClass('valid');
	}
	if(form.code.value == ''){
		window['wok'] = 1;
		window['werr'] += '\t- Security Check\n';
		if(window['wfoc'] == ''){
			window['wfoc'] = 'code';
		}
		$('#code').removeClass('valid');
		$('#code').addClass('error');
			if(window['wok']==1){
				alert('We encountered to following errors when to send your submission.\n\n'+window['werr']+'');
				eval('el("'+window['wfoc']+'").focus();');
			}
	} else {
		$.post('../../_rsc/chk.php',{code: form.code.value}, function(data){
																	  if(data == 'tpp_pass'){
																		  $('#code').removeClass('error');
																		  $('#code').addClass('valid');
																		if(window['wok']==1){
																			alert('We encountered to following errors when trying to send your submission.\n\n'+window['werr']+'');
																			eval('el("'+window['wfoc']+'").focus();');
																		} else {
                                                                            selcat = '';
                                                                            selsub = '';
                                                                            self1 = '';
                                                                            self2 = '';
                                                                            self3 = '';
                                                                                                                                                        	if(el('cat_1').checked == true){
                                                                                    selcat += '1|';
                                                                                }
																			                                                                            	if(el('cat_2').checked == true){
                                                                                    selcat += '2|';
                                                                                }
																			                                                                            	if(el('cat_3').checked == true){
                                                                                    selcat += '3|';
                                                                                }
																			                                                                            	if(el('cat_4').checked == true){
                                                                                    selcat += '4|';
                                                                                }
																			                                                                            	if(el('cat_5').checked == true){
                                                                                    selcat += '5|';
                                                                                }
																			                                                                            	if(el('cat_6').checked == true){
                                                                                    selcat += '6|';
                                                                                }
																			                                                                            	if(el('cat_7').checked == true){
                                                                                    selcat += '7|';
                                                                                }
																			                                                                            	if(el('cat_8').checked == true){
                                                                                    selcat += '8|';
                                                                                }
																			                                                                            	if(el('cat_9').checked == true){
                                                                                    selcat += '9|';
                                                                                }
																			                                                                            	if(el('cat_10').checked == true){
                                                                                    selcat += '10|';
                                                                                }
																			                                                                            	if(el('cat_11').checked == true){
                                                                                    selcat += '11|';
                                                                                }
																			                                                                            	if(el('cat_12').checked == true){
                                                                                    selcat += '12|';
                                                                                }
																			                                                                            	if(el('cat_13').checked == true){
                                                                                    selcat += '13|';
                                                                                }
																			                                                                            	if(el('cat_14').checked == true){
                                                                                    selcat += '14|';
                                                                                }
																			                                                                            	if(el('cat_15').checked == true){
                                                                                    selcat += '15|';
                                                                                }
																			                                                                            	if(el('cat_16').checked == true){
                                                                                    selcat += '16|';
                                                                                }
																			                                                                            	if(el('suburb_1').checked == true){
                                                                                    selsub += '1|';
                                                                                }
                                                                                                                                                        	if(el('suburb_2').checked == true){
                                                                                    selsub += '2|';
                                                                                }
                                                                                                                                                        	if(el('suburb_3').checked == true){
                                                                                    selsub += '3|';
                                                                                }
                                                                                                                                                        	if(el('suburb_4').checked == true){
                                                                                    selsub += '4|';
                                                                                }
                                                                                                                                                        	if(el('suburb_5').checked == true){
                                                                                    selsub += '5|';
                                                                                }
                                                                                                                                                        	if(el('suburb_6').checked == true){
                                                                                    selsub += '6|';
                                                                                }
                                                                                                                                                        	if(el('suburb_7').checked == true){
                                                                                    selsub += '7|';
                                                                                }
                                                                                                                                                        	if(el('suburb_8').checked == true){
                                                                                    selsub += '8|';
                                                                                }
                                                                                                                                                        	if(el('suburb_9').checked == true){
                                                                                    selsub += '9|';
                                                                                }
                                                                                                                                                        	if(el('suburb_10').checked == true){
                                                                                    selsub += '10|';
                                                                                }
                                                                                                                                                        	if(el('suburb_11').checked == true){
                                                                                    selsub += '11|';
                                                                                }
                                                                                                                                                        	if(el('suburb_12').checked == true){
                                                                                    selsub += '12|';
                                                                                }
                                                                                                                                                        	if(el('suburb_13').checked == true){
                                                                                    selsub += '13|';
                                                                                }
                                                                                                                                                        	if(el('suburb_14').checked == true){
                                                                                    selsub += '14|';
                                                                                }
                                                                                                                                                        	if(el('suburb_15').checked == true){
                                                                                    selsub += '15|';
                                                                                }
                                                                                                                                                        	if(el('suburb_16').checked == true){
                                                                                    selsub += '16|';
                                                                                }
                                                                                                                                                        	if(el('suburb_17').checked == true){
                                                                                    selsub += '17|';
                                                                                }
                                                                                                                                                        	if(el('suburb_18').checked == true){
                                                                                    selsub += '18|';
                                                                                }
                                                                                                                                                        	if(el('suburb_19').checked == true){
                                                                                    selsub += '19|';
                                                                                }
                                                                                                                                                        	if(el('suburb_20').checked == true){
                                                                                    selsub += '20|';
                                                                                }
                                                                                                                                                        	if(el('suburb_21').checked == true){
                                                                                    selsub += '21|';
                                                                                }
                                                                                                                                                        	if(el('suburb_22').checked == true){
                                                                                    selsub += '22|';
                                                                                }
                                                                                                                                                        	if(el('suburb_23').checked == true){
                                                                                    selsub += '23|';
                                                                                }
                                                                                                                                                        	if(el('suburb_24').checked == true){
                                                                                    selsub += '24|';
                                                                                }
                                                                                                                                                        	if(el('suburb_25').checked == true){
                                                                                    selsub += '25|';
                                                                                }
                                                                                                                                                        	if(el('suburb_26').checked == true){
                                                                                    selsub += '26|';
                                                                                }
                                                                                                                                                        	if(el('suburb_27').checked == true){
                                                                                    selsub += '27|';
                                                                                }
                                                                                                                                                        	if(el('suburb_28').checked == true){
                                                                                    selsub += '28|';
                                                                                }
                                                                                                                                                        	if(el('suburb_29').checked == true){
                                                                                    selsub += '29|';
                                                                                }
                                                                                                                                                        	if(el('suburb_30').checked == true){
                                                                                    selsub += '30|';
                                                                                }
                                                                                                                                                        	if(el('suburb_34').checked == true){
                                                                                    selsub += '34|';
                                                                                }
                                                                                                                                                        	if(el('suburb_35').checked == true){
                                                                                    selsub += '35|';
                                                                                }
                                                                                                                                                        	if(el('suburb_36').checked == true){
                                                                                    selsub += '36|';
                                                                                }
                                                                                                                                                        	if(el('suburb_37').checked == true){
                                                                                    selsub += '37|';
                                                                                }
                                                                                                                                                        	if(el('suburb_39').checked == true){
                                                                                    selsub += '39|';
                                                                                }
                                                                                                                                                        	if(el('suburb_40').checked == true){
                                                                                    selsub += '40|';
                                                                                }
                                                                                                                                                        	if(el('suburb_42').checked == true){
                                                                                    selsub += '42|';
                                                                                }
                                                                                                                                                        	if(el('suburb_43').checked == true){
                                                                                    selsub += '43|';
                                                                                }
                                                                                                                                                        	if(el('suburb_44').checked == true){
                                                                                    selsub += '44|';
                                                                                }
                                                                                                                                                        	if(el('suburb_45').checked == true){
                                                                                    selsub += '45|';
                                                                                }
                                                                                                                                                        	if(el('suburb_46').checked == true){
                                                                                    selsub += '46|';
                                                                                }
                                                                                                                                                        	if(el('suburb_47').checked == true){
                                                                                    selsub += '47|';
                                                                                }
                                                                                                                                                        	if(el('suburb_48').checked == true){
                                                                                    selsub += '48|';
                                                                                }
                                                                                                                                                        	if(el('suburb_49').checked == true){
                                                                                    selsub += '49|';
                                                                                }
                                                                                                                                                        	if(el('suburb_50').checked == true){
                                                                                    selsub += '50|';
                                                                                }
                                                                                                                                                        	if(el('suburb_51').checked == true){
                                                                                    selsub += '51|';
                                                                                }
                                                                                                                                                        	if(el('suburb_52').checked == true){
                                                                                    selsub += '52|';
                                                                                }
                                                                                                                                                        	if(el('suburb_53').checked == true){
                                                                                    selsub += '53|';
                                                                                }
                                                                                                                                                        	if(el('suburb_54').checked == true){
                                                                                    selsub += '54|';
                                                                                }
                                                                                                                                                        	if(el('suburb_55').checked == true){
                                                                                    selsub += '55|';
                                                                                }
                                                                                                                                                        	if(el('suburb_56').checked == true){
                                                                                    selsub += '56|';
                                                                                }
                                                                                                                                                        	if(el('suburb_57').checked == true){
                                                                                    selsub += '57|';
                                                                                }
                                                                                                                                                        	if(el('suburb_58').checked == true){
                                                                                    selsub += '58|';
                                                                                }
                                                                                                                                                        	if(el('suburb_59').checked == true){
                                                                                    selsub += '59|';
                                                                                }
                                                                                                                                                        	if(el('suburb_60').checked == true){
                                                                                    selsub += '60|';
                                                                                }
                                                                                                                                                        	if(el('suburb_61').checked == true){
                                                                                    selsub += '61|';
                                                                                }
                                                                                                                                                        	if(el('suburb_62').checked == true){
                                                                                    selsub += '62|';
                                                                                }
                                                                                                                                                        	if(el('mcat_1').checked == true){
                                                                                    self1 += '1|';
                                                                                }
                                                                                                                                                        	if(el('mcat_2').checked == true){
                                                                                    self1 += '2|';
                                                                                }
                                                                                                                                                        	if(el('mcat_3').checked == true){
                                                                                    self1 += '3|';
                                                                                }
                                                                                                                                                        	if(el('mcat_4').checked == true){
                                                                                    self1 += '4|';
                                                                                }
                                                                                                                                                        	if(el('mcat_5').checked == true){
                                                                                    self1 += '5|';
                                                                                }
                                                                                                                                                        	if(el('mcat_6').checked == true){
                                                                                    self1 += '6|';
                                                                                }
                                                                                                                                                        	if(el('mcat_7').checked == true){
                                                                                    self1 += '7|';
                                                                                }
                                                                                                                                                        	if(el('mcat_8').checked == true){
                                                                                    self1 += '8|';
                                                                                }
                                                                                                                                                        	if(el('mcat_9').checked == true){
                                                                                    self1 += '9|';
                                                                                }
                                                                                                                                                        	if(el('mcat_10').checked == true){
                                                                                    self1 += '10|';
                                                                                }
                                                                                                                                                        	if(el('pcat_1').checked == true){
                                                                                    self2 += '1|';
                                                                                }
                                                                                                                                                        	if(el('pcat_2').checked == true){
                                                                                    self2 += '2|';
                                                                                }
                                                                                                                                                        	if(el('pcat_3').checked == true){
                                                                                    self2 += '3|';
                                                                                }
                                                                                                                                                        	if(el('pcat_4').checked == true){
                                                                                    self2 += '4|';
                                                                                }
                                                                                                                                                        	if(el('pcat_5').checked == true){
                                                                                    self2 += '5|';
                                                                                }
                                                                                                                                                        	if(el('pcat_6').checked == true){
                                                                                    self2 += '6|';
                                                                                }
                                                                                                                                                        	if(el('pcat_7').checked == true){
                                                                                    self2 += '7|';
                                                                                }
                                                                                                                                                        	if(el('pcat_8').checked == true){
                                                                                    self2 += '8|';
                                                                                }
                                                                                                                                                        	if(el('pcat_9').checked == true){
                                                                                    self2 += '9|';
                                                                                }
                                                                                                                                                        	if(el('pcat_10').checked == true){
                                                                                    self2 += '10|';
                                                                                }
                                                                                                                                                        	if(el('ncat_1').checked == true){
                                                                                    self3 += '1|';
                                                                                }
                                                                                                                                                        	if(el('ncat_2').checked == true){
                                                                                    self3 += '2|';
                                                                                }
                                                                                                                                                        	if(el('ncat_3').checked == true){
                                                                                    self3 += '3|';
                                                                                }
                                                                                                                                                        	if(el('ncat_4').checked == true){
                                                                                    self3 += '4|';
                                                                                }
                                                                                                                                                        	if(el('ncat_5').checked == true){
                                                                                    self3 += '5|';
                                                                                }
                                                                                                                                                        	if(el('ncat_6').checked == true){
                                                                                    self3 += '6|';
                                                                                }
                                                                                                                                                        	if(el('ncat_7').checked == true){
                                                                                    self3 += '7|';
                                                                                }
                                                                                                                                                        	if(el('ncat_8').checked == true){
                                                                                    self3 += '8|';
                                                                                }
                                                                                                                                                        	if(el('ncat_9').checked == true){
                                                                                    self3 += '9|';
                                                                                }
                                                                                                                                                        	if(el('ncat_10').checked == true){
                                                                                    self3 += '10|';
                                                                                }
                                                                            																			$('#signupalerts').fadeTo(100,0.01,function(){
																				$.post('../../_rsc/alertsignup.php',{
																					   yti:   el('ytitle').value,
																					   yfn:  el('yfname').value,
																					   yln:  el('ylname').value,
																					   ymt:  el('ymtel').value,
																					   ye:   el('yemail').value,
																					   ycm:  el('ycm').value,
																					   ypf:  el('priceFrom').value,
																					   ypt:	 el('priceTo').value,
																					   ycat: selcat,
																					   ysub: selsub,
																					   ymh:  self1,
																					   ywl:  self2,
																					   ydw:  self3,
                                                                                       ycase:el('case').value,
                                                                                       ybeds:el('ybeds').value,
																					   ybath:el('ybath').value,
                                                                                       ycars:el('ycars').value,
																					   n: ((el('wnews').checked)?'Y':'N')
																					},function(data){
																					if(data=='tpp_pass'){
																						el('signupalerts').innerHTML = '<h3>Registration Successful</h3><p>Thank you for taking the time to register for our property alerts. You\'ll now receive up-to-date information as it becomes available.</p>';
																						$('#signupalerts').fadeTo(100,1);
																					} else {
																						el('image').src = '../../_img/securimage_show.php?sid=' + Math.random();
																						$('#signupalerts').fadeTo('fast',1,function(){
																							alert(data);
																						});
																					}
																				}, "html");
																		   });
																		}
																	  } else {
																		  window['wok'] = 1;
																		  window['werr'] += '\t- Incorrect Security Code\n';
																		  if(window['wfoc'] == ''){
																			  window['wfoc'] = 'code';
																		  }
																		  el('image').src = '../../_img/securimage_show.php?sid=' + Math.random();
																		  $('#code').removeClass('valid');
																		  $('#code').addClass('error');
																		  	if(window['wok']==1){
																				alert('We encountered to following errors when trying to send your submission.\n\n'+window['werr']+'');
																				eval('el("'+window['wfoc']+'").focus();');
																			}
																	  }
																	  },"html");
	}
}
wCM = function(val){
	if(val=='SMS'){
		$('#ct1').slideUp('fast', function(){
											 $('#ct2').slideDown('fast');
											 });
	} else if(val=="Email") {
		$('#ct2').slideUp('fast', function(){
											 $('#ct1').slideDown('fast');
											 });
	} else {
		$('#ct2').slideUp('fast');
		$('#ct1').slideUp('fast');
	}
}
verAdd = function(val){
	if(val==true){
		el('padd1').value = el('yadd1').value;
		el('padd2').value = el('yadd2').value;
		el('padd3').value = el('yadd3').value;
		el('pstate').selectedIndex = el('ystate').selectedIndex;
		el('ppcode').value = el('ypcode').value;
	} else {
		el('padd1').value = 'address line 1';
		el('padd2').value = 'address line 2';
		el('padd3').value = 'address line 3';
		el('pstate').selectedIndex = 0;
		el('ppcode').value = 'postcode';
	}
}
