// this is for fpp trajectoty progress displaying
var wsop09cirRad = 348; // radius of trajectory circle in pixels
var wsop09cirX = 276; // left position of trajectory circle center in pixels
var wsop09cirY = 555; // top position of trajectory circle center in pixels
var wsop09_angStart = 5; // start angle of trajectory circle
var wsop09_1Seg = new Array(10, 100); // 1st segment (angle of this segment, amount of FPPs for this segment)
var wsop09_2Seg = new Array(10, 100); // 2nd segment (angle of this segment, amount of FPPs for this segment)
var wsop09_3Seg = new Array(15, 200); // 3rd segment (angle of this segment, amount of FPPs for this segment)
var wsop09_4Seg = new Array(40, 1600); // 4th segment (angle of this segment, amount of FPPs for this segment)
var wsop09angFrag = 2.5; // angle between dots (all angles in degrees)
var wsop09imgSize =  11; // width(=height) of bullet image in pixels

wsop09fppCheck = function(radius, xPos, yPos, angStart, angEnd) {
	for(var i = angStart; i <= angEnd; i += 2*Math.PI/360*wsop09angFrag) {	
		var x = xPos + Math.round(Math.cos(i)*radius) - Math.floor(wsop09imgSize/2);
		var y = yPos - Math.round(Math.sin(i)*radius) - Math.floor(wsop09imgSize/2);	
		document.write('<div class="fppBullet" style="top:' + y + 'px; left:' + x + 'px;"></div>');
	}
}
var wsop09fpp;
wsop09fppCheckThis = function() {
	wsop09fpp = location.href.split("fpp=")[1];
	if(wsop09fpp > 0) wsop09fppCheck(wsop09cirRad, wsop09cirX, wsop09cirY, 2*Math.PI/360*wsop09_angStart, 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0]/wsop09_1Seg[1]*((wsop09fpp <= wsop09_1Seg[1])?wsop09fpp:wsop09_1Seg[1])));
	if(wsop09fpp > wsop09_1Seg[1]) wsop09fppCheck(wsop09cirRad, wsop09cirX, wsop09cirY, 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0]), 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0] + wsop09_2Seg[0]/wsop09_2Seg[1]*(((wsop09fpp <= wsop09_1Seg[1] + wsop09_2Seg[1])?wsop09fpp:wsop09_1Seg[1] + wsop09_2Seg[1])-wsop09_1Seg[1])));
	if(wsop09fpp > wsop09_2Seg[1]) wsop09fppCheck(wsop09cirRad, wsop09cirX, wsop09cirY, 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0] + wsop09_2Seg[0]), 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0] + wsop09_2Seg[0] + wsop09_3Seg[0]/wsop09_3Seg[1]*(((wsop09fpp <= wsop09_1Seg[1] + wsop09_2Seg[1] + wsop09_3Seg[1])?wsop09fpp:wsop09_1Seg[1] + wsop09_2Seg[1] + wsop09_3Seg[1])-(wsop09_1Seg[1] + wsop09_2Seg[1]))));
	if(wsop09fpp > wsop09_3Seg[1]) wsop09fppCheck(wsop09cirRad, wsop09cirX, wsop09cirY, 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0] + wsop09_2Seg[0] + wsop09_3Seg[0]), 2*Math.PI/360*(wsop09_angStart + wsop09_1Seg[0] + wsop09_2Seg[0] + wsop09_3Seg[0] + wsop09_4Seg[0]/wsop09_4Seg[1]*(((wsop09fpp <= wsop09_1Seg[1] + wsop09_2Seg[1] + wsop09_3Seg[1] + wsop09_4Seg[1])?wsop09fpp:wsop09_1Seg[1] + wsop09_2Seg[1] + wsop09_3Seg[1] + wsop09_4Seg[1])-(wsop09_1Seg[1] + wsop09_2Seg[1] + wsop09_3Seg[1]))));
}

