﻿onerror=unhandledException;
var RecaptchaOptions = {theme : 'white'};

/* BEGIN SECURE/NON-SECURE PAGE HANDLING */
var SECUREPAGES = "|checkout.html|order-confirmation.html|terms-of-service.html|my-ticketcity.html|contact-form.html|";

try
{
    var bSecure = false;
    var strURL = window.location.href.toString().toLowerCase(); 
    var strPage = window.location.pathname.toString().toLowerCase();
    strPage = strPage.substring(strPage.lastIndexOf("/")+1);
    if(SECUREPAGES.indexOf("|"+strPage+"|")>-1){bSecure=true;}
    if(bSecure&&strURL.indexOf("http://")==0)
    {
         window.location.href=strURL.replace("http://","https://");
    }  
    else if(!bSecure&&strURL.indexOf("https://")==0)
    {
         window.location.href=strURL.replace("https://","http://");
    }
}
catch(ex){/**/}
/* END SECURE/NON-SECURE PAGE HANDLING */


/* BEGIN AFFILIATE TRACKING */
    document.cookie = 'TCAffReferrer=' + document.referrer + '; path=/';
/* END AFFILIATE TRACKING */

/* BEGIN UPDATE CART QTY */
function updateCartQtyDisplay()
{
	try{returnObj("spanCartItemQty").obj.innerHTML=(readCookie("CartItemQty")==""||readCookie("CartItemQty")==null)?"0":readCookie("CartItemQty");}catch(ex){/*carry on*/}
}
/* END UPDATE CART QTY */

/* BEGIN OBJECT FUNCTIONS */
function getObj(name)
{
    if (document.getElementById)
    {
        this.obj = document.getElementById(name);
        this.style = document.getElementById(name).style;
    }
    else if (document.all)
    {
        this.obj = document.all[name];
        this.style = document.all[name].style;
    }
    else if (document.layers)
    {
        this.obj = document.layers[name];
        this.style = document.layers[name];
    }
}

function returnObj(name)
{
    try
    {
        if (document.getElementById)
        {
            this.obj = document.getElementById(name);
            this.style = document.getElementById(name).style;
        }
        else if (document.all)
        {
            this.obj = document.all[name];
            this.style = document.all[name].style;
        }
        else if (document.layers)
        {
            this.obj = document.layers[name];
            this.style = document.layers[name];
        }
        return this;
    }
    catch(err)
    {
        return false;
    } 
}
/* END OBJECT FUNCTIONS */



/* BEGIN DISPLAY FUNCTIONS */
function showHide(id, method)
{
	if(method == "hide")
	{
	    returnObj(id).style.display="none";
	}
	else/*show*/
	{
	    returnObj(id).style.display="";
	}
}

function showHideModalBG(method)
{
    if(method=="hide")
    { 
        returnObj("divModalBG").style.display="none";
    }
    else /*show*/
    {
        returnObj("divModalBG").style.height=returnObj("divMain").obj.offsetHeight + "px";
        returnObj("divModalBG").style.display="";
    }
}
 /* FOLLOWING FOR MOUSEOVER DIV */
function myMouseOut(e) 
{
	try
    {
        if (!e) var e = window.event;
	    var tg = (window.event) ? e.srcElement : e.target;
	    if (tg.nodeName != 'DIV') return;
	    var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	    while (reltg != tg && reltg.nodeName != 'BODY')
		    reltg= reltg.parentNode;
	    if (reltg!= tg){
	     returnObj('divEventPop').style.display = "none";
	    }
	 }
	 catch(ex){ /* carry on, people moving mouse way too fast */ }
}
/* END DISPLAY FUNCTIONS */



/* BEGIN COOKIE FUNCTIONS */
function createCookie(name,value,days)
{
    if (days)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++)
    {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name)
{
    createCookie(name,"",-1);
}
/* END COOKIE FUNCTIONS */



