
addLoadListener(initEvents);
addLoadListener(setFormFieldText);
addLoadListener(setNavButtons);
addLoadListener(setOpenArticle);

var hrefSuffix = (document.location.href.indexOf("html") == -1 ? "do" : "html");

function initEvents() {

  var divCloser = getElementsByClassName("divCloser", "img");
  for (i=0; i<divCloser.length; i++) {
      attachEventListener(divCloser[i], "click", closeParent);
      attachEventListener(divCloser[i], "click", hideMS);
  }
  
  attachEventListener(document.getElementById("showC2"), "click", togglePromoContent);
  attachEventListener(document.getElementById("showC1"), "click", togglePromoContent);
  
  /**attachEventListener(document.getElementById("printPromoSpecial"), "click", printPage);*/
  var promobuttons = getElementsByClassName("printPromoSpecial","a");
  if (promobuttons.length > 0) {
    for (i=0; i<promobuttons.length; i++) {
        attachEventListener(promobuttons[i],"click",printPage);
    }
  }
  
  attachEventListener(document.getElementById("header"), "click", hideMS);
  attachEventListener(document.getElementById("content"), "click", hideMS);
  
  var navbtn = getElementsByClassName("navbtn","a")
  for (i=0; i<navbtn.length; i++) {
      attachEventListener(navbtn[i], "focus", hideMS);
  }
  
  /*var coupTableCell = getElementsByClassName("coupons","td");
  for (i=0; i<coupTableCell.length; i++) {
	  var couponlist = coupTableCell[i].getElementsByTagName("a");
	  for (j=0; j<couponlist.length; j++) {
		  attachEventListener(couponlist[j], "click", popup_offers);
	  }
  }*/


  /**** Ford IT:  REMOVE THIS LISTENER! ****/
  /*
  var forms = document.getElementsByTagName("form");
  for (i=0; i<forms.length; i++) {
      attachEventListener(forms[i], "submit", clearWatermarks);
      if (forms[i].id != "miniMSform") {
        for (j=0; j<forms[i].length; j++) {
            attachEventListener(forms[i].elements[j], "focus", hideMS);
        }
      }
  }*/
  /**** end Ford IT removal ****/

  var articleheaders = getElementsByClassName("articleheader","div");
  if (articleheaders.length > 0) {
    for (i=0; i<articleheaders.length; i++) {
        attachEventListener(articleheaders[i],"click",toggleArticleArea);
    }
  }

//  attachEventListener(document.getElementById("printalloffers"), "click", printAllArticles);

  attachEventListener(document.getElementById("printalloffers"), "click", printAllOffers);
  
  var printbuttons = getElementsByClassName("printoffer","a");
  if (printbuttons.length > 0) {
    for (i=0; i<printbuttons.length; i++) {
        attachEventListener(printbuttons[i],"click",printArticle);
    }
  }

// add listener to print buttons on specials page, work similar to the "print offers" page added 03/03 by Joel Schuster
  var printbuttons = getElementsByClassName("printspecial","a");
  if (printbuttons.length > 0) {
    for (i=0; i<printbuttons.length; i++) {
        attachEventListener(printbuttons[i],"click",printOffer);
    }
  }
  
  var openAll = getElementsByClassName("openAll","a");
  if (openAll.length > 0) {
    for (i=0; i<openAll.length; i++) {
        attachEventListener(openAll[i],"click",openAllArticles);
    }
  }

  var closeAll = getElementsByClassName("closeAll","a");
  if (closeAll.length > 0) {
    for (i=0; i<closeAll.length; i++) {
        attachEventListener(closeAll[i],"click",closeAllArticles);
    }
  }
  
  /**** Swap out Home JPGs with SWFs ****/
  var contentDiv = document.getElementById("content");
  if (contentDiv && cssClass("check",contentDiv,"navhome")) {
          var centerwell = document.getElementById("centerwell");
	  var keyServicesDiv = document.getElementById("keyServices");
	  var leftPromoDiv = document.getElementById("promo_left");
	  var nhraCar = document.getElementById("NHRACar");
      if(DetectFlashVer(8,0,0)) {
          var isPlayed = (getCookie("isPlayed") > 0 ? "true" : "false");
          var swf = AC_FL_RunContent(
            "wmode","transparent",
            "src", "images/centerwell_tires",
            "width", "644",
            "height", "313",
            "quality", "high",
            "bgcolor", "#FFFFFF",
            "type", "application/x-shockwave-flash",
            'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
            "pluginspage", "http://www.adobe.com/go/getflashplayer",
            'FlashVars', 'sAccount=fmcquicklaneprod&isPlayed=' + isPlayed,
	        // Omniture production suite... 'FlashVars', 'sAccount=fmcquicklaneprod'
            "base", "images/"
          );
          centerwell.innerHTML = swf;
		  
		  /*** Swap out 14 Key Services jpg with SWF  ***/
		  var keyServicesDiv = document.getElementById("keyServices");
		  var placeholderImg = getElementsByClassName("placeholder","img",keyServicesDiv)[0];
          var swf = AC_FL_RunContent(
            "wmode","transparent",
            "src", "images/14keyServices",
            "width", "320",
            "height", "313",
            "quality", "high",
            "type", "application/x-shockwave-flash",
            'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
            "pluginspage", "http://www.adobe.com/go/getflashplayer",
            "base", "images/"
          );
          keyServicesDiv.innerHTML = swf;
		  
		  /*** Swap out NHRA bucket jpg with SWF  ***/
          var swf = AC_FL_RunContent(
            "wmode","transparent",
            "src", "images/nhracar",
            "width", "319",
            "height", "111",
            "quality", "high",
            "type", "application/x-shockwave-flash",
            'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
            "pluginspage", "http://www.adobe.com/go/getflashplayer",
            "base", "images/"
          );
          nhraCar.innerHTML = swf;
      } else { //swap in alternate content
          centerwell.innerHTML = "<img class='placeholder' src='images/centerwell.jpg' alt='Life is better in the Quick Lane&#174;.'/>";
          keyServicesDiv.innerHTML = "<img class='placeholder' src='images/14keyServices.jpg' alt='Key services to keep your vehicle performing at its best.'/>";
      }
  }
  
  /*** Swap video into NHRA page ***/
  if (contentDiv && cssClass("check",contentDiv,"navnhra")) {
    var videoContainer = document.getElementById("nhraVideo");
    var placeholderImg = getElementsByClassName("placeholder","img",videoContainer)[0];
    var videoObject = AC_FL_RunContent(
        "wmode","transparent",
        "src", "images/083_nhravideo",
        "width", "285",
        "height", "194",
        "quality", "high",
        "type", "application/x-shockwave-flash",
        'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
        "pluginspage", "http://www.adobe.com/go/getflashplayer",
        'FlashVars', 'sAccount=fmcquicklaneprod',
         "base", "images/"
        // Omniture production suite... 'FlashVars', 'sAccount=fmcquicklaneprod'
    );
    var newContent = document.createElement("div");
    newContent.innerHTML = videoObject;
    videoContainer.insertBefore(newContent,placeholderImg);
    videoContainer.removeChild(placeholderImg);    
  }

  /*** Swap animation into About Us page ***/
  if (contentDiv && cssClass("check",contentDiv,"navabout")) {
    var animationDiv = document.getElementById("animation");
    if(animationDiv) {
      if(DetectFlashVer(8,0,0)) {
            var isPlayed = (getCookie("isPlayed") > 0 ? "true" : "false");
            var swf = AC_FL_RunContent(
              "wmode","transparent",
              "src", "images/centerwell",
              "width", "600",
              "height", "292",
              "quality", "high",
              "bgcolor", "#FFFFFF",
              "type", "application/x-shockwave-flash",
              'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
              "pluginspage", "http://www.adobe.com/go/getflashplayer",
			  'FlashVars', 'sAccount=fmcquicklaneprod&isPlayed=' + isPlayed,
              "base", "images/"
            );
            animationDiv.innerHTML = swf;
        } else { //swap in alternate content
            animationDiv.innerHTML = "<img class='placeholder' src='images/centerwell.jpg' alt='Life is better in the Quick Lane&#174;.'/>";
        }
      }
  }

  /**** Display Maintenance Schedule nav button ****/
  var navmaintsched = document.getElementById("navmaintsched");
  if (navmaintsched) {
      document.getElementById("navmaintsched").style.display = "inline";
      attachEventListener(navmaintsched, "click", showMS);
  }
  /*************************************************/
  
  /****** Add Credit Card banner to array of pages ******/
  var ccBannerPageClasses = new Array("navmaintips","navservices","navspecials"); // list class names of pages on which banner should appear
  var leftcolDiv = getElementsByClassName("leftcol","div");
  if(leftcolDiv) { var subcontentDiv = getElementsByClassName("subcontent","div",leftcolDiv[0]); } // grab left column subcontent
  if(contentDiv && subcontentDiv) {
    var currentPageClass = contentDiv.className; // get classname of current page content div
    var ccBannerDiv = document.createElement("div"); // create wrapper for banner
    ccBannerDiv.className = "noprint";
    ccBannerDiv.setAttribute("id","ccBanner");
    
    var ccBannerApplyLink = document.createElement("a"); // create 'Apply Now' link
    ccBannerApplyLink.setAttribute("href","javascript: geOnlineAppSubmit();");
    ccBannerApplyLink.className = "ccBannerLink";
    ccBannerApplyLink.setAttribute("title","Apply Now for a Quick Lane credit card featuring no payments and no interest for 90 days.");
    ccBannerApplyLink.innerHTML = "Apply Now";
    ccBannerDiv.appendChild(ccBannerApplyLink);

    var ccBannerDetailsLink = document.createElement("a"); // create 'Get Details' link
    ccBannerDetailsLink.setAttribute("href","specials." + hrefSuffix + "#qlcreditcard");
    ccBannerDetailsLink.className = "ccBannerLink";
    ccBannerDetailsLink.setAttribute("title","Get Details on the Quick Lane credit card featuring no payments and no interest for 90 days.");
    ccBannerDetailsLink.innerHTML = "Get Details";
    ccBannerDiv.appendChild(ccBannerDetailsLink);
    
    for (var i = 0; i <= ccBannerPageClasses.length; i++) { // iterate through class names of pages on which we want to see this banner
      if(cssClass("check",contentDiv,ccBannerPageClasses[i])) { // if current page's class name matches any in our array...
        subcontentDiv[0].appendChild(ccBannerDiv); // ...append banner wrapper to left column subcontent
        break; // break so this only happens once and we skip unnecessary loops
      }
    }
  }
  /*************************************************/
  return true;
}


