﻿
	var ids=new Array('AddServiceNote1', 'AddServiceNote2', 'AddServiceNote3', 'str_estimate_type_other', 'str_doc_type_other', 'str_intended_use_other','str_doc_type_revised');
	
	function switchid(id){	
		//hideallids();
		if (id=='AddServiceNote1') {
			hidediv('AddServiceNote2');
		}
		else if (id=='AddServiceNote2') {
			hidediv('AddServiceNote1');
		}
		else {
			hidediv('AddServiceNote1');
			hidediv('AddServiceNote2');
		}

		showdiv(id);
	}
	
	function hideallids(){
		//loop through the array and hide each element by id
		for (var i=0;i<ids.length;i++){
			hidediv(ids[i]);
		}		  
	}
	
	function hidediv(id) {
		//safe function to hide an element with a specified id
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'none';
			}
			else { // IE 4
				document.all.id.style.display = 'none';
			}
		}
	}
	
	function showdiv(id) {
		//safe function to show an element with a specified id
			  
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'block';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'block';
			}
			else { // IE 4
				document.all.id.style.display = 'block';
			}
		}
		
		// apply equal height
		//equalHeight($(".columns"));
	
	}
	
		$(function() {
				   
			/*** BEGIN Step 1	その他 show and hide div ***/ 
			$("#str_est_type").change(function() {
				 var str_est_type = $("#str_est_type").val();
				 $('#str_comment').val("");
				 if (str_est_type=='その他'){
					showdiv('str_estimate_type_other');
					return false;
				 }
				 else {
					hidediv('str_estimate_type_other');
					return false;
				 }	
			});
			
			$("#str_doc_type").change(function() {
				var str_doc_type = $("#str_doc_type").val();	
				$('#str_doc_type_comment').val("");
				$('#str_add_service_prev_job').val("");
				
				$("label#str_doc_type_error").fadeOut('slow');				
				
				if (str_doc_type=='その他'){
					showdiv('str_doc_type_other');
					hidediv('str_doc_type_revised');
					return false;
				}
				else if (str_doc_type=='リバイズ原稿'){
					showdiv('str_doc_type_revised');
					hidediv('str_doc_type_other');
					return false;
				}
				else {
					hidediv('str_doc_type_other');
					hidediv('str_doc_type_revised');
					return false;
				}		
			});
			
			$("#str_intended_use").change(function() {
				var str_intended_use = $("#str_intended_use").val();
				$('#str_usage_comment').val("");
				
				$("label#str_intended_use_error").fadeOut('slow');		
				if (str_intended_use=='その他'){
					showdiv('str_intended_use_other');
					return false;
				}
				else {
					hidediv('str_intended_use_other');
					return false;
				}		
			});
			/*** END Step 1 その他 show and hide div ***/ 

			/*** BEGIN  Step 2 how found show and hide div ***/ 
			$("#str_how_found").change(function() {
				var str_how_found = $("#str_how_found").val();
				$('#str_keywords').val("");
				
				$("label#str_how_found_error").fadeOut('slow');		
				
				if (str_how_found=='友人/同僚からの紹介'){
					showdiv('str_how_found_other');
					return false;
				}
				else if (str_how_found=='ジャーナル編集長からの推薦'){
					showdiv('str_how_found_other');
					return false;
				}
				else if (str_how_found=='サーチエンジン'){
					showdiv('str_how_found_other');
					return false;
				}
				else if (str_how_found=='雑誌の広告'){
					showdiv('str_how_found_other');
					return false;
				}
				else if (str_how_found=='国際学会'){
					showdiv('str_how_found_other');
					return false;
				}
				else if (str_how_found=='その他'){
					showdiv('str_how_found_other');
					return false;
				}
				else {
					hidediv('str_how_found_other');
					return false;
				}		
			});
			/*** END  Step 2 how found show and hide div ***/ 

			/*** BEGIN Step 1 contact method option ***/ 
			$("#str_contact_method_option").change(function() {
				var str_contact_method_option = $("#str_contact_method_option").val();
				
				if (str_contact_method_option=='電話'){
					$('#str_contact_method_option_tel').show();
					$('#str_contact_method_option_fax').hide();
					$('#str_contact_method_option_add').hide();
					return false;
				}
				else if (str_contact_method_option=='ファックス') {
					$('#str_contact_method_option_tel').hide();
					$('#str_contact_method_option_fax').show();
					$('#str_contact_method_option_add').hide();
					return false;
				}		
				
				else if (str_contact_method_option=='郵便') {
					$('#str_contact_method_option_tel').hide();
					$('#str_contact_method_option_fax').hide();
					$('#str_contact_method_option_add').show();
					return false;
				}		
				else {
					$('#str_contact_method_option_tel').hide();
					$('#str_contact_method_option_fax').hide();
					$('#str_contact_method_option_add').hide();
					return false;
				}

			});
			/*** END Step 1 contact method option ***/ 
								
			
			/*
			$("#str_add_service1").click(function() {				
				switchid('AddServiceNote1');				
			});
			$("#str_add_service2").click(function() {
				switchid('AddServiceNote2');				
			});
			$("#str_add_service3").click(function() {
				switchid('AddServiceNote3');				
			});
			*/
			
			$("#str_spec_field").focus(function() {
				$("label#str_spec_field_error").fadeOut('slow');
			});
			
		});
		
		
		$(function() {
		  $('.error').hide();
		  
		  // $("input#str_contact_method").select().focus();
		  
		  $('input.inputs').css({backgroundColor:"#FFFFFF"});
		  $('input.inputs').focus(function(){
			$(this).css({backgroundColor:"#F9F0DD"});
		  });
		  $('input.inputs').blur(function(){
			$(this).css({backgroundColor:"#FFFFFF"});
		  });
		  
		  $('input.inputs_small').css({backgroundColor:"#FFFFFF"});
		  $('input.inputs_small').focus(function(){
			$(this).css({backgroundColor:"#F9F0DD"});
		  });
		  $('input.inputs_small').blur(function(){
			$(this).css({backgroundColor:"#FFFFFF"});
		  });
		  
		  
		   
		
		});
			
			

