// 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'));
});
}

$(document).ready(function(){
$(".toggleup").click(function(){
  $("#newsletter").slideToggle("slow");
  $(this).toggleClass("toggledown"); return false;
  });	 
});
/*$(document).ready(function(){
$(".searchup").click(function(){
  $("#search_page_form").slideToggle("slow");
  $(this).toggleClass("searchdown"); return false;
  });	 
});*/
/*//// Tab News /////////
$(function() {  
	$('#promo_news').tabs({ fxAutoHeight: true });
});*/

/*//// Tab Search /////////
$(function() { 
	$('#search_page_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();
}


////// Jquery PNG Fix //////
$(function() {
	$.ifixpng('../images/pixel.gif'); 
	$('#login').ifixpng();
	$('#newsletter').ifixpng();
	$('#property_info_bg').ifixpng();
});

/*//// Link Dropdown //////////////////////////
$(function() {
    $('#mlink').droppy();
  });*/

/*//// Jobs Position Accordian //////////////////////*/

$(document).ready(function(){
	
                $(".jobs_position h4:first").addClass("active");
                $(".jobs_position .jobscontent:not(:first)").hide();
                /*$(".jobs_position .jobscontent").hide();*/
                $(".jobs_position h4").click(function(){
                    $(this).next(".jobscontent").slideToggle("medium")
                    .siblings(".jobscontent:visible").slideUp("medium");
                    $(this).toggleClass("active");
                    $(this).siblings("h4").removeClass("active");
                });

            });

/*//// Downloads Accordian //////////////////////*/

$(document).ready(function(){
	
                $(".downloads_list h4:first").addClass("active");
                $(".downloads_list .downloads_content:not(:first)").hide();
                /*$(".jobs_position .jobscontent").hide();*/
                $(".downloads_list h4").click(function(){
                    $(this).next(".downloads_content").slideToggle("medium")
                    .siblings(".downloads_content:visible").slideUp("medium");
                    $(this).toggleClass("active");
                    $(this).siblings("h4").removeClass("active");
                });

            });

/*$(document).ready( function(){
  $('#news_list ul li').corners('4px');
  $('#news_list ul li.hover').corners('4px');
});*/
/*//// Popup Map ///////////////////////////////////////////*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*//// Float Box ////////////////////////////////////*/
(function($) {
$(document).ready(function() {
$("a.forgot").fancybox({
		'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:218,
		'overlayShow':		true,
		'padding' :  0,
		'overlayOpacity': 0.8
	});


$("#mail_btn").click(function() {
	email =  $('#email_subscribes').val() ;
	ischk = false ;
	if (( email  == '-------- อีเมล์แอดเดรสของท่าน ---------') ||  ( email  == '' )) {
		alert('กรุณากรอก อีเมล์');
		return false ;
		}
		
	isvalidemail = (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) ;
		
		if (!isvalidemail) {	
		alert('กรุณากรอก อีเมล์ ที่ถูกต้อง ');
		$('#email_subscribes').focus();
		return false ;			
		}
		
	ischk = $('#scancel').is(':checked');
	//alert(ischk);
	 if  (ischk){
	unsub = '1' ; 		 
		 }else {
	unsub = '0' ;  
		 }
		
    $('<a href="subscribe.php?q='+unsub+'|'+email+'">toiframe</a>').fancybox({
        'hideOnContentClick': false,
		'frameWidth'			: 440,
		'frameHeight'				:218,
		'overlayShow':		true,
		'padding' :  0,
		'overlayOpacity': 0.8
    }).click();
});

});
})(jQuery);


/*//// BG Hover //////////////////////////////////////////*/
$(function() {
  $("#item_list li,#announce_table tr,#announce_table2 tr,.table_webboard tr,#persells li,#perrent li,#journal_list li,#news_list li,#housing_list li,#cforum tr,#cgallery tr,#cblog tr,.loop_list dt,#bloglist tr,.table_promotion tr,#side_list li,.table_helpdesk_sub tr").hover(
   function() {
    $(this).addClass("hover");
   },
   function() {
    $(this).removeClass("hover");
   });
 });
/*//// Dropdown List //////////////////////////////////////////*/

/*//// Start Bookmark //////////////////////////////////////////*/
function bookmark(url,title){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite(url,title);
} else if (navigator.appName == "Netscape") {
window.sidebar.addPanel(title,url,"");
} else {
alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*//// End Bookmark //////////////////////////////////////////*/