// displays hint text on any input element with the 'title' attribute set
$(document).ready(function() {
wireUpDisplayTextboxes();
wireUpDisplayTextArea();
});

function wireUpDisplayTextboxes() {
var el = $('input[Title]');

// show the display text
el.each(function(i) {
    $(this).attr('value', $(this).attr('title'));
});

// hook up the blur & focus
el.focus(function() {
    if ($(this).attr('value') == $(this).attr('title'))
        $(this).attr('value', '');
}).blur(function() {
    if ($(this).attr('value') == '')
        $(this).attr('value', $(this).attr('title'));
});
}

function wireUpDisplayTextArea() {
var el = $('textarea[Title]');

// show the display text
el.each(function(i) {
    $(this).attr('value', $(this).attr('title'));
});

// hook up the blur & focus
el.focus(function() {
    if ($(this).attr('value') == $(this).attr('title'))
        $(this).attr('value', '');
}).blur(function() {
    if ($(this).attr('value') == '')
        $(this).attr('value', $(this).attr('title'));
});
}

/*//// Tab News /////////*/
$(function() { 
	$('#promo_news').tabs({ fxAutoHeight: true });
});

/*//// Tab Search /////////*/
$(function() { 
	$('#search_form').tabs({ fxAutoHeight: true });
});

/*//// Swap Forminput ///////////////////////////*/
function swapus(){
document.getElementById("swapus").innerHTML = '' ;
document.getElementById("swapus").innerHTML = '<input name="password" type="password" id="passwd" title="--------------- รหัสผ่าน ---------------">' ;
document.getElementById("passwd").focus();
document.getElementById("passwd").focus();
}

/*//// Banner Slide //////////////////////////////*/

	$(function(){
		$('#banner_slide').loopedSlider({
			autoStart: 5000

		});
	});


/*///// Jquery PNG Fix //////////////////////////////////*/
$(function() {
	$.ifixpng('../images/pixel.gif'); 
	$('#login').ifixpng();
	$('#header_top').ifixpng();
	$('.comunity_sub').ifixpng();
	$('.knowledge_sub').ifixpng();
	$('.advice_sub').ifixpng();
	//$('.tabs-nav li a').ifixpng();
	 
});

/*//// Link Dropdown //////////////////////////*/
$(function() {
    $('#mlink,#menu_link').droppy();
  });

/*//// Float Box ////////////////////////////////////*/
(function($) {
$(document).ready(function() {
$("a.float").fancybox({
		'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:198,
		'overlayShow':		true,
		'padding' :  0,
		'overlayOpacity': 0.8
	});
$("a.forgot").fancybox({
		'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:218,
		'overlayShow':		true,
		'padding' :  0,
		'overlayOpacity': 0.8
	});

$("#subscribe_form").click(function() {
    $('<a href="subscribe.php">dff</a>').fancybox({
        'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:218,
		'overlayShow':		true,
		'padding' :  0,
		'overlayOpacity': 0.8
    }).click();
});
$("a.poll").fancybox({
		'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:270,
		'overlayShow':		false,
		'padding' :  0,
		'overlayOpacity': 0.8
	});
$('a.poll').click();
$('a.btnclose').click(function(){ 
    parent.top.$('#fancy_close').trigger('click'); 
});
});
})(jQuery);
/*//// List Box /////////////////////////////////////////*/
$(document).ready(function() {
  $('#checklist').hide();  
  $('#checklist_bg').hide();
  $('#searchlist1, #searchlist2, #searchlist3').click(function() {
    $('#checklist, #checklist_bg').slideToggle(300); 
	/*$(this).click(function() {
    $('#checklist').hide(); });*/
  });
  $('#apply_select').click(function() {
    $('#checklist, #checklist_bg').hide();
	var selt='';
		for(i=1;i<8;i++){
			if(document.getElementById('cat_'+i).checked){
				selt+=document.getElementById('cat_'+i).value+",";
			}
		}
		var cur_table=document.getElementById('cur_table').value;
		if(selt!=''){
			selt=selt.substr(0,(selt.length-1));	
			document.getElementById('cate'+cur_table).value=selt;
		//	document.getElementById('area'+cur_table).disabled="disabled";
		}
		else{
			document.getElementById('cate'+cur_table).value='- ระบุประเภทอสังหาริมทรัพย์';
		//	document.getElementById('area'+cur_table).disabled="";
		}
  });
 
});
$(function(){
 
	$("#checkall").click(function(){
 
		$(":checkbox").attr("checked","checked");
 
	});
	$("#uncheckall").click(function(){
 
		$(":checkbox").attr("checked","");
 
	});

	$("#searchlist1").click(function(){
 
		$(":checkbox").attr("checked","");
 
	});
	
	$("#searchlist2").click(function(){ 
 
		$(":checkbox").attr("checked","");
 
	});
	
	$("#searchlist3").click(function(){
 
		$(":checkbox").attr("checked","");
 
	});
 
})
/*//// Popup Map ///////////////////////////////////////////*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*//// BG Hover //////////////////////////////////////////*/
$(function() {
  $("#promo_news li,#announce_table tr,#persells li,#perrent li").hover(
   function() {
    $(this).addClass("hover");
   },
   function() {
    $(this).removeClass("hover");
   });
 });

$(document).ready(function(){ 
$('#clickme').click();
}); 