/* BEGIN EVENT FUNCTIONS */
function enterKeyClick(e,btnID)
{
    try
    { 
        if(!e){var e = window.event;}
        if(e.keyCode){code = e.keyCode;}
        else if(e.which){code = e.which;}
        e.cancelBubble = true;
	    if (e.stopPropagation){e.stopPropagation();}
	    if(code==13)
	    {
	        returnObj(btnID).obj.click();
	    }
	    return false;
	}
    catch(ex){/*carry on*/}
}
/* END EVENT FUNCTIONS */



/* BEGIN POSITIONING FUNCTIONS */
function positionFooter()
{
    positionFooterEx(0);
}
function positionFooterEx(nLayoutType)
{
    try
        {
        var divHeaderHeight = 122;
        var divContentHeight = 440;
        var divFooterHeight = 30;
        var featuredOffset = 25; /* this is the offset height of the featured events+cities control */
        var bHasFooter = true;
        
        var divFooterOffsetMarginTop = divHeaderHeight+divContentHeight;

        /* Layout Type 0 = header, big left column, small right column, footer */
        /* Layout Type 1 = header, big content area, footer */
        switch(nLayoutType)
        {
            case 0:
                returnObj("divContent").style.height="auto";
                returnObj("divExtras").style.height="auto";

//alert("divExtras: "+returnObj("divExtras").obj.offsetHeight);
 
                if(returnObj("divContent").obj.offsetHeight<divContentHeight){returnObj("divContent").style.height=divContentHeight.toString() + "px";}
                if((returnObj("divExtras").obj.offsetHeight+featuredOffset)<divContentHeight){returnObj("divExtras").style.height=divContentHeight.toString() + "px";}
                /*divFooterOffsetMarginTop = divHeaderHeight+divContentHeight;*/

//alert("divExtras: "+returnObj("divExtras").obj.offsetHeight+"\nFeatured Offset: "+featuredOffset+"\ndivFooterOffsetMarginTop: "+divFooterOffsetMarginTop+"\ndivContent: "+returnObj("divContent").obj.offsetHeight);

                if((returnObj("divExtras").obj.offsetHeight+featuredOffset)<divFooterOffsetMarginTop){returnObj("divExtras").style.height=divFooterOffsetMarginTop.toString() + "px";}
                if(returnObj("divContent").obj.offsetHeight>(returnObj("divExtras").obj.offsetHeight+featuredOffset))
                {
                    returnObj("divExtras").style.height= (returnObj("divContent").obj.offsetHeight-returnObj("divHeader").obj.offsetHeight).toString() + "px";
                    divFooterOffsetMarginTop = (returnObj("divContent").obj.offsetHeight+returnObj("divHeader").obj.offsetHeight).toString();
                }
                else
                {
                    divFooterOffsetMarginTop = (returnObj("divExtras").obj.offsetHeight+featuredOffset+returnObj("divHeader").obj.offsetHeight).toString();
                }
//alert("divFooterOffsetMarginTop: "+divFooterOffsetMarginTop);
                break;
            case 1:
                returnObj("divContentWide").style.height="auto";
    /*alert(returnObj("divContentWide").obj.offsetHeight);*/
                if(returnObj("divContentWide").obj.offsetHeight<divContentHeight){/*alert("divContHei is taller");*/returnObj("divContentWide").style.height=divContentHeight.toString() + "px";}/*else{alert("nope real content is taller");}*/
                /*var divFooterOffsetMarginTop = divHeaderHeight+divContentHeight;*/
                divFooterOffsetMarginTop = (returnObj("divContentWide").obj.offsetHeight+returnObj("divHeader").obj.offsetHeight).toString();
    /*alert(returnObj("divHeader").obj.offsetHeight);*/
    /*alert(divFooterOffsetMarginTop);*/
                break; 
                
            case 2:
                returnObj("divContentWide").style.height="auto";
                if(returnObj("divContentWide").obj.offsetHeight<divContentHeight){/*alert("divContHei is taller");*/returnObj("divContentWide").style.height=divContentHeight.toString() + "px";}/*else{alert("nope real content is taller");}*/
                divFooterOffsetMarginTop = (returnObj("divContentWide").obj.offsetHeight+returnObj("divHeader").obj.offsetHeight).toString();
                /*bHasFooter = false;*/
                returnObj("divContentWide").style.marginTop=returnObj("divHeader").obj.offsetHeight+"px";
    /*
    alert(returnObj("divContentWide").obj.offsetHeight);
    alert(returnObj("divHeader").obj.offsetHeight);
    alert(divFooterOffsetMarginTop);
    */
                break;
        }
        
        if(bHasFooter)
        {  
            returnObj("divFooter").style.marginTop=divFooterOffsetMarginTop + "px";
            returnObj("divMain").style.height=(returnObj("divFooter").obj.offsetHeight+parseInt(divFooterOffsetMarginTop))+"px";
        }
        else
        {
             returnObj("divMain").style.height=divFooterOffsetMarginTop+"px";
        }

//alert("divFooterOffsetMarginTop: "+divFooterOffsetMarginTop);
//alert("divFooter: "+returnObj("divFooter").style.marginTop);

    }
    catch(ex)
    {
        var strParams = "strErrorMsg="+getDebugInfo()+getExceptionInfo(ex)+"&strSubject=JS_Exception_positionFooterEX&bIsHtmlMsg=true";  
        ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);    
    }
    
}
/* END POSITIONING FUNCTIONS */



