
/*
*------------------------------------------------------------------			
*	Name			main.js
*	Author			fixture designworks
*	Depends			jQuery, jQuery UI, jQuery.validate.js, Google Maps API
*	URL				
*	Last Modified	2009/04/14
*------------------------------------------------------------------
*/

$(function(){

/* Global
------------------------------------------------------------*/

/* Add class "odd" for tr element step by step */
$("table tr:odd").addClass("odd");

/* Add class "last" for the last item */
$("div#wrapper div#footer div#navi ul#path li:last-child").addClass("last");
$("div#wrapper div#footer div#foot ul li:last-child").addClass("last");
$("div#wrapper div#content div#prop_unit ul li:nth-child(4n)").addClass("last");
$("div#wrapper div#content div#bottom p:last-child").addClass("last");
$("div#wrapper.using div#content div#bottom ul li:last-child").addClass("last");
$("div#wrapper div#menu ul li:last-child").addClass("last");


/* Switch language */

$("div#wrapper div#content div#bottom div#lang a").click(function(){
	if($(this).html() == "English"){
		window.blur();
		$("div#j").hide();
		$("div#e").show();
		$(this).addClass("lang_current");
		$(this).prev().removeClass("lang_current");
	}else if($(this).html() == "日本語"){
		window.blur();
		$("div#e").hide();
		$("div#j").show();
		$(this).addClass("lang_current");
		$(this).next().removeClass("lang_current");
	}
	return false;
});

/* Sidemenu > Submenu
------------------------------------------------------------*/


$("div#wrapper div#menu div#search ul li a[href=#open]").toggle(
	function(){
		$(this).parent().addClass("open");
		return false;
    },
	function(){
		$(this).parent().removeClass("open");
		return false;
	}
);

$("div#wrapper.rents div#menu div#search ul li.rents").addClass("open");
$("div#wrapper.sales div#menu div#search ul li.sales").addClass("open");


/* Content > Contact General & Prop
------------------------------------------------------------*/

/* Add the same name class of em content */
var emMark = $("div#wrapper div#content div#prop_unit ul li a em");
emMark.each(function(){
	if($(this).html() == "RENTS"){
		$(this).addClass("rents");
	}else if($(this).html() == "SALES"){
		$(this).addClass("sales");
	}else{
		$(this).addClass("create");
	}
});

/* Datepicker */

if(jQuery.ui){
	$.datepicker.regional['ja'] = {
		clearText: '', clearStatus: '',
		closeText: '閉じる', closeStatus: '',
		prevText: '<前月', prevStatus: '',
		nextText: '次月>', nextStatus: '',
		currentText: '今日', currentStatus: '',
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthStatus: '', yearStatus: '',
		weekHeader: 'Wk', weekStatus: '',
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayStatus: 'DD', dateStatus: 'D, M d',
		dateFormat: 'yy年 mm月 dd日',
		firstDay: 1, 
		initStatus: '',
		isRTL: false
	};
	$("div#wrapper.contact div#content div#bottom table tr td #date1").datepicker($.datepicker.regional["ja"]);
	$("div#wrapper.contact div#content div#bottom table tr td #date2").datepicker($.datepicker.regional["ja"]);
	$("div#wrapper.contact div#content div#bottom table tr td #date3").datepicker($.datepicker.regional["ja"]);
}

/* add class as the type of its name */
$("div#wrapper div#content div#bottom table tr td input[type=text]").addClass("text");
$("div#wrapper div#content div#bottom table tr td input[type=radio]").addClass("radio");
$("div#wrapper div#content div#bottom table tr td input[type=checkbox]").addClass("cb");

/* add/remove class "hv" to label element when mouse over */
$("div#wrapper div#content div#bottom table tr td label").hover(
	function(){
		$(this).addClass("hv");
	},
	function(){
		$(this).removeClass("hv");
	}
);

/* add/remove class "focus" to tr element including focused input element with type=text */
$("div#wrapper div#content div#bottom table tr td input[type=text]")
.focus(function(){$(this).addClass("focus");$(this).parent().parent().addClass("focus")})
.blur(function(){$(this).removeClass("focus");$(this).parent().parent().removeClass("focus")});

/* add/remove class "focus", the same for textarea element */
$("div#wrapper div#content div#bottom table tr td textarea")
.focus(function(){$(this).addClass("focus");$(this).parent().parent().addClass("focus")})
.blur(function(){$(this).removeClass("focus");$(this).parent().parent().removeClass("focus")});

/* add class "required" for th element prev of td including required input element */
$("div#wrapper div#content div#bottom table tr td input.required").parent().prev().addClass("required");

/* Must-fill item for Contact Form */
$("div#wrapper div#content div#bottom table tr th.required").prepend("<em>※</em>");


/* jQuery validate form */	
if($.validator){
	$("div#wrapper div#content div#bottom form#cf").validate();
}



/* Content > Rents&Sales Search
------------------------------------------------------------*/

/* Display detail search */

$("div#wrapper div#content div#bottom table tr td h6 a").toggle(
	function () {
		$(this).parent().next().show(200);
		return false;
	},
	function () {
		$(this).parent().next().hide(200);
		return false;
	}
);


/* Content > Search Result
------------------------------------------------------------*/

$("div#wrapper.result div#content div#bottom h3 a").toggle(
	function(){
		$(this).parent().next().show();
		return false;
	},
	function(){
		$(this).parent().next().hide();
		return false;
	}
)


/* Content > Props > Gallery
------------------------------------------------------------*/


$("div.galleryview").galleryView({
	panel_width: 600,
	panel_height: 400,
	frame_width: 120,
	frame_height: 80,

	border: "none",
	pause_on_hover: true
});

$("div.gallery_top").galleryView({
	panel_width: 700,
	panel_height: 465,

	border: "none",
	pause_on_hover: true
});

/* Footer > Copyright
------------------------------------------------------------*/

var date = new Date();
year = date.getFullYear();
$("div#wrapper div#footer div#foot p").html("Copyright &copy; " + year + " CAMELLIA ORGANIZATION Co., Ltd. All rights reserved.")





});



/* END */