// JScript File

// Globals
// Major version of Flash required
var requiredMajorVersion = 6;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

function ShowFlash(movieSource,movieWidth,movieHeight)
{
    // Version check based upon the values entered above in "Globals"
    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    if (hasReqestedVersion) {
	    var movieId = 'control1_vector';

        var s='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
        s+='  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
        s+=' ID=' + movieId + ' WIDTH=' + movieWidth + ' HEIGHT=' + movieHeight + '>';
        s+=' <PARAM NAME=movie VALUE="' + movieSource + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=opaque> ';
        s+=' <EMBED src="' + movieSource + '" wmode="opaque" salign="T" quality="autohigh" allowScriptAccess="SameDomain"';
        s+=' WIDTH=' + movieWidth + ' HEIGHT=' + movieHeight + ' ID=' + movieId;
        s+=' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">';
        s+=' </EMBED>';
        s+=' </OBJECT>';
        
        // replace static div with flash
        if (document.getElementById('static') != null)
            document.getElementById('static').innerHTML = s;
        else
            document.write(s);  
    } 
    else 
    {  // flash is too old or we can't detect the plugin
	    var alternateContent = 'This content requires the Adobe Flash Player. '
	    + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
	    // replace static div with flash
        if (document.getElementById('static') != null)
            document.getElementById('static').innerHTML = alternateContent;
        else
	        document.write(alternateContent);  // insert non-flash content
    }
}

function validateEmail(emailStr) 
{
    var trimmed = emailStr.replace(/^\s+|\s+$/g, '');
    
    if (trimmed == "" || trimmed =="your email address") {
        return false;
    }
    
    var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    var matches = rx.exec(emailStr);
    var valid = (matches != null && emailStr == matches[0]);
    
    if (!valid)
      alert("Please enter a valid email address");
      
    return valid;
} 

function validatePassword(pswdStr)
{ 
	if(pswdStr.length<6)
	{
		 alert("Password must be at least 6 characters long"); 
		return false; 
	} 
	return true; 
}

/*
function FixIeFlashBorder()
{
 if(navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && (navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) &&  navigator.userAgent.indexOf("Safari")==-1){
  theObjects = document.getElementsByTagName("object"); 
  for (var i = 0; i < theObjects.length; i++) 
  theObjects[i].parentNode.innerHTML = theObjects[i].parentNode.innerHTML;
 }
}
*/

function Count(text,long) 
{
	var maxlength = new Number(long); // Change number to your max length.
	if (text.value.length > maxlength)
	{
		text.value = text.value.substring(0,maxlength);
		alert("Only " + long + " characters are allowed!");
	}
}

function cbHeadSignup(txtEmailHeader)
{
	if (validateEmail(txtEmailHeader)) {
		window.location="EmailSignUp.aspx?email=" + txtEmailHeader;
	}
	return false;
}

function getAbsoluteTop(objectId) 
{
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oTop = o.offsetTop;            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;  // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	// Return top position
	return oTop;
}
function getAbsoluteLeft(objectId) 
{
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft;            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;    // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	// Return left postion
	return oLeft;
}

function ShowSpinner(eve){
	var spinnerDiv = document.getElementById("spinner");
	spinnerDiv.style.display = "block";
}

function HideSpinner(){
	var spinnerDiv = document.getElementById("spinner");
	spinnerDiv.style.display = "none";
}

function ShowTaxCalculator(){
	var taxCalcDiv = document.getElementById("divTaxCalculator");
	taxCalcDiv.style.display = "block";
}

function HideTaxCalculator(){
	var taxCalcDiv = document.getElementById("divTaxCalculator");
	taxCalcDiv.style.display = "none";
}

function ShowSpinnerOnValidation(source, arguments){
	var zipCodePattern = /^\d{5}$|^\d{5}-\d{4}$/;
    if(zipCodePattern.test(arguments.Value)){
		arguments.IsValid = true;
		var resultContainer = document.getElementById('resultContainer');
		resultContainer.style.display = "none";
		ShowSpinner();
    }else{
		arguments.IsValid = false;
    }
}

function modalWin(popupUrl, width, height) {
window.open(popupUrl,'name', 'height='+height+',width='+width+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
/*
This is creates a modal popup window
if (window.showModalDialog) {
	window.showModalDialog(popupUrl,"name", "dialogWidth:255px;dialogHeight:250px;dialogTop:100px;dialogLeft:100px;");
} else {
	window.open(popupUrl,'name', 'height=255,width=250,top=100,left=100,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
}
*/
} 