/* BEGIN STRING FUNCTIONS */
function InStr(strSearched, strSearchFor)
{
    for (i=0; i < (Len(strSearched)-Len(strSearchFor)+1); i++)
    {
        if (strSearchFor == Mid(strSearched, i, Len(strSearchFor)))
        {
            return i;
        }
    }
    return -1;
}

function Mid(str, start, len)
{
    if (start < 0 || len < 0) {return ""};
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
    { 
        iEnd = iLen;
    }        
    else
    { 
        iEnd = start + len;
    }
    return String(str).substring(start,iEnd);
}

function Left(str, n)
{
    if (n <= 0)
    {
        return "";
    }
    else if (n > String(str).length)
    { 
        return str;
    }
    else
    { 
        return String(str).substring(0,n);
    }
}

function Right(str, n)
{
    if (n <= 0)
    { 
        return "";
    }
    else if (n > String(str).length)
    { 
        return str;
    } 
    else
    {
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
}

function Len(str)
{
    return String(str).length; 
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function Trim(str)
{
    return str.replace(/^\s+/, "").replace(/\s+$/, "");
}

function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}

/* Appends the given value to the end of this instance. */

StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}

/* Clears the string buffer */

StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}

/* Converts this instance to a String. */

StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
} 

function getPageName()
{
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    sPage = sPage.substring(0, sPage.length - 5);
    return sPage; 
 }
/* END STRING FUNCTIONS */


/* BEGIN SEARCH FUNCTION */
function goSearch(searchTerm)
{
    var q = trim(searchTerm).replace("'", "").replace("&", "%26");
    if (q == "find tickets" || q == "")
    {
        return false;
    }
    else
    { 
        window.location.href="/search.html?q=" + q; 
    }
}
/* END SEARCH FUNCTION */

/* BEGIN ERROR FUNCTIONS */
function getDebugInfo()
{
    var strInfo = "<b>DEBUG INFO:</b><br />";
    try
    {  
        try{strInfo = strInfo + "<b>page:</b> " + location.href + "<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>URL:</b> " + document.URL + "<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>title:</b> " + document.title + "<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>referrer:</b> " + document.referrer + "<br />";}catch(ex){/**/}
        
        try{strInfo = strInfo + "<b>platform:</b> "+navigator.platform+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>appCodeName:</b> "+navigator.appCodeName+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>appName:</b> "+navigator.appName+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>appVersion:</b> "+navigator.appVersion+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>appMinorVersion:</b> "+navigator.appMinorVersion+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>userAgent:</b> "+navigator.userAgent+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>browserLanguage:</b> "+navigator.browserLanguage+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>systemLanguage:</b> "+navigator.systemLanguage+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>userLanguage:</b> "+navigator.userLanguage+"<br />";}catch(ex){/**/}
        try{strInfo = strInfo + "<b>cpuClass:</b> "+navigator.cpuClass+"<br />";}catch(ex){/**/}
    }
    catch(exx){strInfo=strInfo+"...couldn't retrieve all debug info<br />";}
    strInfo = strInfo + "<hr />";
    strInfo = strInfo + getCookieInfo() + getFormInfo(); 
    return strInfo; 
}