function stopEvent(event) {
  if (typeof event.stopPropagation != "undefined") {
    event.stopPropagation();
  } else {
    event.cancelBubble = true;
  }
  return true;
}


function attachEventListener(target, eventType, fn, capture) {
  if(target) {
      if(!capture) capture="false";
      if (typeof target.addEventListener != "undefined") {
        target.addEventListener(eventType, fn, capture);
      } else if (typeof target.attachEvent != "undefined") {
        target.attachEvent("on" + eventType, fn);
      } else {
        eventType = "on" + eventType;

        if (typeof target[eventType] == "function") {
          var oldListener = target[eventType];
          target[eventType] = function() {
            oldListener();
            return  fn();
          }
        } else {
          target[eventType] = fn;
        }
        
      }
      return true;
   }
}


function addLoadListener(f) {
  if (typeof window.addEventListener != 'undefined') {
    window.addEventListener('load', f, false);
  } else if (typeof document.addEventListener != 'undefined') {
    document.addEventListener('load', f, false);
  } else if (typeof window.attachEvent != 'undefined') {
    window.attachEvent('onload', f);
  } else {
    var oldf = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = f;
    } else {
      window.onload = function() {
        oldf();
        f();
      }
    }
  }
}


function getEventTarget(event) {
    var targetElement = null;
    if (typeof event.target != "undefined") {
        targetElement = event.target;
    } else {
        targetElement = event.srcElement;
    }
    
    while (targetElement.nodeType == 3 && targetElement.parentNode != null) {
        targetElement = targetElement.parentNode;
    }
    return targetElement;
}


