/*=========================================================


	Site Name   Cadillac
	File Name   function.js

	Create Date 2007/12/03
	Update Date 2007/12/03


==========================================================*/

/*========================================================*/
/*                                                        */
/*                                                        */
/*		1. Fullscreen Function                    */
/*                                                        */
/*		2. Pop Up Window Function                 */
/*                                                        */
/*		3. RollOver Images Function*              */
/*                                                        */
/*		4. Fade Effect Function*                  */
/*                                                        */
/*		5. Png Fix Function*                      */
/*                                                        */
/*		6. Tab Function*                          */
/*                                                        */
/*		7. Pop Up Window Function (Dealer List)   */
/*                                                        */
/*		8. CSS Selector Function                  */
/*                                                        */
/*		* Require jquery.js                       */
/*                                                        */
/*                                                        */
/*========================================================*/

/*----------------------------------------------------------

	1. Fullscreen Function

-----------------------------------------------------------*/

function getFullscreen(thePage){
	var winWidth = screen.availWidth;
	var winHeight = screen.availHeight;
	window.open(thePage,"title","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width="+winWidth+",height="+winHeight);
}

/*----------------------------------------------------------

	2. Pop Up Window Function

-----------------------------------------------------------*/

function openBrWindow(url, name, myW, myH, ans) {
	posX = (screen.availWidth - myW) / 2;
	posY = (screen.availHeight - myH) / 2;
	newWin = window.open(url, name, "left="+posX+", top="+posY+",width="+myW+", height="+myH+", scrollbars="+ans+", resizable="+ans);
}

/*----------------------------------------------------------

	3. RollOver Images Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	var image_cache = new Object(); //preload images
	$("img.btn").each(function(i){
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var imgsrc_on = this.src.substr(0, dot) + '_o' + this.src.substr(dot, 4);
	image_cache[this.src] = new Image();
	image_cache[this.src].src = imgsrc_on;
	$(this).hover(
		function(){ this.src = imgsrc_on; },
		function(){ this.src = imgsrc; });
	});
})

/*----------------------------------------------------------

	4. Fade Effect Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	$("img.fadeImg").hover(
		function(){$(this).fadeTo(300, 0.5);},
		function(){$(this).fadeTo(300, 1);}
	);
});

/*----------------------------------------------------------

	5. Tab Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	$('li#switchBtn a').toggle(function(){
		$('div#specList').fadeOut(500,function(){$('div#priceList').fadeIn(500)});
		$('li#switchBtn a img').attr('src','./images/link_btn01.gif');
		return false;
	},function(){
		$('div#priceList').fadeOut(500,function(){$('div#specList').fadeIn(500)});
		$('li#switchBtn a img').attr('src','./images/link_btn02.gif');
		return false;
	});
})

/*----------------------------------------------------------

	6. Pop Up Window Function (Dealer List)

-----------------------------------------------------------*/

function openWindow(url) {
	myPath = "http://www.automotive.mitsui.co.jp/dealer/"
	window.name="dealer";
	sw=screen.availWidth; 
	sh=screen.availHeight;
	wl = (sw-500)/2;
	wt = (sh-500)/2;
	window.open(myPath+url,"window","width=520,height=650,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=" + wl + ",top=" + wt);
}

/*----------------------------------------------------------

	7. CSS Selector Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	var de = document.documentElement;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = h;

	var contHeight = document.body.offsetHeight;

	if(arrayPageSize > contHeight) {
		myHeight = arrayPageSize;
	}else{
		myHeight = contHeight;
	}
});

$(function(){
	$("div#sideBar")
	.css("height",myHeight)
});
