var currentQuote=0;
var currentMoreInfo=0;
var delivAddrStatus=0;
var five=0;

function delivAddrOn( )
{
	if( delivAddrStatus==0 )
	{
		new Effect.BlindDown(document.getElementById('delivAddrSection'));
		delivAddrStatus=1;
	}
}
function delivAddrOff( )
{
	if( delivAddrStatus==1 )
	{
		new Effect.BlindUp(document.getElementById('delivAddrSection'));
		delivAddrStatus=0;
	}
}

function checkDelivAddrStatus( )
{
	if( document.getElementById( 'diffDelivAddr' ).checked==true )
	{
		delivAddrOn();
	}
}


function getInnerLink( ){
	if ( currentQuote == 0 )
	{
		return( '<a class="ptr2" href="javascript:swapQuote()" title="Create here to buy off the roll" >Buy off the roll ('+ (maxw4)+' metres minimum width)</a>' );
		
	}
	return( '<a class="ptr2" href="javascript:swapQuote()" title="Create for bespoke sizes" >Click here for Bespoke sizes</a>' );
	
}

function getSwapLink( ) {
	document.write( '<p id="quoteSwitcher" >' );
	document.write( getInnerLink( ) );
	document.write( '</p>' );
}

function getHiddenOption( )

{
	document.write( '<div id="bespoke-option" style="display:none">' );

	document.write( '<p class="initial">Please enter the length you require in metres into the boxes below. Remember to include an extra 0.10m for any irregularities which may exist in walls and for cutting.</p>' );
document.write( '<p><label for="bespokeLength">Length:</label> <input class="std" id="bespokeLength" name="bespokeLength" type="text" value="" \onFocus="startCalc();" onBlur="stopCalc();"\/> m &nbsp;&nbsp;x &nbsp; <label for="bespokeWidth">Width:</label> <input class="std" id="bespokeWidth" name="bespokeWidth" type="text" value="" \onFocus="startCalc();" onBlur="stopCalc();"\/> m</p>' );
	document.write( '<img src="images/blankimage.jpg" name="firstnameerror" height="10" border="0" id="firstnameerror" />' );	
	document.write( '<p><input name="addstain" type="checkbox" id="addstain" value="1" onFocus="startCalc();" onBlur="stopCalc();"/><label for="addstain">Add Intec stain inhibition @ &pound;5.00 per m<sup>2</sup></label></p><p><strong><label for="costBox">Total Cost <font size="1">(inc vat)</font><label for="costBox"> &pound; </label><input name="costBox" type="text" disabled="disabled" class="std" id="costBox" \onFocus="startCalc();" onBlur="stopCalc();"\ value="0.00" size="9" /></strong></p>' );

	document.write( '</div> <!-- bespoke-option -->' );
		
}

function swapQuote( )
{
	if ( currentQuote == 0 )
	{
		/* Opening the By Roll section */
		new Effect.BlindUp( document.getElementById( 'by-the-roll-option' ) );
		new Effect.BlindDown( document.getElementById( 'bespoke-option' ), { queue: 'end', afterFinish: swapQuoteCallBackAfterFinish } );
		document.getElementById( 'bespokeLength' ).value = '';
		document.getElementById( 'bespokeWidth' ).value = '';
five=1;

	}
	else
	{
		/* Opening the Bespoke section */
		new Effect.BlindUp( document.getElementById( 'bespoke-option' ) );
		new Effect.BlindDown( document.getElementById( 'by-the-roll-option' ), { queue: 'end', afterFinish: swapQuoteCallBackAfterFinish } );
		document.getElementById( 'byRollLength' ).value = '';
five=0;


	}
	currentQuote = ( currentQuote + 1 ) % 2;
}

function swapQuoteCallBackAfterFinish(obj){
	document.getElementById( 'quoteSwitcher' ).innerHTML = getInnerLink();
}


function toggleMoreInfo( ){
	if ( currentMoreInfo == 0)
	{
		new Effect.BlindDown( document.getElementById( 'moreInfo' ), { afterFinish: toggleMoreInfoCallBackAfterFinish } );
	}
	else
	{
		new Effect.BlindUp( document.getElementById( 'moreInfo' ), { afterFinish: toggleMoreInfoCallBackAfterFinish } );
	}
	currentMoreInfo = ( currentMoreInfo + 1 ) % 2;
}

function toggleMoreInfoCallBackAfterFinish(obj){ ;
	a=document.getElementById( 'moreInfoLink' );
	a.innerHTML = ( currentMoreInfo == 0 ) ? 'More info' : 'Less info';
	a.className = ( currentMoreInfo == 0 ) ? 'ptr' : 'ptr3';
}


function writeMoreInfo(){
	document.write( '<p style="margin-top:5px"><a class="ptr" id="moreInfoLink" href="javascript:toggleMoreInfo()" title="More Information">More Info</a></p>');
	document.write( '<div id="moreInfo" style="display:none">');
	document.write( '<p><strong>Heavy</strong> - heavy usage, for example hallways, family living rooms.</p>');
	document.write( '<p><strong>Light</strong> - light usage, for example bedrooms and guest rooms.</p>');
	document.write( '<p><strong>H.Moisture</strong> - usage in areas of high moisture, for example in bathrooms.</p>');
	document.write( '<p><strong>Stairs</strong> - usage on stairways.</p>');
	document.write( '<p><strong>Castors</strong> - usage with furniture fitted with castors</p>');
	document.write( '</div>');
}

function createToolTips() {
	for ( var i=0; i<tooltips.length; i++ ) 
	{
		new Tip( tooltips[i][0],
			'<img src="' + tooltips[i][1] + '" /><p><strong>Colour:</strong> ' + tooltips[i][2] + '</p><p><strong>Weave: </strong> ' + tooltips[i][3] + '</p>',
			{ className: 'murray', effect: 'appear', offset: {x:10, y:75} , hideAfter: 1.5, duration:0.15, delay:0.1  });
	}
}