function cancelClick(e) {
    if (window.event && window.event.returnValue) {
     window.event.returnValue = false;
    }
    if (e && e.preventDefault) {
     e.preventDefault();
    }
}


function toggleWatermark(event) {
  if (typeof event == "undefined") {
      event = window.event;
  }
  var field = getEventTarget(event);
  if (field.value == null || field.value.length == 0 || field.value == field.title) {
    cssClass("swap", field, "textfield", "watermark");
    if (event.type == "blur") {
        field.value = field.title;
    } else {
        field.value = "";
    }
    stopEvent(event);
  }
  return true;
}


function setFormFieldText() {
    var input = document.getElementsByTagName("input");
    for (var i=0; i<input.length; i++) {
        if ((input[i].type == "text" || input[i].type == "textarea") && input[i].title) {
            attachEventListener(input[i], "focus", toggleWatermark);
            attachEventListener(input[i], "blur", toggleWatermark);
            input[i].blur();
        }
    }
    return true;
}


function clearWatermarks() {
    var textinputs = document.getElementsByTagName("input");
    for (var i=0; i<textinputs.length; i++) {
        if ((textinputs[i].type == "text" || textinputs[i].type == "textarea") && textinputs[i].title) {
            var val = textinputs[i].value;
            if (val == null || val.length == 0 || val == textinputs[i].title) {
                textinputs[i].value = "";
            }
        }
    }
}

