var MWJ_progBar = 0;

function getRefToDivNest( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	return document[divID];
}

function progressBar( oBt, oBc, oBg, oBa, oWi, oHi, oDr ) {
	MWJ_progBar++; this.id = 'MWJ_progBar' + MWJ_progBar; this.dir = oDr; this.width = oWi; this.height = oHi; this.amt = 0;
	//write the bar as a layer in an ilayer in two tables giving the border
	document.write( '<table border="0" cellspacing="0" cellpadding="'+oBt+'"><tr><td bgcolor="'+oBc+'">'+
		'<table border="0" cellspacing="0" cellpadding="0"><tr><td height="'+oHi+'" width="'+oWi+'" bgcolor="'+oBg+'">' );
	if( document.layers ) {
		document.write( '<ilayer height="'+oHi+'" width="'+oWi+'"><layer bgcolor="'+oBa+'" name="MWJ_progBar'+MWJ_progBar+'"></layer></ilayer>' );
	} else {
		document.write( '<div style="position:relative;top:0px;left:0px;height:'+oHi+'px;width:'+oWi+';">'+
			'<div style="position:absolute;top:0px;left:0px;height:0px;width:0;font-size:1px;background-color:'+oBa+';" id="MWJ_progBar'+MWJ_progBar+'"></div></div>' );
	}
	document.write( '</td></tr></table></td></tr></table>\n' );
	this.setBar = resetBar; //doing this inline causes unexpected bugs in early NS4
	this.setCol = setColour;
}
function trimSpace(x)
    {
	   var emptySpace = / /g;
	   var trimAfter = x.replace(emptySpace,"");
	   return(trimAfter);
    }

function textValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z ]/g) != -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;
}

function textValidate1(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 ||  incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;
}
function numberValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9]/g) != -1 || incomingString==defaultValue || parseInt(incomingString, 10) <= 0 )
	{
		return false;
	}
	else
		return true;	
}

var emailexp = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z\-]+)\.(([a-zA-Z]{2,3}|[0-9]{1,3})|([a-zA-Z]{2}\.[a-zA-Z]{2}))$/;
function resetBar( a, b ) {
	//work out the required size and use various methods to enforce it
	this.amt = ( typeof( b ) == 'undefined' ) ? a : b ? ( this.amt + a ) : ( this.amt - a );
	if( isNaN( this.amt ) ) { this.amt = 0; } if( this.amt > 1 ) { this.amt = 1; } if( this.amt < 0 ) { this.amt = 0; }
	var theWidth = Math.round( this.width * ( ( this.dir % 2 ) ? this.amt : 1 ) );
	var theHeight = Math.round( this.height * ( ( this.dir % 2 ) ? 1 : this.amt ) );
	var theDiv = getRefToDivNest( this.id ); if( !theDiv ) { window.status = 'Progress: ' + Math.round( 100 * this.amt ) + '%'; return; }
	if( theDiv.style ) { theDiv = theDiv.style; theDiv.clip = 'rect(0px '+theWidth+'px '+theHeight+'px 0px)'; }
	var oPix = document.childNodes ? 'px' : 0;
	theDiv.width = theWidth + oPix; theDiv.pixelWidth = theWidth; theDiv.height = theHeight + oPix; theDiv.pixelHeight = theHeight;
	if( theDiv.resizeTo ) { theDiv.resizeTo( theWidth, theHeight ); }
	theDiv.left = ( ( this.dir != 3 ) ? 0 : this.width - theWidth ) + oPix; theDiv.top = ( ( this.dir != 4 ) ? 0 : this.height - theHeight ) + oPix;
}

function setColour( a ) {
	//change all the different colour styles
	var theDiv = getRefToDivNest( this.id ); if( theDiv.style ) { theDiv = theDiv.style; }
	theDiv.bgColor = a; theDiv.backgroundColor = a; theDiv.background = a;
}

var inti = 1;
var noofquestions = 12;

function hideall(){
	for(  j = 0 ; j < noofquestions ; ++j ){
		var div_id = "question_" + (j+1);
		document.getElementById(div_id).style.display = 'none';
	}
}

