var change_page = 0;

$(document).ready(function() {
	$("img.ps").hover(function(){
		if(this.src.slice( -6, -3 )!="_x."){
			this.src = this.src.substring(0,this.src.length-4)+"_x"+this.src.slice(-4);
		}
	});
	$("img.ps").mouseout(function(){
		if(this.src.slice( -6, -3 )=="_x."){
			this.src = this.src.substring(0,this.src.length-6)+this.src.slice(-4);
		}
	});
	if ( document.getElementById('slider') ) {
		$("#slider").easySlider({
			'speed'	:	140,
			'lastShow'	:	false,
			'firstShow'	:	false,
			'prevText' :	'',
			'nextText' :	'',
			'prevId': 'prevBtn',
			'nextId': 'nextBtn',
			'firstId': 'firstBtn',
			'lastId': 'lastBtn',
			'flexId': 'flexBtn',
			'prevId2': 'mc_prev_button',
			'nextId2': 'mc_next_button',
			'firstId2': 'mc_first_button',
			'lastId2': 'mc_last_button',
			'flexId2': 'mc_flex_button',
			'flexShow'	:	true
		}); 
		$("a.zoom").fancybox({
			'overlayOpacity'	:	0.7,
			'overlayColor'		:	'#FFF',
			'zoomSpeedIn'		:	300,
			'zoomSpeedOut'		:	200,
			'callbackOnShow'	:	true
		});
	}
}); 

function checkForm(num) {
	var txt = "";
	document.getElementById('error_comment').innerHTML = "※は必須入力の項目です。"
	txt += "type="+num;
	txt += "&company="+document.getElementById('company').value;
	txt += "&name="+document.getElementById('name').value;
	txt += "&address="+document.getElementById('address').value;
	txt += "&tel="+document.getElementById('tel').value;
	txt += "&email="+document.getElementById('email').value;
	txt += "&email_kakunin="+document.getElementById('email_kakunin').value;
	txt += "&comment="+document.getElementById('comment').value;
	sendRequest("POST", "inquiry_set.php", txt, false, checkForm_result );
}
function checkForm_result( xmlhttp ) {
	var tmp = xmlhttp.responseText.split( "<!--mcstudio-line-->" );
	if ( tmp[0] == "OK1" ) {
		if ( confirm( "送信してよろしいですか？" ) ) {
			checkForm(2);
		}
	} else if ( tmp[0] == "OK2" ) {
		document.getElementById('inquiry_area').innerHTML = tmp[1];
	} else {
		document.getElementById('error_comment').innerHTML = tmp[1];
	}
}

function checkFormEn(num) {
	var txt = "";
	document.getElementById('error_comment').innerHTML = "Please be sure to fill in the item of the ※ mark."
	txt += "type="+num;
	txt += "&company="+document.getElementById('company').value;
	txt += "&name="+document.getElementById('name').value;
	txt += "&address="+document.getElementById('address').value;
	txt += "&tel="+document.getElementById('tel').value;
	txt += "&email="+document.getElementById('email').value;
	txt += "&email_kakunin="+document.getElementById('email_kakunin').value;
	txt += "&comment="+document.getElementById('comment').value;
	sendRequest("POST", "inquiry_en_set.php", txt, false, checkFormEn_result );
}
function checkFormEn_result( xmlhttp ) {
	var tmp = xmlhttp.responseText.split( "<!--mcstudio-line-->" );
	if ( tmp[0] == "OK1" ) {
		if ( confirm( "Please check it again, and click OK Button." ) ) {
			checkFormEn(2);
		}
	} else if ( tmp[0] == "OK2" ) {
		document.getElementById('inquiry_area').innerHTML = tmp[1];
	} else {
		document.getElementById('error_comment').innerHTML = tmp[1];
	}
}

function setItem( num ) {
	var i=1;
	while ( document.getElementById('item_category'+i) ) {
		document.getElementById('item_category'+i).style.display = 'none';
		i++;
	}
	document.getElementById('item_category'+num).style.display = 'inline';
}

function changeItem( num ) {
	change_page = num - 1;
	$('a#mc_flex_button').click();
}