function printPage(event)
{
	if (typeof event == "string") {
		var promo = document.getElementById(event);
	} else {
		var promo = getEventTarget(event);
	}

	while (!cssClass("check",promo,"promo_special")) {
		promo = promo.parentNode;
	}

	var promos = getElementsByClassName("promo_special","div");
	if (promos.length > 1) {
		for (i=0; i<promos.length; i++) {
		    var a = promos[i];
			cssClass("add", a, "noprint");
		}
	}
	
	cssClass("remove",promo,"noprint");
	fireDart("print special");
	cancelClick(event);
	window.print();
	return false;
}

function togglePromoContent(event)
{
	var c1 = document.getElementById("content1");
	var c2 = document.getElementById("content2");
	
	if( c1.style.display == "none")
	{
		c1.style.display = "block";
		c2.style.display = "none"
	}
	else
	{
		c1.style.display = "none";
		c2.style.display = "block"
	}
	cancelClick(event);
	stopEvent(event);
	return false;
}

function showMS(event) {
    var div = document.getElementById("miniMSformWrap");
    div.style.display = "inline";
    div.style.zIndex = "100";
    div.focus();
    // Form stays hidden on Production
    document.scheduleForm.style.display = "block";
    // "Find a Quick Lane" drop-down for State ignores z-index in IE
    document.getElementById("findaql_state").style.visibility = "hidden";
    if(typeof event != "undefined") {
    cancelClick(event);
    stopEvent(event);
    return false;
    }
}


function hideMS(event) {
    var div = document.getElementById("miniMSformWrap");
    div.style.display = "none";
    // "Find a Quick Lane" drop-down for State ignores z-index in IE
    document.getElementById("findaql_state").style.visibility = "visible";
}


function getElementsByClassName(classname, tag, node) {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName(tag?tag:"*");
    for(var i=0,j=els.length; i<j; i++) {
        if(re.test(els[i].className)) {
            a.push(els[i]);
        }
    }
    return a;
}


function closeParent(event) {
  if (typeof event == "undefined") {
      event = window.event;
  }
  var child = getEventTarget(event);
  var parent = child.parentNode;
  parent.style.display = "none";
  return true;
}


function cssClass(fn, el, class1, class2) {
  switch (fn) {
    case "swap":
      el.className = !cssClass("check", el, class1) ? el.className.replace(class2, class1) : el.className.replace(class1, class2);
    break;
    case "add":
      if (!cssClass("check", el, class1)) {
        el.className += el.className ? " " + class1 : class1;
      }
    break;
    case "remove":
      var rep = el.className.match(" " + class1) ? " " + class1 : class1;
      el.className = el.className.replace(rep, "");
    break;
    case "check":
      return new RegExp("\\b" + class1 + "\\b").test(el.className);
    break;
  }
}


