jQuery(document).ready(function()
{
	var form1 = {triggerID : "search_btn01" , targetID : "test1-content" , image : ["tab_01.gif","tab_01on.gif"] , form : document.form1 , hashname : "wtype1"};
	var form2 = {triggerID : "search_btn02" , targetID : "test2-content" , image : ["tab_02.gif","tab_02on.gif"] , form : document.form2 , hashname : "wtype2"};
	var form3 = {triggerID : "search_btn03" , targetID : "test3-content" , image : ["tab_03.gif","tab_03on.gif"] , form : document.form3 , hashname : "wtype3"};
	
	form1.trigger  = jQuery("#" + form1.triggerID);
	form1.target   = jQuery("#" + form1.targetID);
	form2.trigger  = jQuery("#" + form2.triggerID);
	form2.target   = jQuery("#" + form2.targetID);
	form3.trigger  = jQuery("#" + form3.triggerID);
	form3.target   = jQuery("#" + form3.targetID);
	
	var switchForm = function(number , firstview)
	{
		if(number == 1)
		{
			selectForm = form1;
			otherForm1 = form2;
			otherForm2 = form3;
		}
		if(number == 2)
		{
			selectForm = form2;
			otherForm1 = form1;
			otherForm2 = form3;
		}
		if(number == 3)
		{
			selectForm = form3;
			otherForm1 = form1;
			otherForm2 = form2;
		}
		selectForm.trigger.attr("src" , "/mc002_product/search/img/" + selectForm.image[1]);
		otherForm1.trigger.attr("src" , "/mc002_product/search/img/" + otherForm1.image[0]);
		otherForm2.trigger.attr("src" , "/mc002_product/search/img/" + otherForm2.image[0]);
		
		if(firstview)
		{
			otherForm1.target.css("display" , "none");
			otherForm2.target.css("display" , "none");
			selectForm.target.css("display" , "block");
			//selectForm.target.parent().height(selectForm.target.height());
			if( bi.ieVersion <= 6 ) selectForm.target.parent().animate({height:selectForm.target.height() , opacity:1} , selectForm.target.height() , "linear");
			else selectForm.target.parent().animate({height:selectForm.target.height() , opacity:1} , 0 , "linear");
		}
		else
		{
			selectForm.target.parent().stop().animate({height:0 , opacity:0} , selectForm.target.parent().height() , "easeOutCubic" , function()
			{
				otherForm1.target.css("display" , "none");
				otherForm2.target.css("display" , "none");
				selectForm.target.css("display" , "block");
				selectForm.target.parent().animate({height:selectForm.target.height() , opacity:1} , selectForm.target.height() , "easeOutCubic");
			});
			location.hash = selectForm.hashname;
		}
		document.getElementById(selectForm.triggerID).onmouseover = function()
		{
			selectForm.trigger.attr("src" , "/mc002_product/search/img/" + selectForm.image[1]);
		}
		document.getElementById(selectForm.triggerID).onmouseout = function()
		{
			selectForm.trigger.attr("src" , "/mc002_product/search/img/" + selectForm.image[1]);
		}
		document.getElementById(otherForm1.triggerID).onmouseover = function()
		{
			otherForm1.trigger.attr("src" , "/mc002_product/search/img/" + otherForm1.image[1]);
		}
		document.getElementById(otherForm1.triggerID).onmouseout = function()
		{
			otherForm1.trigger.attr("src" , "/mc002_product/search/img/" + otherForm1.image[0]);
		}
		document.getElementById(otherForm2.triggerID).onmouseover = function()
		{
			otherForm2.trigger.attr("src" , "/mc002_product/search/img/" + otherForm2.image[1]);
		}
		document.getElementById(otherForm2.triggerID).onmouseout = function()
		{
			otherForm2.trigger.attr("src" , "/mc002_product/search/img/" + otherForm2.image[0]);
		}
		document.getElementById("searchformsubmit").onclick = function()
		{
			selectForm.form.submit();
		}
		document.getElementById(form1.triggerID).onclick = function(){switchForm(1 , false);};
		document.getElementById(form2.triggerID).onclick = function(){switchForm(2 , false);};
		document.getElementById(form3.triggerID).onclick = function(){switchForm(3 , false);};
		document.getElementById(selectForm.triggerID).onclick = null;
	}
	document.getElementById(form1.triggerID).onclick = function(){switchForm(1 , false);};
	document.getElementById(form2.triggerID).onclick = function(){switchForm(2 , false);};
	document.getElementById(form3.triggerID).onclick = function(){switchForm(3 , false);};
	
	switch (true)
	{
		case location.hash == "#" + form2.hashname : switchForm(2 , true); break;
		case location.hash == "#" + form3.hashname : switchForm(3 , true); break;
		default : switchForm(1 , true);
	}
});
