// JavaScript Document


$(document).ready(function() { 
						   
	$('.reasonblock').hide();
	$('.killcross').hide();
	$('.reasonhead').addClass('reasonpointeractive');
	
	$('.reasonhead').hover(function(){
				$(this).toggleClass('reasonToggleHover');
	})



	$('#newsmenu').hide();

	var divheight = $('#content').height();
	if(divheight<636){divheight=636;}
	$('#leftColumn').css("height",(divheight+15));
	$('#leftColumn').css("background-image", "url(images/site/leftback.jpg)");




	$('.reasonhead').click(function(){   // children().find('.reasonextend')
			var _this = $(this);
			var _thistext = $(this).next();
			var _thisheadcross = $(this).children('.killcross');
			if($(_thisheadcross).is(':hidden')){
				$(_thistext).slideToggle(1200, function(){ // reasonblock
				_thisheadcross.show();
				$(_this).addClass('reasonToggleColor');
				setcolumns();
				}); 
			} else {
				_thisheadcross.hide();
				$(_thistext).slideToggle(1200, function(){ // reasonextend
					$(_this).removeClass('reasonToggleColor');
					setcolumns();
				}); 
			}
	});


	setcolumns();
});

function nothing(){
}

function setcolumns(){
var divheight = $('#content').height();
//var rdivheight = $('#outerRight').height();
//	if(rdivheight>divheight){divheight=rdivheight;}
	if(divheight<636){divheight=636;}
//	alert(divheight);
$('#leftColumn').css("height",(divheight+15));
$('#leftColumn').css("background-image", "url(images/site/leftback.jpg)");
//$('#outerRight').css("height",(divheight+36));
//$('#outerRight').css("border-left", "solid 1px #75afdf");

}


function dosize(){

	// right, check for bogeys
	vActivity = $('#activity_level').val();
	if(vActivity==0){
		alert("Please select activity level");
		$('#activity_level').focus();
		return false;
	}

	band = $('#band_size').val();
	if(band==0 || band.length==0){
		alert("Please enter your band size");
		$('#band_size').focus();
		return false;
	}

	bust = $('#bust_size').val();
	if(bust==0 || bust.length==0){
		alert("Please enter your bust size");
		$('#bust_size').focus();
		return false;
	}

	// ok, got this far - let's proceed!

	// get the right band size
	var vSize = "";
	band_inches = band/2.54;
	if(band_inches < 26) {vSize = "30";}
	if(band_inches > 26 && band_inches < 27) {vSize = "30 or 32";}	
	if(band_inches > 27 && band_inches < 28) {vSize = "32";}
	if(band_inches > 28 && band_inches < 29) {vSize = "32 or 34";}	
	if(band_inches > 29 && band_inches < 30) {vSize = "34";}
	if(band_inches > 30 && band_inches < 31) {vSize = "34 or 36";}	
	if(band_inches > 31 && band_inches < 32) {vSize = "36";}
	if(band_inches > 32 && band_inches < 33) {vSize = "36 or 38";}	
	if(band_inches > 33 && band_inches < 34) {vSize = "38";}
	if(band_inches > 34 && band_inches < 35) {vSize = "38 or 40";}	
	if(band_inches > 35 && band_inches < 36) {vSize = "40";}	

		cup = bust/2.5  - band/2.5;
			cupsize = "G cup"; 
			activity_text = " 4 ";

			if(cup<9){
				cupsize = "FF cup"; 
				activity_text = " 4 ";
			}
			if(cup<8){
				cupsize = "F cup"; 
				if(vActivity==1) { activity_text = "3"};
				if(vActivity==2) { activity_text = "4"};
				if(vActivity==3) { activity_text = "4"};
				if(vActivity==4) { activity_text = "4"};
			}
			if(cup<7){
				cupsize = "E cup"; 
				if(vActivity==1) { activity_text = "3"};
				if(vActivity==2) { activity_text = "4"};
				if(vActivity==3) { activity_text = "4"};
				if(vActivity==4) { activity_text = "4"};
			}
			if(cup<6){
				cupsize = "DD cup"; 
				if(vActivity==1) { activity_text = "3"};
				if(vActivity==2) { activity_text = "3"};
				if(vActivity==3) { activity_text = "3"};
				if(vActivity==4) { activity_text = "4"};
			}
			if(cup<5){
				cupsize = "D cup"; 
				if(vActivity==1) { activity_text = "2"};
				if(vActivity==2) { activity_text = "3"};
				if(vActivity==3) { activity_text = "3"};
				if(vActivity==4) { activity_text = "4"};
			}
			if(cup<4){
				cupsize = "C cup"; 
				if(vActivity==1) { activity_text = "2"};
				if(vActivity==2) { activity_text = "2"};
				if(vActivity==3) { activity_text = "3"};
				if(vActivity==4) { activity_text = "3"};
			}
			if(cup<3){
				cupsize = "B cup"; 
				if(vActivity==1) { activity_text = "1"};
				if(vActivity==2) { activity_text = "2"};
				if(vActivity==3) { activity_text = "2"};
				if(vActivity==4) { activity_text = "3"};
			}
			if(cup<2){
				cupsize = "A cup"; 
				if(vActivity==1) { activity_text = "1"};
				if(vActivity==2) { activity_text = "1"};
				if(vActivity==3) { activity_text = "2"};
				if(vActivity==4) { activity_text = "2"};
			}
			if(cup<1){
				cupsize = "AA cup"; 
				if(vActivity==1) { activity_text = "1"};
				if(vActivity==2) { activity_text = "1"};
				if(vActivity==3) { activity_text = "2"};
				if(vActivity==4) { activity_text = "2"};
			}
			
			introtext="Your ideal bra will be size " + vSize + " - " + cupsize + "<br>We recommend support level "+activity_text + "(see below)";
			
		$('#bra_size').html(introtext);			

		// close them all first
			if($('.reasonhead').next().not(':hidden')){
				$('.reasonhead').removeClass('reasonToggleColor');
				$('.reasonhead').children('.killcross').slideUp();
				$('.reasonhead').next().hide(); 
			}

		// now open the required one, with style
			theLevel = '#level'+eval(activity_text);
			$('#level'+eval(activity_text)).next().slideDown(1200, function(){ // reasonblock
				var _this = $(this);
				var _reasonhead = $(this).prev();
				var _thisheadcross = _reasonhead.children('.killcross');	
				_thisheadcross.show();
				$(_reasonhead).addClass('reasonToggleColor');
				setcolumns();
			});

}