function visToggle(event) {
  if (typeof event == "undefined") {
      event = window.event;
  }
  var el = getEventTarget(event);
  if (event.type == "mouseover") {
      el.firstChild.style.visibility = "hidden";
  } else {
      el.firstChild.style.visibility = "visible";
  }
  stopEvent(event);
  return true;
}


function setNavButtons() {
    if (document.getElementById("content")) {
        var contentClass = document.getElementById("content").className.split(" ");
        var navbtn = getElementsByClassName("navbtn","a");
        for (i=0; i<navbtn.length; i++) {
            if (contentClass.inArray(navbtn[i].id)) {
                cssClass("add", navbtn[i], "current");
            }
        }
    }
}


/*function popup_offers(event) {
	var articleid = getEventTarget(event).id;
	var qlpaCode = getEventTarget(event);
	while (!cssClass("check",qlpaCode,"data")) {
		qlpaCode = qlpaCode.parentNode;
	}
	if (qlpaCode.id) {
		qlpaCode = qlpaCode.id;
		var qlpaCode_qs = "&paCode=" + qlpaCode;
	} else {
		var qlpaCode_qs = "";
	}
	var offersWin = window.open("qloffers_popup." + hrefSuffix + "?articleid=" + articleid + qlpaCode_qs, "qloffers_popup", "width=550, height=600, scrollbars=yes, menubar=yes, resizable=yes");
	offersWin.focus();
	cancelClick(event);
    return false;
}*/


function popup_offers(pacode, offerid, offertype, querystr, pn, channel, hier, prop1, prop5) {
	var s=s_gi(s_account); 
	
	if( channel=='specials' || channel=='locate' ){
		s.linkTrackVars='eVar1,eVar2,eVar4,eVar14,eVar15,prop1,prop2,prop5,prop14,prop15,channel,hier1';
		s.eVar2=pacode;s.prop2=pacode;
	}
	else{
		s.linkTrackVars='eVar1,eVar4,eVar14,eVar15,prop1,prop5,prop14,prop15,channel,hier1';
	}	
	s.eVar1=prop1;s.eVar4='eng';s.eVar14='fcsd';s.eVar15='quicklane.com';
	s.prop1=prop1; s.prop5=prop5;  s.prop14='fcsd'; s.prop15='quicklane.com';
	s.tl(this,'o','local map');
	s.pageName=pn;
	s.channel=channel;
	s.hier1=hier;
	var url= "offer.do?dlrpacode="+pacode +"&offer=" + offerid + "&offertype=" + offertype + querystr;
    var offersWin = window.open(url,"qloffers_popup","width=550, height=600, scrollbars=yes");
    offersWin.focus();
}


function popup_localMap(url,channel, hier, prop5, pacode) {
	var s=s_gi(s_account); 
	s.pageName='qln: locate: map'; 
	
	if( channel=='specials' || channel=='locate' ){
		s.linkTrackVars='eVar2,eVar4,eVar14,eVar15,prop2,prop5,prop14,prop15,channel,hier1';
		s.eVar2=pacode;s.prop2=pacode;
	}
	else{
		s.linkTrackVars='eVar4,eVar14,eVar15,prop5,prop14,prop15,channel,hier1';
	}	
	
	s.eVar4='eng'; s.eVar14='fcsd'; s.eVar15='quicklane.com';
	s.prop14='fcsd'; s.prop15='quicklane.com';
	s.prop5=prop5;
	s.channel=channel;
	s.hier1=hier;
	s.tl(this,'o','local map');
    var localmapWin = window.open(url,"localMap_popup","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=yes,height=550,width=650,left=100,top=100");
   	localmapWin.focus();
}


Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
}


// parses the location.href into an object of name value pairs
function getQueryString()
{
    var o = new Object();

    var s = location.search;
    if (s.length <= 1)
        return o;

    s = s.substring(1);

    var parts = s.split('&');
    for (var i=0; i<parts.length; i++)
    {
        var parts2 = parts[i].split('=');
        o[parts2[0]] = parts2.length == 2 ? parts2[1] : null;
    }

    return o;
}


