/************************************************************************/
/*                        START CLEAR FORM FIELDS                       */
/************************************************************************/
// Clear default form value script.  If you have set the field's Value so 
// that there is default text in the field, this clears the field when 
// the user clicks in it.
// Add to each <input> tag:  onFocus="clearText(this)"
function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
} 
/************************************************************************/
/*                         END CLEAR FORM FIELDS                        */
/************************************************************************/


/************************************************************************/
/*                      START WIDGET PAGE REDIRECT                      */
/************************************************************************/
function handleWidgetSubmit() {
	// Set hidden fields
	setFieldValue('radioCreditReport', 'credit', 'radioIdentityReport', 'identity', 'saleChoice');
	setFieldValue('radioCreditReport', 'siteid=fb69a48f91', 'radioIdentityReport', 'siteid=d183da80f5', 'customParameters');

	// Clear input fields that have not been filled in
	clearUninitializedInputFields('firstname', 'First Name', 'lastname', 'Last Name', 'zipcode', 'Zip Code');

	// Redirect to LP
	redirectToSalesPage('saleChoice', 'firstname', 'lastname', 'zipcode', 'customParameters', 'creditLPUrl', 'identityLPUrl');
}

function setFieldValue(radioButton1Id, value1, radioButton2Id, value2, storageFieldId) {
	/* First we need to initialize some variables to capture the form's radio buttons */
	var r1 = document.getElementById(radioButton1Id);	// this references the document's form input field by id - the Credit Report radio button
	var r2 = document.getElementById(radioButton2Id);	// this references the document's form input field by id - the Identity Security Report radio button
	var storageField = document.getElementById(storageFieldId); // this references the document's form input field by id - the target field

	/* Now that we have initialized our script, we check which report the user chose */
	/* Choosing the Credit Report */
	if (r1 && r1.checked == true) {
		storageField.value = value1;
	}
	else if (r2 && r2.checked == true) {
		storageField.value = value2;
	}
}

function clearUninitializedInputFields(firstNameFieldId, firstNameFieldInitialValue, lastNameFieldId, lastNameFieldInitialValue, zipCodeFieldId, zipCodeFieldInitialValue) {
	var fnameField = document.getElementById(firstNameFieldId);	// this references the document's form input field for FirstName by id
	clearText(fnameField);
		
	var lnameField = document.getElementById(lastNameFieldId);	// this references the document's form input field for LastName by id
	clearText(lnameField);

	var zcodeField = document.getElementById(zipCodeFieldId);	// this references the document's form input field for ZipCode by id
	clearText(zcodeField);

}

function redirectToSalesPage(saleChoiceFieldId, firstNameFieldId, lastNameFieldId, zipCodeFieldId, customParametersFieldId, creditLPUrlFieldId, identityLPUrlFieldId) {
	/* First we need to initialize some variables to capture the form's fields we want to pass to the next page */
	var saleChoice = document.getElementById(saleChoiceFieldId).value; // this references the document's form input field by id - the Sale Choice hidden field
	var fname = document.getElementById(firstNameFieldId).value;	// this references the document's form input field for FirstName by id
	var lname = document.getElementById(lastNameFieldId).value;	// this references the document's form input field for LastName by id
	var zcode = document.getElementById(zipCodeFieldId).value;	// this references the document's form input field for ZipCode by id
	var cparameters = document.getElementById(customParametersFieldId).value;	// this references the document's form input field for CustomParameters by id

	/* Now that we have initialized our script, we check which report the user chose */
	/* Choosing the Credit Report - we apend the url redirect with the form's input fields, which will populate on the next page */
	var qsParameters = "&firstname="+fname+"&lastname="+lname+"&zipcode="+zcode;
	if (cparameters != "") {
		qsParameters += "&" + cparameters;
	}
	if (saleChoice == "credit") {
		var lpUrl = document.getElementById(creditLPUrlFieldId).value;
		document.location.href = lpUrl + qsParameters;
	}
	/* Choosing the Identity Security Report - we apend the url redirect with the form's input fields, which will populate on the next page */
	else if (saleChoice == "identity") {
		var lpUrl = document.getElementById(identityLPUrlFieldId).value;
		document.location.href = lpUrl + qsParameters;
	}
	/* If neither radio button was selected, we alert the user to make a choice - with a successful validation complete we direct the user to the proper page */
	else {
		alert ("Please Choose One Report")
	}
}
/************************************************************************/
/*                       END WIDGET PAGE REDIRECT                       */
/************************************************************************/


/************************************************************************/
/*                         START PRINT FUNCTION                         */
/************************************************************************/
function printme() { 
	window.print(); 
}
/************************************************************************/
/*                          END PRINT FUNCTION                          */
/************************************************************************/


/************************************************************************/
/*                      START WINDOW CLOSE FUNCTION                     */
/************************************************************************/
function closeme() { 
	window.close(); 
} 
/************************************************************************/
/*                       END WINDOW CLOSE FUNCTION                      */
/************************************************************************/


