
//-------------------------------------
// DEFAULT GLOBALS (DO NOT MODIFY!)
//-------------------------------------

var g_accordTimeout  = 600;
var g_accordActive   = null;
var g_accordCookies  = true;
var g_accordNewComer = null;


//-------------------------------------
// PRELOAD IMAGES
//-------------------------------------

if (document.images) {
	Number(4).times( function(index) { 
		pimg = new Image().src = "/identity-theft/images/ico/soflevel" + (index + 1) + "_off.gif"; });
}


//-------------------------------------
// ACCORDION (SINGLE INSTANCE)
//-------------------------------------

var g_accordTimer = null;
function buildSofAccordion()  { 
	g_accordTimeout = Number(g_accordTimeout);
	var forceH2StyleOverride = true;
    var target = IDG$('js_soffAccordion');
	
	var activeItem = null;
	if (g_accordActive != null) activeItem = $T(target,'LI')[g_accordActive - 1];
	
	if (target == null) throw('ERROR: missing html tag for accordion.');
	

	var liIndex = 0;
	$T(target,'H2').each( function(element) {
			element.onmouseover = function() { if (this.parentNode.state != 'opened') Element.classNames(this).add("hover"); }
			element.onmouseout = function() { Element.classNames(this).remove("hover"); }
	});
	
	$T(target,'LI').each( function(element) {
			element.hiddenID = liIndex;
			liIndex++;
			
			element.lateOnmouseover = function() { //opens current
				
					//crawl all other divs
					$T(this.parentNode,'DIV').each( function(element) {
						if (element.parentNode != this) 
						{
							Element.hide(element);
							var otherTitle = $T(element.parentNode,'H2')[0];
							otherTitle.className = otherTitle.className.replace('_on','_off');
							otherTitle.style.cursor = '';
							element.parentNode.state = 'closed';
						}
					});
					
					//show first sub div
					Element.show($T(this,'DIV')[0]);
					($T(this,'H2')[0]).style.cursor = 'default';

					//change class on h2
					var title = $T(this,'H2')[0];
					title.className = title.className.replace('_off','_on');
					
					//save state
					if (g_accordCookies) simpleCookie.set('activeAccord', this.hiddenID, 60);
					this.state = 'opened';
			}
			
			element.forceClose = function() {
				Element.hide($T(this,'DIV')[0]);
				var title = $T(this,'H2')[0];
				title.className = title.className.replace('_on','_off');
				this.state = 'closed';
			}
			
			element.onclick = function() {
				if (g_accordTimer != null) clearTimeout(g_accordTimer);
				if (this.state == 'opened') {} //element.forceClose()
					else element.lateOnmouseover();
			}
			
			onMouseEnter( element, function() {
					if (g_accordTimer != null) clearTimeout(g_accordTimer);
					g_accordTimer = setTimeout( function(){ element.lateOnmouseover() }, g_accordTimeout );
			});

			if (forceH2StyleOverride)
			{
				$T(element,'H2').each( function(header) { 
						header.onmouseover = function() { this.style.textDecoration = 'underline'; this.style.fontWeight = 'bold'; }
						header.onmouseout = function() { this.style.textDecoration = ''; this.style.fontWeight = ''; }
				});
			}
			
    });
	
	onMouseLeave( target, function() {
			if (g_accordTimer != null) clearTimeout(g_accordTimer);
	});
	
	//set active using global variable
	if ((g_accordActive != null) && (activeItem != null)) activeItem.lateOnmouseover();
	
	//set active using cookie (do not touch the global)
	var cookieState = simpleCookie.get('activeAccord');
	if (cookieState != null)
	{
		activeItem = $T(target,'LI')[Number(cookieState)];
		if (activeItem != null) activeItem.lateOnmouseover();
	} else { //neither global nor cookie... fall back
		$T(target,'LI')[g_accordNewComer].lateOnmouseover();
	}
}


//-------------------------------------
// INJECT FLASH ON MAIN PAGE
//-------------------------------------

function injectMainFlash() {
	
	var name = document.getElementById("ctl00_mainContent_hdNames").value;
		
	var flashToDisplay = g_fileMainFlash + name + ".swf";

    var so = new SWFObject( flashToDisplay, "mainFlash", "586", "255", g_mainFlashVersion, "#ffffff");
	so.addParam("wmode", "transparent");
	so.addParam("salign", "t"); 
	if (!so.write("mainPromoFlash"))
	{
		Element.show($T(IDG$('mainPromoFlash'),'P')[0]);
	}
}

function injectLandingFlash() {

   if ( document.getElementById("grooveFlashContent") )
   {
        var so = new SWFObject("/images/groove/IdentityGuard_799x200.swf", "IdentityGuard_799x200", "799", "200", "8", "#ffffff");
        so.write("grooveFlashContent");
   }
}

//-------------------------------------
// SIMPLE DOM POLLING
//-------------------------------------

/*
var bodyPoll = setInterval( function() {
	if (IDG$('js_soffAccordion') != null) buildSofAccordion();
	if (IDG$('mainPromoFlash') != null) injectMainFlash();
	
	if ($T(document,'BODY')[0]) 
	{ 
		clearInterval(bodyPoll);
		//... 
	}  
} ,100);

*/
function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_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 orderredirect(url)
{
window.location=url + "&" + readCookieaaa("URLParams");
}


function readCookieaaa(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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_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 offerPop(url) 
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=570,height=500,left = 340,top = 150');");
}

