var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_opera = (agt.indexOf("opera") != -1);
var is_ff = (agt.indexOf("firefox") != -1);
var is_win = (agt.indexOf("windows") != -1);
	
function playCaptcha() {
	var data = new Array();
	url = 'http://' + subdomain + '.finda.co.nz/captcha_sounds/';

	for(var c = 0; c < capchas.length; c++) {
		data.push(url+ capchas[c] + '.wav');
	}
	for (var i = 0; i < data.length; i++) {
		setTimeout("buildCaptchaAudio('"+ data[i] +"', '"+ i +"');", i*1*1000);
	}
}

function buildCaptchaAudio(audioFile, order) {
	elementId = 'captcha' + order;
	
	if (is_ie) {
     	// IE GETS BGSOUND
     	track = Builder.node('bgsound',{id:elementId, src:audioFile, loop:1, autostart:'true'});
	} else if (is_ff && is_win) {
		// FF ON WIN GETS WMV
		track = Builder.node('embed', {type:'application/x-mplayer2', pluginspage:'http://microsoft.com/windows/mediaplayer/en/download/',        id:elementId, name:'mediaPlayer', displaysize:'4', autosize:'-1', bgcolor:'darkblue', showcontrols:'false', showtracker:'-1', showdisplay:'0', showstatusbar:'-1', videoborder3d:'-1', width:'0', height:'0', src:audioFile, autostart:'true', designtimesp:'5311', loop:'false'});
	} else {
		// ALL OTHERS ARE GENERIC
		track = Builder.node('embed',{id:elementId, src:audioFile, loop:'false', autostart:'true', hidden:'true'});
	}
	document.body.appendChild(track);
	setTimeout("document.body.removeChild(document.getElementById('"+ elementId +"'));", 1*1000);						
}