/************************************************************************/
/*                        START BOOKMARK FUNCTION                       */
/************************************************************************/
function bookmark(url, description) {
	netscape="Non IE user's press CTRL+D/APPLE+D to add a bookmark to PrivacyMatters.com."
	if (navigator.appName=='Microsoft Internet Explorer') {
		window.external.AddFavorite(url, description);
	}
	else if (navigator.appName!='Microsoft Internet Explorer') {
		alert(netscape);
	}
}

// This is a cross browser (Firefox 1.x+, IE4+ and Opera7+) 
// script for allowing the user to easily bookmark the site, 
// by clicking on a link on the page.
// Add this to the href link: javascript:bookmarksite('Bookmark Name/Title','URL');
function bookmarksite(title,url){
	if (window.sidebar) // opens firefox bookmark dialogue
	window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print) { // opens opera bookmark dialogue
		var lvll = document.createElement('a');
		lvll.setAttribute('href',url);
		lvll.setAttribute('title',title);
		lvll.setAttribute('rel','sidebar');
		lvll.click();
	} 
	else if(document.all) // opens ie bookmark dialogue
	window.external.AddFavorite(url, title);
}

/************************************************************************/
/*                         END BOOKMARK FUNCTION                        */
/************************************************************************/


/************************************************************************/
/*                       START QUICK LINK URL JUMP                      */
/************************************************************************/
function MM_jumpMenu(targ,selObj,restore) { //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
/************************************************************************/
/*                        END QUICK LINK URL JUMP                       */
/************************************************************************/


/************************************************************************/
/*                           START VIEW SAMPLE                          */
/************************************************************************/
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
/************************************************************************/
/*                         END QUICK VIEW SAMPLE                        */
/************************************************************************/


/************************************************************************/
/*                    START CALIFORNIA PRIVACY POP-UP                   */ 
/************************************************************************/
function shownewwin(windowURL, windowName, windowFeatures) {
	if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null) {
		var newWindow = window.open(windowURL, windowName, windowFeatures);
		newWindow.focus();
		return;
	}
	else if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {
		/*alert("You are using NS.");*/
		window.open(windowURL, windowName, windowFeatures);
	}
 }
/************************************************************************/
/*                     END CALIFORNIA PRIVACY POP-UP                    */
/************************************************************************/


/************************************************************************/
/*                    START DROP DOWN MENU QUICK JUMP                   */ 
/************************************************************************/
function LinkUp() {
	location.href = document.DropDown.DDlinks.options[document.DropDown.DDlinks.selectedIndex].value;
}
function LinkUp2() {
	location.href = document.DropDown2.DDlinks2.options[document.DropDown2.DDlinks2.selectedIndex].value;
}
function LinkUp3() {
	location.href = document.DropDown3.DDlinks3.options[document.DropDown3.DDlinks3.selectedIndex].value;
}
/************************************************************************/
/*                     END DROP DOWN MENU QUICK JUMP                    */ 
/************************************************************************/

/************************************************************************/
/*              START PRIVACY AND SECURITY PROTECTED POP-UP             */
/************************************************************************/
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) {
	var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 660, h = 300;  
	if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
	if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
	if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
		if (document.all || document.layers || document.getElementById) {
			w = screen.availWidth; h = screen.availHeight;
		}
		if (winAlign.indexOf("center") != -1) {
			topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;
		}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight;
		if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0;
		if (winAlign.indexOf("top") != -1) topPos = 0; 						
		features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;
	}
	if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
	if (window["popupWindow"] == null) window["popupWindow"] = new Array();
	var wp = popupWindow.length;
	popupWindow[wp] = window.open(theURL,winName,features);
	if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
	if (document.all || document.layers || document.getElementById) {
		if (borderless && borderless != "") {
			popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);
		}
		if (alwaysOnTop && alwaysOnTop != "") {
			ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
			popupWindow[wp].document.body.onload = function() {
				window.setInterval("window.focus();", 50);
		};
		}
		if (autoCloseTime && autoCloseTime > 0) {
			popupWindow[wp].document.body.onbeforeunload = function() {
				if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
				window.onbeforeunload = null;
			}  
			autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000);
		}
		window.onbeforeunload = function() {
			for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();
		};
	}   
	document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
/************************************************************************/
/*              END PRIVACY AND SECURITY PROTECTED POP-UP               */
/************************************************************************/