function getExceptionInfo(ex)
{
    var strException = "<b>JAVASCRIPT EXCEPTION:</b><br />";
    try
    {  
        try{strException = strException + "<b>name:</b>" + ex.name + "<br /><b>message:</b>" + ex.message + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>description:</b>" + ex.description + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>number:</b>" + ex.number + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>fileName:</b>" + ex.fileName + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>lineNumber:</b>" + ex.lineNumber + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>stack:</b>" + ex.stack + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>toSource:</b>" + escape(ex.toSource) + "<br />";}catch(e){/**/}
        try{strException = strException + "<b>toString:</b>" + ex.toString() + "<br />";}catch(e){/**/}
    }
    catch(exx){strException=strException+"...couldn't retrieve all exception info<br />";} 
    return strException;
}

function unhandledException(msg,url,line)
{
    var strInfo = "<b>Message:</b> "+msg+"<br /><b>URL:</b> "+url+"<br /><b>Line Number:</b> "+line + "<hr />";
    var strParams = "strErrorMsg="+strInfo.replace("&", "&#38;")+getDebugInfo().replace("&", "&#38;")+"<br /><hr />"+stackTrace(arguments.callee).replace("&", "&#38;")+"&strSubject=JS_UNHANDLED-EXCEPTION&bIsHtmlMsg=true";
    ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);    
}

function getFormInfo()
{
    var strInfo = "<b>FORM FIELDS:</b><br />";
    for(n in document.forms[0].elements)
    {
        try
        {
            switch(document.forms[0].elements[n].type)
            {
                case "text":
                case "hidden":
					if(document.forms[0].elements[n].id.toString().toUpperCase().indexOf("CVV")==-1) // do not log CVV info
					{
						strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.value + "<br />";
					}
                    break;
                case "radio":
                    strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.value + " [" + returnObj(document.forms[0].elements[n].id).obj.checked + "]<br />";
                    break;
                case "checkbox":
                    strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + " [" + returnObj(document.forms[0].elements[n].id).obj.checked + "]<br />";
                    break;
                case "select-one":
                    strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.options[returnObj(document.forms[0].elements[n].id).obj.selectedIndex].text + "<br />";
                    break;
            }
        }
        catch(ex){/*carry on*/}
    }
    return strInfo + "<hr />"; 
}

function getCookieInfo()
{
    var strInfo = "<b>COOKIE VALUES:</b><br />";
    var strCookies = document.cookie.split(";");   
    for(n in strCookies)
    {
        strInfo = strInfo + escape(strCookies[n]) + "<br />";
    }
    return strInfo + "<hr />"; 
}

	function stackTrace(startingPoint)
	{
		var stackTraceMessage = "<b>STACK TRACE:</b> <br>\n";
		var nextCaller = startingPoint;
		while(nextCaller)
		{
			stackTraceMessage += getSignature(nextCaller) + "<br>\n";
			nextCaller = nextCaller.caller;
		}
		stackTraceMessage += "<br>\n\n";
		
		// return message
		return stackTraceMessage; 
	}
	
	function getSignature(theFunction)
	{
		var signature = getFunctionName(theFunction);
		signature += "(";
		for(var x=0; x<theFunction.arguments.length; x++)
		{
			// trim long arguments
			var nextArgument = theFunction.arguments[x];
			if(nextArgument.length > 30)
				nextArgument = nextArgument.substring(0, 30) + "...";
			
			// apend the next argument to the signature
			signature += "'" + nextArgument + "'"; 
			
			// comma seperator
			if(x < theFunction.arguments.length - 1)
				signature += ", ";
		}
		signature += ")";
		return signature;
	}
	
	function getFunctionName(theFunction)
	{
		// mozilla makes it easy. I love mozilla.
		if(theFunction.name)
		{
			return theFunction.name;
		}
		
		// try to parse the function name from the defintion
		var definition = theFunction.toString();
		var name = definition.substring(definition.indexOf('function') + 8,definition.indexOf('('));
		if(name)
			return name;

		// sometimes there won't be a function name 
		// like for dynamic functions
		return "anonymous";
	}