function show_next() {	
	var txt = "";
	var boxes;
	var i,boolNext;
	boolNext=true;
	inti = inti + 1;
	if( inti < (noofquestions + 1) ) {
		// hide all the divs
		//hideall();
		switch(inti)
			{
			case  2:
				if(document.getElementById('q11').checked==false&&document.getElementById('q12').checked==false&&document.getElementById('q13').checked==false&&document.getElementById('q14').checked==false&&document.getElementById('q15').checked==false&&document.getElementById('q16').checked==false&&document.getElementById('q17').checked==false) 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
			case 3:
				boxes = document.frmmintest.entercostreven.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.entercostreven[i].checked)  txt = txt + document.frmmintest.entercostreven[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 4:
				boxes = document.frmmintest.activmaninhouse.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.activmaninhouse[i].checked)  txt = txt + document.frmmintest.activmaninhouse[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 5:
				boxes = document.frmmintest.extpartner.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.extpartner[i].checked)  txt = txt + document.frmmintest.extpartner[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 6:
				boolNext=true;
							if(document.getElementById('q21').checked==false&&document.getElementById('q22').checked==false&&document.getElementById('q23').checked==false&&document.getElementById('q24').checked==false&&document.getElementById('q25').checked==false&&document.getElementById('q26').checked==false&&document.getElementById('q27').checked==false&&document.getElementById('q28').checked==false&&document.getElementById('q29').checked==false&&document.getElementById('q210').checked==false) 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 8:
				boxes = document.frmmintest.bussirepr.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.bussirepr[i].checked)  txt = txt + document.frmmintest.bussirepr[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 7:
				boxes = document.frmmintest.annuenter.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.annuenter[i].checked)  txt = txt + document.frmmintest.annuenter[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 9:
				boolNext=true;
						if(document.getElementById('q31').checked==false&&document.getElementById('q32').checked==false&&document.getElementById('q33').checked==false&&document.getElementById('q34').checked==false&&document.getElementById('q35').checked==false&&document.getElementById('q36').checked==false&&document.getElementById('q37').checked==false&&document.getElementById('q38').checked==false&&document.getElementById('q39').checked==false&&document.getElementById('q310').checked==false) 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 10:
				boxes = document.frmmintest.statagree.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.statagree[i].checked)  txt = txt + document.frmmintest.statagree[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 11:
				boxes = document.frmmintest.agenwork.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.agenwork[i].checked)  txt = txt + document.frmmintest.agenwork[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		   case 12:
				boxes = document.frmmintest.inhibscal.length;
				boolNext=true;
						for ( i = 0; i <boxes; i++)
							{  		
								if (document.frmmintest.inhibscal[i].checked)  txt = txt + document.frmmintest.inhibscal[i].value + "1";
							}
							if (txt == "") 
								{		
								alert ( "Please Select an option to proceed further");
								boolNext=false;
								inti = inti - 1;
								}
						break;
		
			}

		// show the requested div
		hideall();
		var div_id = "question_" + inti;
		document.getElementById(div_id).style.display = 'block';
	} else{
		inti = noofquestions;
		
	}
	if(boolNext){
	myProgBar.setBar(((100/11)/100),true);  //add 10% to the progress bar's progress
	myProgBar.setCol('#BBD900'); //change the colour of the progress bar
	}//if ends
}


//the main function, call to the effect object
function init(){	
	var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
	var toggles = document.getElementsByClassName('display'); //h3s where I click on
	//accordion effect
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, duration: 500}
	);

	//hash function		
	function checkHash(){
		var found = false;
		toggles.each(function(h3, i){
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(stretchers[i]);
				found = true;
			}
		});
		return found;
	}
	
	if (!checkHash()) myAccordion.showThisHideOpen(stretchers[tab]);
}

function reset()
{
	//document.rfp.reset();
}


//addEvent(window, 'load', init, true);


// arun - fox

function fox(x)
{
	if(navigator.appName=="Netscape")
	{
		if(x=="Other Services")
		{
			document.getElementById('footer_id').style.marginTop = 650 + "px";
			return false;
		}
		else if(x=="Business Travel")
		{
			document.getElementById('footer_id').style.marginTop = 110 + "px";
			return false;
		}
		else
		{
			document.getElementById('footer_id').style.marginTop = 10 + "px";
			return false;
		}
	}
}


// arun - logo

function log()
{	
	
	//document.getElementById('logo_id').style.marginRight = 15 + "px";
	return false;
}



// hide - show script

function call()
	{
		document.getElementById('malay').style.display="none";
		document.getElementById('sing').style.display="none";
		document.getElementById('musq').style.display="none";
		document.getElementById('sizz').style.display="none";

		document.getElementById('arun').selectedIndex=0;

		return false;
	}

	function show()
	{
		if(document.getElementById('arun').selectedIndex==0)
		{
			document.getElementById('that').style.display="block";			
			document.getElementById('malay').style.display="none";
			document.getElementById('sing').style.display="none";
			document.getElementById('musq').style.display="none";
			document.getElementById('sizz').style.display="none";
			return false;
		}
		else if(document.getElementById('arun').selectedIndex==1)
		{
			document.getElementById('that').style.display="none";			
			document.getElementById('malay').style.display="block";
			document.getElementById('sing').style.display="none";
			document.getElementById('musq').style.display="none";
			document.getElementById('sizz').style.display="none";
			return false;
		}
		else if(document.getElementById('arun').selectedIndex==2)
		{
			document.getElementById('that').style.display="none";			
			document.getElementById('malay').style.display="none";
			document.getElementById('sing').style.display="block";
			document.getElementById('musq').style.display="none";
			document.getElementById('sizz').style.display="none";
			return false;
		}
		else if(document.getElementById('arun').selectedIndex==3)
		{
			document.getElementById('that').style.display="none";			
			document.getElementById('malay').style.display="none";
			document.getElementById('sing').style.display="none";
			document.getElementById('musq').style.display="block";
			document.getElementById('sizz').style.display="none";
			return false;
		}
		else if(document.getElementById('arun').selectedIndex==4)
		{
			document.getElementById('that').style.display="none";			
			document.getElementById('malay').style.display="none";
			document.getElementById('sing').style.display="none";
			document.getElementById('musq').style.display="none";
			document.getElementById('sizz').style.display="block";
			return false;
		}
	
	}
