/////// Session Id Functions Begin ////////////////////
function getSessionId(){
	// Get a sessionid, cookie, qs, generate
	var ttsid = "";	// Omniture session id
	// check cookie
	ttsid = getCookie("ttsid");
	if ((ttsid == "") || (ttsid == null)){
		// check url querystring
		var fullPageUrl = window.location.search;
		ttsid = getQueryStringValue(fullPageUrl, "ttsid");
	}
	if ((ttsid == "") || (ttsid == null)){
		// generate sessionid from guid
		ttsid = getGuid(20);
	}
	return ttsid;
}
function storeSessionId(ttsid){
	var expireDays = 220;
	var expireStamp = new Date(new Date().getTime() + expireDays * 24 * 3600 * 1000);
	setCookie("ttsid", ttsid, expireStamp, "/",sessionDomain);
}
function initSessionId(){
	var ttsid = getSessionId();
	storeSessionId(ttsid);
	return ttsid;
}
function getGuid(n){
	var t = new Date().getTime()+""; //milliseconds since 1 January 1970
	n = n - t.length;
	var g = t;
	for(var i = 0; i < n; i++) {
		g += Math.floor(Math.random() * 0xF).toString(0xF) + (i == 8 || i == 12 || i == 16 || i == 20 ? "-" : "");
	}
	return g;
}
/////// Session Id Functions End /////////////////
/////// Session Id Main Start ////////////////////
var sessionDomain=".intuit.com";
var ttsid = initSessionId();
var today = new Date();
var timeString = today.getTime();
var s_prop8 = ttsid;
/////// Session Id Main End ////////////////////

function getQueryStringValue(sourceUrl, key) {
  var u = sourceUrl;
  var parmValue = "";
  u = u.slice(1);
  parms = u.split("&");
  var parmArray = [];
  for ( var i = 0; i < parms.length; i++){
    parmArray.push(parms[i].split("="));
  }
  for (var i=0;i<parmArray.length; i++) {
    if (parmArray[i][0] == key) {
      parmValue = parmArray[i][1];
    }
  }
  return parmValue;
}

// Cookie management
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;	
}
/////////////// ASA launch /////////////////////
var asaWindowRef = null;
function launchASA (){
	var topic = '';
	if (arguments.length>0) {
		topic = arguments[0];
	} else if (typeof(contactTopic) != 'undefined' && contactTopic != null) {
		topic = contactTopic;
	}	
	if (asaWindowRef != null) {
		if (asaWindowRef.closed) {
			asaWindowRef = OpenCenteredWindow('/support/asa/mainpage.jsp?topic=' + topic, 'tina', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes', '600', '525', true)
		}
		asaWindowRef.focus();
	} else {
		asaWindowRef = OpenCenteredWindow('/support/asa/mainpage.jsp?topic=' + topic, 'tina', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes', '600', '525', true)
	}
}
function OpenCenteredWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if (document.winName) { alert('exists'); }
  if(window.screen)if(isCenter)if(isCenter==true){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  return window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}