function setOpenArticle() {
	closeAllArticles();
	if(document.forms[0] != null) {
		if(document.forms[0].name == "offersform") {
		if(document.offersform.articleid.value > "")
			toggleArticleArea(document.offersform.articleid.value);
		}
	}
	/*qs = getQueryString();
	if(qs) {
		if (qs.articleid.value <> "") {
			toggleArticleArea(qs.articleid);
		}
	}*/
}


function setPageTitle() {
    var pagetitle = getElementsByClassName("pagetitle","span");
    if (pagetitle.length > 0 && pagetitle[0] != "undefined" && pagetitle[0].innerHTML.length > 0) {
        document.title = pagetitle[0].innerHTML;
    }
}


// Pass an offerid or articleid, or event will bubble up to find one
function toggleArticleArea(event) {
	if (typeof event == "string") {
		if (document.getElementById(event)) {
			var article = document.getElementById(event); } else { return; }
	} else {
		var article = getEventTarget(event);
	}
	while (!cssClass("check",article,"article")) {
		article = article.parentNode;
	}
	cssClass("swap",article,"closed","open");
	toggleLinkText(article);
	cancelClick(event);
	return false;
}



function printAllArticles() {
	var articles = getElementsByClassName("article","div");
	var toggled = new Array;
	var c = 0;
	if (articles.length > 0) {
		for (i=0; i<articles.length; i++) {
			cssClass("remove", articles[i], "noprint");
			if (!cssClass("check",articles[i],"open")) {
				cssClass("swap",articles[i],"open","closed");
				toggleLinkText(articles[i]);
				toggled[c] = articles[i];
				c++;
			}
		}
	}
	fireDart("print special");
	cancelClick(event);
	window.print();
	return false;
}


// Pass an offerid or articleid, or event will bubble up to find one
function printArticle(event) {
	if (typeof event == "string") {
		var article = document.getElementById(event);
	} else {
		var article = getEventTarget(event);
	}

	while (!cssClass("check",article,"article")) {
		article = article.parentNode;
	}
	cssClass("remove",article,"noprint");

	var id = getElementsByClassName("articlecontent","div",article)[0].id;

	var articles = getElementsByClassName("articlecontent","div");
	if (articles.length > 1) {
		for (i=0; i<articles.length; i++) {
			if (articles[i].id != id) {
				var a = articles[i];
				while (!cssClass("check",a,"article")) {
					a = a.parentNode;
				}
				cssClass("add", a, "noprint");
			}
		}
	}
	fireDart("print special");
	cancelClick(event);
	window.print();
	return false;
}

function printAllOffers(event) {
    openAllArticles();
	var articles = getElementsByClassName("specials","div");
	if (articles.length > 0) {
		for (i=0; i<articles.length; i++) {
			cssClass("remove", articles[i], "noprint");
		}
	}
	fireDart("print special");
	cancelClick(event);
	window.print();
	return false;
}

function printOffer(event) {
	if (typeof event == "string") {
		var offer = document.getElementById(event);
	} else {
		var offer = getEventTarget(event);
	}

	while (!cssClass("check",offer,"specials")) {
		offer = offer.parentNode;
	}

	var offers = getElementsByClassName("specials","div");
	if (offers.length > 1) {
		for (i=0; i<offers.length; i++) {
		    var a = offers[i];
			cssClass("add", a, "noprint");
		}
	}
	
	cssClass("remove",offer,"noprint");
	fireDart("print special");
	cancelClick(event);
	window.print();
	return false;
}

function closeAllArticles() {
	var articles = getElementsByClassName("articlecontent","div");
	if (articles.length > 0) {
		for (i=0; i<articles.length; i++) {
			while (!cssClass("check",articles[i],"article")) {
				articles[i] = articles[i].parentNode;
			}
			if (!cssClass("check",articles[i],"closed")) {
				cssClass("swap",articles[i],"open","closed");
				toggleLinkText(articles[i]);
			}
		}
	}
	return false;
}