/************************************************************************/
/*              START THE FLASH FIX FOR THE AFFILIATE PAGE              */
/************************************************************************/
function playIndexFlash() { 
document.write('<script language="JavaScript" type="text/javascript">  \n');
document.write('var requiredMajorVersion = 6; \n');
document.write('var requiredMinorVersion = 0; \n');
document.write('var requiredRevision = 0; \n');
document.write('var jsVersion = 1.0; \n');
document.write('</script>  \n');
document.write('<script language="VBScript" type="text/vbscript">  \n');
document.write('Function VBGetSwfVer(i)  \n');
document.write('  on error resume next  \n');
document.write('  Dim swControl, swVersion  \n');
document.write('  swVersion = 0  \n');
document.write('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))  \n');
document.write('  if (IsObject(swControl)) then  \n');
document.write('    swVersion = swControl.GetVariable("$version")  \n');
document.write('  end if  \n');
document.write('  VBGetSwfVer = swVersion  \n');
document.write('End Function  \n');
document.write('</script>  \n');
document.write('<script language="JavaScript1.1" type="text/javascript">  \n');
document.write('var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; \n');
document.write('var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; \n');
document.write('var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; \n');
document.write('jsVersion = 1.1; \n');
document.write('function JSGetSwfVer(i) { \n');
document.write('	if (navigator.plugins != null && navigator.plugins.length > 0) { \n');
document.write('		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { \n');
document.write('			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; \n');
document.write('      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; \n');
document.write('			descArray = flashDescription.split(" "); \n');
document.write('			tempArrayMajor = descArray[2].split("."); \n');
document.write('			versionMajor = tempArrayMajor[0]; \n');
document.write('			versionMinor = tempArrayMajor[1]; \n');
document.write('			if ( descArray[3] != "" ) { \n');
document.write('				tempArrayMinor = descArray[3].split("r"); \n');
document.write('			} \n');
document.write('			else { \n');
document.write('				tempArrayMinor = descArray[4].split("r"); \n');
document.write('			} \n');
document.write('      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; \n');
document.write('            flashVer = versionMajor + "." + versionMinor + "." + versionRevision; \n');
document.write('      	} \n');
document.write('		else { \n');
document.write('			flashVer = -1; \n');
document.write('		} \n');
document.write('	} \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; \n');
document.write('	else { \n');
document.write('		flashVer = -1; \n');
document.write('	} \n');
document.write('	return flashVer; \n');
document.write('}  \n');
document.write('function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)  {  \n');
document.write(' 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);  \n');
document.write('	for (i=25;i>0;i--) {	  \n');
document.write('		if (isIE && isWin && !isOpera) {  \n');
document.write('			versionStr = VBGetSwfVer(i);  \n');
document.write('		}  \n');
document.write('		else {  \n');
document.write('			versionStr = JSGetSwfVer(i);  \n');		
document.write('		}  \n');
document.write('		if (versionStr == -1 ) {   \n');
document.write('			return false;  \n');
document.write('		}  \n');
document.write('		else if (versionStr != 0) {  \n');
document.write('			if(isIE && isWin && !isOpera) {  \n');
document.write('				tempArray         = versionStr.split(" ");  \n');
document.write('				tempString        = tempArray[1];  \n');
document.write('				versionArray      = tempString .split(",");  \n');				
document.write('			}  \n');
document.write('			else {  \n');
document.write('				versionArray      = versionStr.split(".");  \n');
document.write('			}  \n');
document.write('			versionMajor      = versionArray[0];  \n');
document.write('			versionMinor      = versionArray[1];  \n');
document.write('			versionRevision   = versionArray[2];  \n');
document.write('			versionString     = versionMajor + "." + versionRevision;     \n');
document.write('			versionNum        = parseFloat(versionString);  \n');
document.write('			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {  \n');
document.write('				return true;  \n');
document.write('			}  \n');
document.write('			else {  \n');
document.write('				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	  \n');
document.write('			}  \n');
document.write('		}  \n');
document.write('	}	  \n');
document.write('	return (reqVer ? false : 0.0);  \n');
document.write('}  \n');
// -->
document.write('</script>  \n');
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if(hasRightVersion) { 
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="707" height="369" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> \n');
         document.write('<param name="movie" value="offer.swf" /> \n');
         document.write('<param name="menu" value="false" /> \n');
         document.write('<param name="quality" value="high" /> \n');
         document.write('<param name="bgcolor" value="#FFFFFF" />\n');
         document.write('<param name="wmode" value="opaque" />\n');
         document.write('<embed src="offer.swf" wmode="opaque" menu="false" quality="high" bgcolor="#FFFFFF" width="707" height="369" name="offer" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
         document.write('</embed>\n');
        document.write('</object>\n');
	}
	else { 
        document.write('<a href="http://www.macromedia.com/go/getflash/" target="_blank"><img src="flash_holder.jpg" border="0" width="707" height="369" alt="Click here to download the flash player plug-in"></a>\n');
  	}
}
/************************************************************************/
/*               END THE FLASH FIX FOR THE AFFILIATE PAGE               */
/************************************************************************/


/************************************************************************/
/*                     START SHOW HIDE DIV FUNCTION                     */
/************************************************************************/
// Animated Collapsible DIV
var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand, initstate) {
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)) { //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function() {thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function() {animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand) {
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes") { //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction) {
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength) { //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function() {thisobj._slideengine(direction)}, 10)
	}
	else { //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function() {
	if (typeof this.runtimer=="undefined" || this.runtimer==null) { //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==0) { //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function() {
	if (typeof this.runtimer=="undefined" || this.runtimer==null) { //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==this.contentheight) { //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function() {
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Please wait until document has fully loaded then click again")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------

animatedcollapse.curveincrement=function(percent) {
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype) { //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name) { 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value) {
		document.cookie = name+"="+value
}

/************************************************************************/
/*                     START SHOW HIDE DIV FUNCTION                     */
/************************************************************************/
