// ============================================================ 
// RollOver
// ============================================================ 
function initRollOverImages() {
  var image_cache = new Object();
  $("img.swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + 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; });
  });
}

initRollOverImages;

	$('.fstep2').hide();
	$('.fstep3').hide();
	$('.fstep4').hide();
	$('.fstep5').hide();
	$('.fstep6').hide();

$(document).ready(function(){

stvalue = $.cookie('st');

	$('.syokisutv').hide();
	$('.syokitcn').hide();
	$('.syoki').hide();


if(stvalue =='54'){
// tcn
$('.syokitcn').show();
}else if(stvalue=='53'){
// sutv	
$('.syokisutv').show();
}else{
$('.syoki').show();
}


	// フェードインアウト
	jQuery.each(
		[4,5,6],
		function(i, n) { 
			
			// 戻る
			$('.back'+n).click(function() {
				$('.step li:nth-child('+(n+1)+') div').removeClass('forcus');
				$('.step li:nth-child('+(n)+') div').addClass('forcus');
				
				$('.fstep'+(n+1)).fadeOut('normal',function() {
				if ($(this).is(":hidden"))
					$('.fstep'+n).fadeIn('normal');
				});
				window.scroll(0, 0);
			});
		}
	);
	

$('.next1').click(function() {
						   
	val = $('input[name=house]:radio:checked').val();
						   
	$('.step li:nth-child(1) div').removeClass('forcus');
	$('.step li:nth-child(2) div').addClass('forcus');
	$('.fstep1').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		window.scroll(0, 0);
		$('.fstep2').fadeIn('normal');

	}
	});
});



$('.next2').click(function() {
	
	val = 'TV' + $('#tv').attr('value') +"\n";
	val += 'NET1' + $('#net1').attr('value') +"\n";
	val += 'NET2' + $('#net2').attr('value') +"\n";
	val += 'PHONE' + $('#phone').attr('value') +"\n";

	$('.kekkayasuku').hide();
	$('.kekkadougaku').hide();
	$('.kekkatuika').hide();

valTV=parseInt($('#tv').attr('value')-0);
valNET1=parseInt($('#net1').attr('value')-0);
valNET2=parseInt($('#net2').attr('value')-0);
valPHONE=parseInt($('#phone').attr('value')-0);
valTTL = valTV +valNET1 + valNET2 + valPHONE;

	$('.step li:nth-child(2) div').removeClass('forcus');
	$('.step li:nth-child(3) div').addClass('forcus');
	$('.fstep2').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		window.scroll(0, 0);
		$('.fstep3'+$('input[name=house]:radio:checked').val()).fadeIn('normal');
	}
	});
});



$('.skip2').click(function() {
valTTL =undefined;

	val = 'TV' + $('#tv').attr('value') +"\n";
	val += 'NET1' + $('#net1').attr('value') +"\n";
	val += 'NET2' + $('#net2').attr('value') +"\n";
	val += 'PHONE' + $('#phone').attr('value') +"\n";


	$('.kekkayasuku').hide();
	$('.kekkadougaku').hide();
	$('.kekkatuika').hide();


	$('.step li:nth-child(2) div').removeClass('forcus');
	$('.step li:nth-child(3) div').addClass('forcus');
	$('.fstep2').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		window.scroll(0, 0);
		$('.fstep3'+$('input[name=house]:radio:checked').val()).fadeIn('normal');
	}
	});
});