/* END ERROR FUNCTIONS */

/* BEGIN PAGE LOGGING */
function LogPageRequest()
{
    try
   { 
        getClick2C_ID();
        var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogPageRequest";
        var strParams = "RefURL="+URLencode(document.referrer)+"&ReqURL="+URLencode(document.URL);

        var strYahoo = "search.yahoo.com/";
        var strGoogle = ".google.com/search?";
        var strMSN = "search.msn.com";
        var strLive = "search.live.com";
                
        // ignore no referrar; Yahoo/Overture PPC; Google PPC
        if (document.referrer != ''&&window.location.href.indexOf("s_kwcid=")<0&&window.location.href.indexOf("ovcrn=")<0&&window.location.href.indexOf("gclid=")<0&&(document.referrer.indexOf(strYahoo) > 0 || document.referrer.indexOf(strGoogle) > 0 || document.referrer.indexOf(strMSN) > 0 || document.referrer.indexOf(strLive) > 0))
       {
            strParams = strParams+"&SERef=TRUE";
        }
        else
        {
            strParams = strParams+"&SERef=FALSE";
        }

        ajaxPost(strParams,strServiceURL);
    }
   catch(e) {}
}

function URLencode(sStr)
{
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

/* END PAGE LOGGING */

/* BEGIN Click2 TRACKING DETECTION */
function getClick2C_ID()
{
   var strC2CampaignID = parseQueryString('BrCg'); 
   var strC2RecipientID = parseQueryString('BrRc');
   var strC2CustomerID = parseQueryString('BrCs'); 
  
   if(readCookie('c2cid')!='' && readCookie('c2cid')!=null) //cookie exists
   {
        if (strC2CampaignID != false) // it is in the querystring // 
        {
            if (readCookie('c2cid')!= strC2CampaignID)
            {
                eraseCookie('c2cid');
                createCookie('c2cid', strC2CampaignID);
            }
            else if (readCookie('c2rid')!= strC2RecipientID)
            {
                eraseCookie('c2rid'); 
                createCookie('c2rid', strC2RecipientID); 
            }
            else if (readCookie('c2custID')!=strC2CustomerID)
            { 
                eraseCookie('c2custID');  
                createCookie('c2custID', strC2CustomerID);               
            } 
         }
   }
   else
   {
        if(strC2CampaignID != false) //c2cid is in the qs
        {
            createCookie('c2cid', strC2CampaignID);
            createCookie('c2rid', strC2RecipientID); 
            createCookie('c2custID', strC2CustomerID);  
        }
   }     
}
/* END Click2 TRACKING DETECTION */


/* BEGIN EMAIL FORM FUNCTIONS */
function submitEmailForm(id)
{
	var strFormData = "";
    var n;
	var bPost = true;
	 
    var strInputs = returnObj("hidEF_"+id+"_text").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(1,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}
	
    strInputs = returnObj("hidEF_"+id+"_textarea").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(1,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}

    strInputs = returnObj("hidEF_"+id+"_select").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(2,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.options[returnObj(strInputs[n]).obj.selectedIndex].value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}
	
    strInputs = returnObj("hidEF_"+id+"_checkbox").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(4,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.checked) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}

    strInputs = returnObj("hidEF_"+id+"_radio").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(3,strInputs[n]))
			{
				var rdos = getElementsByAttribute(document.documentElement,"input","name",strInputs[n]);
				for(var x = 0; x < rdos.length; x++)
				{
					if(rdos[x].checked)
					{
						strFormData = strFormData + strInputs[n] + "=" + escape(rdos[x].value) + "::";
					} 
				}
			}
			else
			{
				bPost = false;
			}
		}
	}
	
    strInputs = returnObj("hidEF_"+id+"_hidden").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
		}
	}
	    
	if(bPost)
	{ 
		var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/EmailForm";
		var strParams = "ID="+id+"&FormData="+strFormData;

		ajaxPost(strParams,strServiceURL,"confirmEmailForm");
	}
	else
	{
		alert("There was a problem with your request!\n\nPlease fill out the form completely and try again.\n\n");
	}
}

