var ShowMeLater = "";
function AskMeLater() {
    ShowMeLater = true;
}
function runSurvey() {
	$('#popSurvey').modal({
	    zIndex: 999,
		opacity: 70,
		overlayId: 'overlay',
		containerId: 'surveyContainer',
		closeHTML: '<a class="closeSurvey" title="No Thanks"></a>',
		onOpen: function (dialog) {
  			dialog.overlay.fadeIn('normal', function () {
    			dialog.container.slideDown('normal', function () {
      				dialog.data.fadeIn('normal');
    			});
  			});
		},
		onClose: function (dialog) {
  			dialog.data.fadeOut('normal', function () {
    			dialog.container.slideUp('normal', function () {
      				dialog.overlay.fadeOut('normal', function () {
        				$.modal.close(); // must call this!
      				});
    			});
  			});
		}
	});
}
function runEnews() {
	$('#popEnews').modal({
	    zIndex: 999,
		opacity: 70,
		overlayId: 'overlay',
		containerId: 'enewsContainer',
		closeHTML: '<a class="closeEnews" title="Close"></a>',
		onOpen: function (dialog) {
  			dialog.overlay.fadeIn('normal', function () {
    			dialog.container.slideDown('normal', function () {
      				dialog.data.fadeIn('normal');
    			});
  			});
		},
		onClose: function (dialog) {
  			dialog.data.fadeOut('normal', function () {
    			dialog.container.slideUp('normal', function () {
      				dialog.overlay.fadeOut('normal', function () {
        				$.modal.close(); // must call this!
      				});
    			});
  			});
		}
	});
}
function runCutTheCord() {
    $('#CutTheCordModal').modal({
        zIndex: 999,
        opacity: 70,
        overlayId: 'overlay',
        containerId: 'CutTheCordModalContainer',
        //closeHTML: '',
        onOpen: function (dialog) {
            dialog.overlay.fadeIn('normal', function () {
                dialog.container.slideDown('normal', function () {
                    dialog.data.fadeIn('normal');
                });
            });
        },
        onClose: function (dialog) {
            dialog.data.fadeOut('normal', function () {
                dialog.container.slideUp('normal', function () {
                    dialog.overlay.fadeOut('normal', function () {
                        $.modal.close(); // must call this!
                    });
                });
            });
        }
    });
}
function runOnlineClaims() {
	$('#popOnlineClaims').modal({
	    zIndex: 999,
		opacity: 70,
		overlayId: 'overlay',
		containerId: 'OnlineClaimsContainer',
		//closeHTML: '',
		onOpen: function (dialog) {
  			dialog.overlay.fadeIn('normal', function () {
    			dialog.container.slideDown('normal', function () {
      				dialog.data.fadeIn('normal');
    			});
  			});
		},
		onClose: function (dialog) {
  			dialog.data.fadeOut('normal', function () {
    			dialog.container.slideUp('normal', function () {
      				dialog.overlay.fadeOut('normal', function () {
        				$.modal.close(); // must call this!
      				});
    			});
  			});
		}
	});
}
function runRefAuth() {
	$('#popRefAuth').modal({
	    zIndex: 999,
		opacity: 70,
		overlayId: 'overlay',
		containerId: 'ClaimsContainer',
		//closeHTML: '',
		onOpen: function (dialog) {
  			dialog.overlay.fadeIn('normal', function () {
    			dialog.container.slideDown('normal', function () {
      				dialog.data.fadeIn('normal');
    			});
  			});
		},
		onClose: function (dialog) {
  			dialog.data.fadeOut('normal', function () {
    			dialog.container.slideUp('normal', function () {
      				dialog.overlay.fadeOut('normal', function () {
        				$.modal.close(); // must call this!
      				});
    			});
  			});
		}
	});
}
function runWiniPad() {
	$('#popwiniPad').modal({
	    zIndex: 999,
		opacity: 70,
		overlayId: 'overlay',
		containerId: 'WiniPadContainer',
		//closeHTML: '',
		onOpen: function (dialog) {
  			dialog.overlay.fadeIn('normal', function () {
    			dialog.container.slideDown('normal', function () {
      				dialog.data.fadeIn('normal');
    			});
  			});
		},
		onClose: function (dialog) {
  			dialog.data.fadeOut('normal', function () {
    			dialog.container.slideUp('normal', function () {
      				dialog.overlay.fadeOut('normal', function () {
        				$.modal.close(); // must call this!
      				});
    			});
  			});
		}
	});
}
function runWiniPad2() {
    $('#popiPad').modal({
        zIndex: 999,
        opacity: 70,
        overlayId: 'overlay',
        containerId: 'iPadContainer',
        //closeHTML: '',
        onOpen: function (dialog) {
            dialog.overlay.fadeIn('normal', function () {
                dialog.container.slideDown('normal', function () {
                    dialog.data.fadeIn('normal');
                });
            });
        },
        onClose: function (dialog) {
            dialog.data.fadeOut('normal', function () {
                dialog.container.slideUp('normal', function () {
                    dialog.overlay.fadeOut('normal', function () {
                        $.modal.close(); // must call this!
                    });
                });
            });
        }
    });
}
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 = "";
	
	var domainName = document.domain.substring(document.domain.indexOf('.',0));
	if(domainName == ".triwps.com" || domainName == ".triwest.com")
	{
	
		document.cookie = name+"="+value+expires+"; path=/; domain=" + domainName;
    }
	else
	{	
	    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 getMetaPortal() {
	var m = document.getElementsByTagName('meta');
	for (var i in m) {
		if (m[i].name == "portal") {
			return m[i].content;
		}
	}
}
function siteSurvey()
{
    var visits = readCookie('seenSurvey');
	if (visits) 
	{
		var cookieDate = new Date(readCookie('dateSurvey'));
		var currentDate = new Date();
		var difference = currentDate.getTime() - cookieDate.getTime();
		var twoMinutes = 120000;
		var oneDay = 86400000;
		var currentSeconds = new Date().getSeconds();
		switch(visits) 
		{
		    case "0":
			    if (difference >= twoMinutes) 
			    {
			        if(currentSeconds >= 1 && currentSeconds < 16)
			        {
		                switch(getMetaPortal()) 
		                {
		                    case "BU":
			                createCookie('seenSurvey','1',180);
		                    break;

		                    case "BS":
			                    createCookie('seenSurvey','1',180);
		                    break;

		                    case "PU":
			                    createCookie('seenSurvey','1',180);
		                    break;

		                    case "PS":
			                    createCookie('seenSurvey','1',180);
		                    break;

		                    case "CU":
			                    createCookie('seenSurvey','1',180);
		                    break;

   		                    case "CS":
			                    createCookie('seenSurvey','1',180);
		                    break;

		                    default:
			                    createCookie('seenSurvey','1',180);
		                    break;
		                }
				        setTimeout("runSurvey()", 500);
				        }
				        else
				        {
				            createCookie('seenSurvey','1',180);
				        }
			    }
			break;
		}
	}
	else 
	{
		createCookie('seenSurvey','0',180);
		createCookie('dateSurvey',Date(),180);
	}
}
function ProviderModal() {
    var visits = readCookie('seenCutTheCordCampaign');
	//var visits = readCookie('seenRefAuth');
	/*if (visits) 
	{*/
    var cookieDate = new Date(readCookie('dateCutTheCordCampaign'));
	//var cookieDate = new Date(readCookie('dateRefAuth'));
		switch(visits) 
		{
		    case null:
		        switch (getMetaPortal()) {
		            case "PU":
		                
		                if (ShowMeLater == true) {
		                    createCookie('seenCutTheCordCampaign', '1', 1);
		                    createCookie('dateCutTheCordCampaign', Date(), 1);
		                }
		                else {
		                    createCookie('seenCutTheCordCampaign', '1', 20);
		                    createCookie('dateCutTheCordCampaign', Date(), 20);
		                    
		                }
		                //		                createCookie('seenRefAuth', '1', 14);
		                //			        setTimeout("runRefAuth()", 500);
		                break;

		            case "PS":
		                createCookie('seenCutTheCordCampaign', '1', 20);
		                setTimeout("runCutTheCord()", 500);
		                //    		            createCookie('seenRefAuth', '1', 14);
		                //			        setTimeout("runRefAuth()", 500);
		                break;

		            default:
		                break;
		        }
		       // createCookie('dateCutTheCord', Date(), 15);
		        //createCookie('dateRefAuth', Date(), 14);
		        break;
		}
	/*}
	else {
		createCookie('seen','0',30);
		createCookie('date',Date(),90);
	}*/
}
function cookieModal() {

    //if (getMetaPortal() == "PU" && readCookie('seenCutTheCordCampaign') == null) {
       // setTimeout("runCutTheCord()", 500);
        //ProviderModal();
    //}
   // else {
        siteSurvey();
    //}
}
//function cookieModal() {
//	var visits = readCookie('seenRefAuth');
//	/*if (visits) 
//	{*/
//		var cookieDate = new Date(readCookie('date'));
//		switch(visits) 
//		{
//		    case null:
//		        switch(getMetaPortal()) 
//		        {
//		            case "PU":
//			        createCookie('seenRefAuth','1',14);
//			        setTimeout('runRefAuth()', 500);
//		            break;

//    		        case "PS":
//			        createCookie('seenRefAuth','1',14);
//			        setTimeout('runRefAuth()', 500);
//	    	        break;

//		            default:
//		            break;
//		        }
//				
//			break;
//		}
//	/*}
//	else {
//		createCookie('seen','0',30);
//		createCookie('date',Date(),90);
//	}*/
//}
function modalContent() {
var cookieDate = new Date(readCookie('date'));
    //document.getElementById('popEnews').innerHTML = '<form id="subscribe" action="frames.aspx" method="get"><div><input name="page" value="http://triwest-qa.triwps.com/unauth/apps/ProviderENewsRegistration/default.aspx?" visible="false" type="hidden" /><input type="text"  onblur="doBackEmail(this)" onfocus="doClearEmail(this)" name="email" class="email" value="Your E-mail Address" /><a class="yes" href="javascript:document.subscribe.submit();" title="Sign Up" onclick="$.modal.close()"><span style="visibility:hidden">Sign Up</span></a></div></form>';
    //document.getElementById('popSurvey').innerHTML = '<a class="yes" href="http://www.questionpro.com/akira/TakeSurvey?id=1177228&custom1=' + getMetaPortal() + '&custom2=' + document.location.href + '&custom3='+ cookieDate +'" title="If you need technical help, please email the Triwest Webmaster at Webmaster@triwest.com." onclick="$.modal.close()" rel="external" target="_blank"><span style="visibility:hidden;">Okay</span></a>';
    //document.getElementById('poptimelyClaims').innerHTML = '<img src="/App_Themes/Default/images/provider/modal/TimelyClaimsModalHeader.jpg" alt="Don&#8217;t Wait! Submit Your TRICARE Claims" /><hr style="color:#c9c28b; height:1px;" /><p>All TRICARE claims must be <a href="/unauth/newsletters/e-news/2010/01_08.aspx" rel="external" target="_blank" title="filed in a timely manner">filed in a timely manner</a>. You can submit your TRICARE claims online and receive faster payments! Simply register for the secure provider portal if you aren&#8217;t registered already.</p><a href="/provider/registration.aspx?&#38;WT.mc_id=PopUp_Prov_Claims_Public_Register" title="Register"><img src="/app_themes/Default/images/provider/modal/registerBtn.png" alt="Register" /></a> <a href="https://secure.triwest.com/triwest/open/frames/sec_frame2.asp?audience=provider?&WT.mc_id=PopUp_Prov_Claims_Public_Login" title="Login"><img src="/app_themes/Default/images/provider/modal/login.png" alt="Login" /></a>';
    
//    if(window.location.search == '')
//    {
//    document.getElementById('poptimelyClaims').innerHTML += ' <a href="?&#38;WT.mc_id=PopUp_Prov_Claims_Public_No" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/app_themes/Default/images/provider/modal/noThanks.png" alt="No Thanks" /></a>';
//    }
//    else
//    {
//        document.getElementById('poptimelyClaims').innerHTML += ' <a href="'+window.location.search + '&#38;WT.mc_id=PopUp_Prov_Claims_Public_No" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/app_themes/Default/images/provider/modal/noThanks.png" alt="No Thanks" /></a>';
//    }

    document.getElementById('popRefAuth').innerHTML = '<img src="/App_Themes/Default/images/provider/modal/submitAuthRefModalHeader.png" alt="Submit Referral/Authorizations Online" /><hr style="color:#c9c28b; height:1px;" /><p>Register for the secure area of www.triwest.com to submit your referral and authorization requests online.  Most requests are processed immediately.  Plus, you will be entered into a weekly drawing for an <a href="/document_library/pdf_docs/WRAPContest.pdf" title="iPod nano&#169;" target="_blank">iPod nano&#169;</a> each time you submit a request with clinical information!</p><a href="/provider/registration.aspx?&#38;WT.mc_id=Popup_Auth_Public_Register" title="Register"><img src="/app_themes/Default/images/provider/modal/registerBtn.png" alt="Register" /></a> <a href="https://secure.triwest.com/triwest/open/frames/sec_frame2.asp?audience=provider?&WT.mc_id=Popup_Auth_Public_Login" title="Login"><img src="/app_themes/Default/images/provider/modal/login.png" alt="Login" /></a>';
    
    if(window.location.search == '')
    {
    document.getElementById('popRefAuth').innerHTML += ' <a href="?&#38;WT.mc_id=Popup_Auth_Public_No" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/app_themes/Default/images/provider/modal/noThanks.png" alt="No Thanks" /></a>';
    }
    else
    {
        document.getElementById('popRefAuth').innerHTML += ' <a href="'+window.location.search + '&#38;WT.mc_id=Popup_Auth_Public_No" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/app_themes/Default/images/provider/modal/noThanks.png" alt="No Thanks" /></a>';
    }
}
function ModalContentiPad() {
    document.getElementById('popwiniPad').innerHTML = '<a href="" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/App_Themes/Default/images/provider/modal/noThanks.jpg" alt="No Thanks" /></a> <a href="/document_library/pdf_docs/iPadContestFlier.pdf" target="_blank" onclick="javascript:$.modal.close();"  title="Okay"><img src="/App_Themes/Default/images/provider/modal/okbutton.jpg" alt="Okay" /></a> <a href="" onclick="javascript:$.modal.close();" title="Ask Me Later"><img src="/App_Themes/Default/images/provider/modal/asklater.jpg" alt="Ask Me Later" /></a>';

}
function ModalContentiPad2() {
    document.getElementById('popiPad').innerHTML = '<a href="" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/App_Themes/Default/images/provider/modal/noThanks.jpg" alt="No Thanks" /></a> <a href="/document_library/pdf_docs/CareAffiliateContestFlyer.pdf" target="_blank" onclick="javascript:$.modal.close();"  title="Okay"><img src="/App_Themes/Default/images/provider/modal/okbutton.jpg" alt="Okay" /></a> <a href="" onclick="javascript:$.modal.close();" title="Ask Me Later"><img src="/App_Themes/Default/images/provider/modal/asklater.jpg" alt="Ask Me Later" /></a>';

}
function ModalContentOnlineClaims() {
    document.getElementById('popOnlineClaims').innerHTML = '<h1>Introducing Online Claims Correspondence and Webmail</h1><ul><li>Submit secure claims <br />inquiries online</li><li>Submit general inquiries about <br />your secure web account</li></ul><a href="/en/provider/claimspayments/claims-submission/online-correspondence/ClaimsCorrespondence-Webmail.pdf?wt.ac=CTC_TW_PopUp1" target="_blank" onclick="javascript:$.modal.close();"  title="Tell Me More Now"><img src="/common/images/backgrounds/TellMeMoreNowButton.jpg" alt="Tell Me More Now" style="padding:0 15px 20px 95px;" /></a><br /><a href="" onclick="javascript:$.modal.close();" title="No Thanks"><img src="/common/images/backgrounds/noThanks_onlineClaims.jpg" alt="No Thanks" /></a>  <a href="" onclick="javascript:$.modal.close();" title="Ask Me Later"><img src="/common/images/backgrounds/TellMeLaterButton.jpg" alt="Tell Me More Now" /></a>';

}
function ModalContentCutTheCord() {
    document.getElementById('CutTheCordModal').innerHTML = '<h1>Cut the Cord!</h1><img src="/en/common/images/modals/CTC-pop-up-1.jpg" alt="Scissors cutting phone wire" /><p>Convenient &#8250; immediate &#8250; faster &#8250; easier</p><div id="CutTheCordModalButtons"><div style="float:left;width:210px;"><p><a href="?wt.ac=CTC_TW_PubPop__AskLater" onclick="javascript:AskMeLater();$.modal.close();ProviderModal();" title="Ask Me Later" class="modal-buttons">Ask Me Later</a> <a href="?wt.ac=CTC_TW_PubPop_NoThanks" onclick="javascript:$.modal.close();ProviderModal();" title="No Thank You" class="modal-buttons">No Thank You</a></p></div><div style="float:right; text-align:center; width:210px;"> <p><a href="/en/provider/registration/?wt.ac=CTC_TW_PubPop_RegisterNow" onclick="javascript:$.modal.close();ProviderModal();" class="register-buttons" title="Register Now!">Register Now!</a></p> <p> <a href="/en/provider/cut-the-cord/?wt.ac=CTC_TW_PubPop_ShowTools" onclick="javascript:$.modal.close();ProviderModal();" class="buttons" title="Show Me Online Tools">Show Me Online Tools</a></p> </div></div>';
}
function ModalContentSurvey()
{
var cookieDate = new Date(readCookie('dateSurvey'));
var iframeURL = "";
if (iframeURL != "")
{ 
      iframeURL = "IFRAME" + iframeURL; } 

  document.getElementById('popSurvey').innerHTML = '<a class="yes" href="https://triwest.qualtrics.com/SE/?SID=SV_4McEaoj4sMMIsjG&Q16_1=' + getMetaPortal() + '&Q16_2=(' + document.location.href + iframeURL + ')&Q16_3=' + cookieDate + '" title="If you need technical help, please email the Triwest Webmaster at Webmaster@triwest.com." onclick="$.modal.close()" target="_blank"><span style="visibility:hidden;">Okay</span></a>';
    }
