// JavaScript Document //

function FindObj(n, d) { // v4.01  
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {  
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);  
  if(!x && d.getElementById) x=d.getElementById(n); return x;  
}

function Layers() { //v6.0
  var i,p,v,obj,args=Layers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=FindObj(args[i]))!=null) { v=args[i+2];
  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openTicker() {
            //alert('called');
            if(screen.width){
                        var winl = (screen.width-800)/2;
                        var wint = (screen.height-150)/2;
            }else{
                        winl = 0;wint =0;
            }

            if (winl < 0) winl = 0;
            if (wint < 0) wint = 0;
            var settings = 'height=' + 120 + ',';
            settings += 'width=' + 800 + ',';
            settings += 'top=' + wint + ',';
            settings += 'screenY=' + wint + ',';
            settings += 'left=' + winl + ',';
            settings += 'screenX=' + winl + ',';
            settings += 'location=no';
            win = window.open('/ticker_minimized.htm','ticker',settings);
            win.window.focus();
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
function ticker_DoFSCommand(command, args) {
            var tickerObj = isInternetExplorer ? document.all.ticker : document.ticker;
            eval(command+'('+args+')');
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
            document.write('<script language=\"VBScript\"\>\n');
            document.write('On Error Resume Next\n');
            document.write('Sub ticker_FSCommand(ByVal command, ByVal args)\n');
            document.write(' Call ticker_DoFSCommand(command, args)\n');
            document.write('End Sub\n');
            document.write('</script\>\n');
}

function CheckSubscribe() {
	var sSubscribe = document.subform.fSubscribe.value;
	SubContainer = window.parent.document.getElementById('sub_status');

	if (sSubscribe=="E-mail address") {
		SubContainer.innerHTML = "<span><strong>Please provide your email address.</strong></span>";
		return false;
	} else {
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(sSubscribe)) {
			//SubContainer.innerHTML = "<span><strong>You have been added to the Tour Insider mailing list.</strong></span>";
			//Check Email
			TIcheckEmail(sSubscribe);
			return false;
		} else {
			SubContainer.innerHTML = "<span><strong>Please provide a valid email address.</strong></span>";
			return false;
		}

	}
}


/* == Ajax calls == */
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    } 
  } 
}
return req;
}

var http = getXMLHTTPRequest();

/* Check email address */
function TIcheckEmail(addy) {
	http.open("GET", "/news/sendInsider.aspx?addy="+addy, true);
	http.onreadystatechange = function () {
		if (http.readyState == 4) {
			if (http.status == 200) {
				//alert(http.responseText);
				document.getElementById('sub_status').innerHTML = http.responseText;
			} else {
				document.getElementById('sub_status').innerHTML = "An error occurred here: " + http.statusText;
			}
		} else {
			document.getElementById('sub_status').innerHTML = "<span><em>(Please wait...)</em></span>";
		}           
	};
	http.send(null);
}





/* Professor Shaft redirect */
function ustResultWindow(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)
{
	var output = "";

	// Build profile parms
	output += "ustFinalName=" + escape(arg0) + "&";
	output += "ustFinalAddress=" + escape(arg1) + "&";
	output += "ustFinalCity=" + escape(arg2) + "&";
	output += "ustFinalState=" + escape(arg3) + "&";
	output += "ustFinalZip=" + escape(arg4) + "&";
	output += "ustFinalEmail=" + escape(arg5) + "&";
	output += "ustFinalHandicap=" + arg6 + "&";
	output += "ustFinalUpdates=" + escape(arg7) + "&";
	
	// Build rec parms
	output += "ShaftType=" + arg8 + "&";
	output += "cd=" + arg9 + "&";
	output += "bf=" + arg10 + "&";
	output += "fl=" + arg11 + "&";
	output += "ShaftId1=0&ShaftId2=0&";
	output += "FromFlash=1";
	
	var op = "/shaftfitresult.asp?" + output;	
	
	window.location=op;
}