function confirmEmailForm(xml)
{
    var bActiveX=true;
	if (document.implementation && document.implementation.createDocument)
	{
	    bActiveX=false;
		xmlDoc = document.implementation.createDocument("", "", null);
		parser=new DOMParser();
        xmlDoc=parser.parseFromString(xml,"text/xml");
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(xml);
 	}
	else
	{
		alert("Your browser is having problems with our website!\n\nPlease call us to resolve this issue.");
		return;
	}

    switch(xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("Status"))
    {
        case "0":
			returnObj("divEF_"+xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("ID")).style.display="none";
			returnObj("divEFC_"+xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("ID")).style.display="";
            break;
        default:
            alert("There was a problem with your request!\n\nPlease fill out the form completely and try again or call 1-800-521-9616 to speak with a representative.\n\n");
            break;
    }
}

function validateEmailForm(nType,id)
{
    switch(nType)
    {
        case 1: /* text, textarea */
			if(returnObj("validator-"+id))
			{
				if(returnObj(id).obj.value.search(returnObj("validator-"+id).obj.value)!=-1)
				{ 
					returnObj("validator-"+id+"-msg").style.display="none";
					return true;
				}
				else
				{
					returnObj("validator-"+id+"-msg").style.display="";
					return false;
				}
			}
			else
			{
				return true;
			}
            break;
        case 2: /* dropdown */
			if(returnObj("validator-"+id))
			{
	            if(returnObj(id).obj.options[returnObj(id).obj.selectedIndex].value.search(returnObj("validator-"+id).obj.value)!=-1)
				{
					returnObj("validator-"+id+"-msg").style.display="none";
					return true;
				}
				else
				{
					returnObj("validator-"+id+"-msg").style.display="";
					return false;
				}
			}
			else
			{
				return true;
			}
            break;
        case 3: /* radio */
			/* only validates that something was selected */
			if(returnObj("validator-"+id))
			{
				var rdos = getElementsByAttribute(document.documentElement,"input","name",id);
				for(var x = 0; x < rdos.length; x++)
				{
					if(rdos[x].checked)
					{
						returnObj("validator-"+id+"-msg").style.display="none";
						return true;
					}
				}
				returnObj("validator-"+id+"-msg").style.display="";
				return false;
			}
			else
			{
				return true;
			}
			break;
        case 4: /* checkbox */
			/* only validates that the checkbox is selected */
			
			if(returnObj(id).obj.checked)
			{
				returnObj("validator-"+id+"-msg").style.display="none";
				return true;
			}
			else
			{
				returnObj("validator-"+id+"-msg").style.display="";
				return false;
			}
			break;
    }
    return true;
}

/* END EMAIL FORM FUNCTIONS */


/* BEGIN QUERYSTRING DETECTIION */
function parseQueryString( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return false;
  else
    return results[1];
} 

/* END QUERYSTRING DETECTION */

/* BEGIN ELEMENT FUNCTIONS */
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue)
{
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		/*oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);*/
		oAttribute = oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

document.getElementsByClassName = function(cl)
{
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++)
    {
        var classes = elem[i].className;
        if (myclass.test(classes)){retnode.push(elem[i]);}
    }
    return retnode;
}
/* END ELEMENT FUNCTIONS */

function dontOfferDiscount()
{
    window.onbeforeunload = null;
}