var countQuery = 0;
var countLocation = 0;
var optionsQuery = new Array("Java Developer", "Linux", "IT Manager", "Security admin", "Network Administrator", "Web Designer", "DBA", "HP Unix");
var optionsLocation = new Array("Bangalore", "Mumbai", "Delhi", "Hyderabad", "Pune", "Ahmedabad", "Chandigarh", "Baroda");
var demo = 'true';

function start(temp) {
	demoQuery(temp);
	demoLocation(temp);
}

function showDemo() {
	if( (document.getElementById('location').value != "") || (document.getElementById('query').value != "") ) {
		demo='false';
	}
	if( (document.getElementById('location').value == "") && (document.getElementById('query').value == "") ) {
		demo='true';
	}
	if( demo == 'true' ) {
		demoLocation(0);
		demoQuery(0);
	}
}



function clearDemo() {
	if( demo == 'true') {
		clearDemoLocation();
		clearDemoQuery();
	}
	if( (document.getElementById('location').value != "") || (document.getElementById('query').value != "") ) {
		demo='false';
	}
	if( (document.getElementById('location').value == "") && (document.getElementById('query').value == "") ) {
		demo='true';
	}	
}



function demoLocation(temp) {
	
	document.getElementById('location').value=optionsLocation[temp].substring(0,countLocation);
	countLocation=countLocation+1;
	
	var step = 100;
	
	if( countLocation > optionsLocation[temp].length) {
		temp = temp + 1;
		countLocation = 0;
		step = 1500;
	}
	
	if(temp == optionsLocation.length) {
		temp = 0;
	}
	
	t1=setTimeout("demoLocation("+temp+")",step);		
	
}	


function showDemoLocation() {
	if(document.getElementById('location').value == "") {
		demoLocation(0);
	}
}

function clearDemoLocation() {
	clearTimeout(t1);
	document.getElementById('location').value=""
}

function demoQuery(temp) {
	
	document.getElementById('query').value=optionsQuery[temp].substring(0,countQuery);
	countQuery=countQuery+1;
	
	var step = 100;
	
	if( countQuery > optionsQuery[temp].length) {
		temp = temp + 1;
		countQuery = 0;
		step = 1500;
	}
	
	if(temp == optionsQuery.length) {
		temp = 0;
	}
	
	t=setTimeout("demoQuery("+temp+")",step);		
	
}	


function showDemoQuery() {
	if(document.getElementById('query').value == "") {
		demoQuery(0);
	}
}

function clearDemoQuery() {
	clearTimeout(t);
	document.getElementById('query').value=""
}