// this is for board text changing
wsop09changeInBox = function() {
		for(var i = 0; i < 6; i++) eval('document.getElementById("txt'+i+'").style.display="none";');
		for(var i=0; i < arguments.length; i++) eval('document.getElementById("txt"+arguments['+i+']).style.display = "block"');
		if(arguments[0]==4 && document.getElementById("txt4").innerHTML=="") {
			document.getElementById("txt4").innerHTML = '<iframe width="476" height="180" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?hl=en&amp;ie=UTF8&amp;source=embed&amp;msa=0&amp;msid=116232454938803451872.000467f92bdfde597e603&amp;ll=37.71859,-7.03125&amp;spn=93.467955,322.03125&amp;z=1&amp;output=embed"></iframe>';
			document.getElementById("txt5").href = 'http://maps.google.com/maps/ms?hl=en&ie=UTF8&source=embed&msa=0&msid=116232454938803451872.000467f92bdfde597e603&ll=37.71859,-7.03125&spn=93.467955,322.03125&z=1';
		}
}

// this is for wrong pin message displaying
wsop09pinTxt = function() {
	if(location.href.split("fpp=")[1] == "invalid" || arguments[0] == 1) document.getElementById("wrongPin").style.display = "block";
	if(arguments[0] == 0) document.getElementById("wrongPin").style.display = "none";
}

// this will fill in the numbers and text on qualifiers according to FPPs
var vegasQualified;
wsop09vegasQualified = function() {
	var vegasQualifiedLevel;
	vegasQualified = (wsop09fpp >= (vegasQualifiedLevel=wsop09_4Seg[1]+wsop09_3Seg[1]+wsop09_2Seg[1]+wsop09_1Seg[1])) ? 4 : ((wsop09fpp >= (vegasQualifiedLevel=wsop09_3Seg[1]+wsop09_2Seg[1]+wsop09_1Seg[1])) ? 3 : ((wsop09fpp >= (vegasQualifiedLevel=wsop09_2Seg[1]+wsop09_1Seg[1])) ? 2 : ((wsop09fpp >= (vegasQualifiedLevel=wsop09_1Seg[1])) ? 1 : 0)));
	if(vegasQualified < 1) vegasQualifiedLevel = 0;
	var vegasQualifiedTxt = document.getElementById("vegasQualified");
	vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/\[VAR1\]/g, wsop09fpp).replace(/\[VAR3\]/g, vegasQualified+1).replace(/\[VAR4\]/g, (vegasQualified<4)?eval("vegasQualifiedLevel + wsop09_"+(vegasQualified+1)+"Seg[1] - wsop09fpp"):0);
	var tempTextAnd = vegasQualifiedTxt.innerHTML.split("[VAR2] ")[1].split(" ")[0];
	var tempTextVegas = vegasQualifiedTxt.innerHTML.split(" [VAR2x]")[0].split(tempTextAnd+" ")[1];
	if(vegasQualified == 1) vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/\[VAR2\] .+ \[VAR2x\]/g, vegasQualified);
	else for(var i = vegasQualified; i > 0; i--) {
		if(i == vegasQualified) vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/\[VAR2x\]/, i);
		else vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/\[VAR2\]/, "[VAR2], "+tempTextVegas+" "+i);
		if(i < 2) vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.split(tempTextVegas+" [VAR2], ")[0]+vegasQualifiedTxt.innerHTML.split(tempTextVegas+" [VAR2], ")[1];
	}
	if(vegasQualified > 3) vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/none/g, 'inherit').replace(/block/g, 'none');

            else if(vegasQualified > 0) vegasQualifiedTxt.innerHTML = vegasQualifiedTxt.innerHTML.replace(/none/g, 'block');
}

// this will highlight table header of qualified Vegas
wsop09vegasQualifiedTab = function() {
	for(var i = 1; i <= vegasQualified; i++) eval('document.getElementById("vegasQualified'+ i +'").style.backgroundColor = "#c00";');
}