function openAllArticles() {
	var articles = getElementsByClassName("articlecontent","div");
	if (articles.length > 0) {
		for (i=0; i<articles.length; i++) {
			while (!cssClass("check",articles[i],"article")) {
				articles[i] = articles[i].parentNode;
			}
			if (!cssClass("check",articles[i],"open")) {
				cssClass("swap",articles[i],"open","closed");
				toggleLinkText(articles[i]);
			}
		}
	}
	return false;
}
function toggleLinkText(article,text1,text2) {
    var t1 = text1 ? text1 : "View Details";
    var t2 = text2 ? text2 : "Hide Details";
    var link = (article.getElementsByTagName("a").length > 0) ? article.getElementsByTagName("a")[0] : null;
	if(link) {
	    link.innerHTML = cssClass("check", article, "closed") ? t1 : t2;
	    return true;
	}
	return false;
}


// List out an object's properties
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}


// Dynamically fire DARTs
function fireDart(desc) {
    var url = "";
    switch (desc) {
        case "print special":
            url = "http://fls.doubleclick.net/activityi;src=690341;type=quick999;cat=quick392;ord=1;num=";
            break;
        default:
            return false;
    }
    var axel = Math.random()+"";
    var a = axel * 10000000000000;
    var dart = document.createElement("iframe");
    dart.id = a;
    dart.setAttribute("width",1);
    dart.setAttribute("height",1);
    dart.setAttribute("frameborder",0);
    dart.setAttribute("src",url + a + "?");
    dart.className = "dart"; 
    document.body.appendChild(dart); 
    setTimeout("document.body.removeChild(document.getElementById('"+a+"'))",1000);
}

function geOnlineAppSubmit() { 
	omnitureEventForCC('referral: quicklane credit card','referral: quicklane credit card');
    document.frmApplicationTermsCond.submit(); 
} 

function omnitureEventForCC(var6,prop5) {
		var s=s_gi(s_account);
		s.pageName='referral: exit';
		s.linkTrackVars='eVar1,eVar4,eVar6,eVar14,eVar15,prop1,prop4,prop5,prop14,prop15,channel,hier1,events';
		s.linkTrackEvents='event4';
		s.eVar1='Quick Lane Credit Card';
		s.prop1='Quick Lane Credit Card';
		s.eVar4='eng'; s.eVar6=var6;s.eVar14='fcsd'; s.eVar15='quicklane.com';
		s.prop4='eng';s.prop5=prop5;
		s.prop14='fcsd'; s.prop15='quicklane.com';
		s.channel='home';
		s.hier1='home';
		s.events='event4';
		s.tl(this,'o', 'referral: exit');
}

function printOffer_Omniture(pageName, prop, titleName, prop1, channel, hier1) {
	var s=s_gi(s_account);
	s.pageName=pageName;
	s.linkTrackVars='eVar1,eVar4,eVar14,eVar15,prop1,prop4,prop5,prop14,prop15,channel,hier1';
	s.eVar1=prop1; s.eVar4='eng'; s.eVar14='fcsd'; s.eVar15='quicklane.com';
	s.prop1=prop1; s.prop4='eng';s.prop5=prop; s.prop14='fcsd'; s.prop15='quicklane.com';
	s.channel=channel;
	s.hier1=hier1;
	s.tl(this,'o', 'Current Specials');
}

function setCookie(cName,cValue,expireDays) {
	if(expireDays) {
		var exDate = new Date();
		exDate.setDate(exDate.getDate()+expireDays);
	}
	document.cookie = cName + "=" + escape(cValue) + (expireDays ? ";expires=" + exDate.toGMTString() : "");
}

function getCookie(cName) {
	if (document.cookie && document.cookie.length>0) {
		cStart = document.cookie.indexOf(cName + "=");
		if (cStart != -1) {
			cStart += (cName.length + 1);
			cEnd = document.cookie.indexOf(";",cStart);
			if (cEnd == -1) cEnd = document.cookie.length;
			return unescape(document.cookie.substring(cStart,cEnd));
		}
	}
	return "";
}

// This is fired from Flash when the homepage centerwell plays 80%
function checkIfPlayed() {
	setCookie("isPlayed","1");
}