$('.next3').click(function() {
var ahouse = $('input[name=house]:radio:checked').val();	

if(ahouse == 'kodate' ){
	
	val2 = $("input[name=inputplankodate]:radio:checked").val();
	

	$('.tyukikodate').show();
	$('.tyukimansion').hide();

	$('.resultotoku40').hide();
	$('.resultotoku160').hide();
	$('.resultman40').hide();
	$('.resultman160').hide();

if(val2 == "お得プラン１６０") {
	$('.resultotoku160').show();
valPrice = 9500;
	$('#btn-inq').show();
	$('#btn-inq2').hide();

}

if(val2 =="お得プラン４０")	{
	$('.resultotoku40').show();
valPrice = 8800;
	$('#btn-inq').show();
	$('#btn-inq2').hide();
}

if(val2 == "マンション通信パック１６０"){
	$('.resultman160').show();
valPrice = 5460;
	$('#btn-inq').hide();
	$('#btn-inq2').show();
}

if(val2 =="マンション通信パック４０"){
	$('.resultman40').show();
valPrice = 4725;
	$('#btn-inq').hide();
	$('#btn-inq2').show();
}


}else if(ahouse=='mansion'){

	val2 = $("input[name=inputplanmansion]:radio:checked").val();


	$('.tyukikodate').hide();
	$('.tyukimansion').show();

	$('.resultotoku40').hide();
	$('.resultotoku160').hide();
	$('.resultman40').hide();
	$('.resultman160').hide();

if(val2 == "お得プラン１６０") {
	$('.resultotoku160').show();
valPrice = 9500;
	$('#btn-inq').show();
	$('#btn-inq2').hide();

}

if(val2 =="お得プラン４０")	{
	$('.resultotoku40').show();
valPrice = 8800;
	$('#btn-inq').show();
	$('#btn-inq2').hide();
}

if(val2 == "マンション通信パック１６０"){
	$('.resultman160').show();
valPrice = 5460;
	$('#btn-inq').hide();
	$('#btn-inq2').show();
}

if(val2 =="マンション通信パック４０"){
	$('.resultman40').show();
valPrice = 4725;
	$('#btn-inq').hide();
	$('#btn-inq2').show();
}


	}else{
		
	alert("住居タイプを選択してください");	
window.reload();	
	}


if(valTTL !=undefined && valTTL >0){

$('.selectedplan').html(val2);
$('.ttlprice').html(valTTL);


if(valTTL == valPrice){

//alert ("TTLnow : " + valTTL +" =  Planprice :" + valPrice);
$('.kekkadougaku').show();

}else if( valTTL < valPrice){

//alert ("TTLnow : " + valTTL +" <  Planprice :" + valPrice);
$('.kekkatuika').show();
$('.pricedif').html((valPrice-valTTL));
	
}else if( valTTL > valPrice){

//alert ("TTLnow : " + valTTL +" >  Planprice :" + valPrice);
$('.kekkayasuku').show();
$('.pricedif').html((valTTL-valPrice));

}
	
}


	$('.step li:nth-child(3) div').removeClass('forcus');
	$('.step li:nth-child(4) div').addClass('forcus');
	$('.fstep3'+$('input[name=house]:radio:checked').val() ).fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		window.scroll(0, 0);
		$('.fstep4').fadeIn('normal');

	}
	});

});




$('.next4').click(function() {
						   
				   
	$('.step li:nth-child(4) div').removeClass('forcus');
	$('.step li:nth-child(5) div').addClass('forcus');
	$('.fstep4').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		$('.fstep5').fadeIn('normal');

	}
	});
	window.scroll(0, 0);
});




$('.next5').click(function() {
	$('.step li:nth-child(5) div').removeClass('forcus');
	$('.step li:nth-child(6) div').addClass('forcus');
	$('.fstep5').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		$('.fstep6').fadeIn('normal');

	}
	});
	window.scroll(0, 0);
});




$('.next6').click(function() {
	$('.step li:nth-child(6) div').removeClass('forcus');
	$('.step li:nth-child(7) div').addClass('forcus');
	$('.fstep6').fadeOut('normal',function() {
	if ($(this).is(":hidden")){
		$('.fstep7').fadeIn('normal');

	}
	});
	window.scroll(0, 0);
});



$('.back1').click(function() {
				$('.step li:nth-child(2) div').removeClass('forcus');
				$('.step li:nth-child(1) div').addClass('forcus');
				
				$('.fstep2').fadeOut('normal',function() {
				if ($(this).is(":hidden"))
					$('.fstep1').fadeIn('normal');
				});
				window.scroll(0, 0);
});
		


$('.back2kodate').click(function() {
				$('.step li:nth-child(3) div').removeClass('forcus');
				$('.step li:nth-child(2) div').addClass('forcus');
				
				$('.fstep3kodate').fadeOut('normal',function() {
				if ($(this).is(":hidden"))
					$('.fstep2').fadeIn('normal');
				});
				window.scroll(0, 0);
});
		


$('.back2mansion').click(function() {
				$('.step li:nth-child(3) div').removeClass('forcus');
				$('.step li:nth-child(2) div').addClass('forcus');
				
				$('.fstep3mansion').fadeOut('normal',function() {
				if ($(this).is(":hidden"))
					$('.fstep2').fadeIn('normal');
				});
				window.scroll(0, 0);
});
		



$('.back3').click(function() {
				$('.step li:nth-child(4) div').removeClass('forcus');
				$('.step li:nth-child(3) div').addClass('forcus');
				
				$('.fstep4').fadeOut('normal',function() {
				if ($(this).is(":hidden"))
					$('.fstep3'+$("input[name=house]:radio:checked").val()).fadeIn('normal');
				});
				window.scroll(0, 0);
});
		



	$('.fstep2').hide();
	$('.fstep3').hide();
	$('.fstep4').hide();
	$('.fstep5').hide();
	$('.fstep6').hide();
	$('p2add').hide();
	$('convtag').hide();
	initRollOverImages;
});


