﻿//Bookmark current page
function BookmarkThisPage() {
    var sTitle =  window.document.title;
    var sUrl = window.document.location.href;
    

    if (window.sidebar)			// Mozilla Firefox Bookmark
        window.sidebar.addPanel(sTitle, sUrl, "");
    else if (window.external)	// IE Favorite
        window.external.AddFavorite(sUrl, sTitle);
    else if (navigator.appVersion.indexOf('Mac') != -1)
        alert('Press Apple+D to bookmark this site.');
    else
        alert('Press Control+D to bookmark this site.');
}


// Print current page
function PrintThisPage() {
    if (window.print)
        window.print();
    else
        alert('Select PRINT from the File menu.');
}


/******************Leaving the Site – Off Ramp*************************/
function FollowURL(iLanguage, sURL, bReturn, sWndName, sOptions)
{
	var sPrompt;
	
	switch (iLanguage)
	{
		case 1: // iGlobalEng
			sPrompt = ""
			break;
		case 2: // iThirdPartyEng
			sPrompt = "Leaving the Site \n\n\n You have selected a link that will take you away from www.DiabetesPainHelp.com. \n\n  This Web site is neither owned nor controlled by Pfizer. Pfizer is not responsible for the content or services of this site."
			break;
	}
	
	if (sWndName == null) sWndName = "opener";
	if (sOptions == null) sOptions = "";

	if(! confirm(sPrompt))
		if (bReturn) return false;
		else return;

	var externalWin = window.open(sURL, null, sOptions);
	if (externalWin.opener == null)
		externalWin.opener = window;
	externalWin.opener.name = sWndName;
	if (bReturn) return true;
}
function PrintFriendly()
{
    document.getElementById('leftCol').style.display = "none";
	document.getElementById('bodyBottomSec').style.display = "none";
	document.getElementById('footerSec').style.display = "none";
    window.print();
}

function PrintFriendlyAll()
{
    window.print();
}
/**********************************************************************/

function GoToUrl(urlID) {
   url = null; 
   switch(urlID) {
      case "1" : {
         url = "http://www.theacpa.org/documents/ACPA-FibroLog.pdf";
         break; 
         }
       case "2" : {
         url = "http://www.painfoundation.org/";
         break; 
         }   
       case "3" : {
         url = "http://www.fmnetnews.com/";
         break; 
         }     
       case "4" : {
         url = "http://www.fmaware.org";
         break; 
         }         
       case "5" : {
         url = "http://www.nfra.net";
         break; 
         }  
      case "6" : {
         url = "http://www.nationalpainfoundation.org/";
         break; 
         }     
      case "7" : {
         url = "http://www.healthywomen.org";
         break; 
         }
     case "8" : {
         url = "http://www.rheumatology.org/";
         break; 
         }   
     case "9" : {
         url = "http://familydoctor.org/online/famdocen/home/common/pain/disorders/070.html";
         break; 
         }                
     case "10" : {
         url = "http://www.mayoclinic.com/health/Fibromyalgia/DS00079";
         break; 
         }                         
    case "11" : {
         url = "http://www.webmd.com/Fibromyalgia/default.htm";
         break; 
         }                                  
    case "12" : {
         url = "http://www.nlm.nih.gov/medlineplus/fibromyalgia.html";
         break; 
         }                                           
    case "13" : {
         url = "http://www.niams.nih.gov/Health_Info/Fibromyalgia/";
         break; 
         }                                                    
     case "14" : {
         url = "http://www.rheumatology.org/directory/geo.asp?aud=pat";
         break; 
         }  
      case "15" : {
         url = "http://www.lyrica.com/";
         break; 
         } 
      case "16" : {
         url = "http://www.theacpa.org/";
         break; 
         }
      case "17" : {
         url = "http://www.afsafund.org/";
         break; 
         }
      case "18" : {
         url = "http://www.healthywomen.org/";
         break; 
         }
      case "19" : {
         url = "https://www.fibroknowledge.com/";
         break; 
         }
      case "20" : {
         url = "http://www.HealthyWomen.org";
         break; 
         }
      case "21" : {
         url = "http://www.healthywomen.org/healthcenter/chronic-pain";
         break; 
         }
      }  
   if(url) {
      window.location = url;    
      }
   }
   
   function printdiv(printpage)
    {
    window.print(); 
    }
function callUnsubscribeFormSubmit()
    {
        FormSubmit();
        document.getElementById("unsubscribe_form").submit();
    }
    function SetCheckboxandPhoneOnload()
{
    if(document.getElementById("Q12919|A17604").checked)
    document.getElementById("hdnQ12919|A17604").value = "consent";
    GetPhNumber();
}
function SetUnsubContent() 
{
     
   if (document.getElementById("errorQ10005|A10005").innerHTML.indexOf("Please enter your first name.")!=-1
        || document.getElementById("errorQ10007|A10007").innerHTML.indexOf("Please enter your last name.")!=-1
        || document.getElementById("errorQ10019|A10019").innerHTML.indexOf("Please enter your city.")!=-1
        || document.getElementById("errorQ10020|A10020").innerHTML.indexOf("Please enter your state.")!=-1
        || document.getElementById("errorQ10012|A10012").innerHTML.indexOf("Please enter your phone number.")!=-1
        || document.getElementById("errorQ10015|A10015").innerHTML.indexOf("Please enter a valid e-mail address.")!=-1
        || document.getElementById("errorQ12918|A17603").innerHTML.indexOf("Please limit your story to 3000 characters or less. (Approximately 500 words.)")!=-1
        || document.getElementById("errorQ13533|A19612").innerHTML.indexOf("Please Limit your tip to 250 characters or less.")!=-1
        || document.getElementById("errorQ13533|A19613").innerHTML.indexOf("Please Limit your tip to 250 characters or less.")!=-1
        || document.getElementById("errorQ13533|A19614").innerHTML.indexOf("Please Limit your tip to 250 characters or less.")!=-1
        || document.getElementById("errorQ12919|A17604").innerHTML.indexOf("<DIV id=tempDIV></DIV>")!=-1 
        || document.getElementById("errorQ12919|A17604").innerHTML.indexOf("<div id=tempDIV></div>")!=-1) 
   {
      if(document.getElementById("Q12919|A17604").checked)
        document.getElementById("consentchkbox").style.display="none";
      document.getElementById("livingwithfibro").style.display = "none"; 
      document.getElementById("seektreatment").style.display = "none"; 
      document.getElementById("officiallydiagnosed").style.display = "none"; 
      document.getElementById("privacypolicy").style.display = "none"; 
      document.getElementById("broad").style.display = "none"; 
      document.getElementById("generalmsg").style.display = "none";
      document.getElementById("generalmsg1").style.display = "none";
      document.getElementById("generalmsg2").style.display = "none";
      document.getElementById("generalmsg3").style.display = "none";
      document.getElementById("generalmsg4").style.display = "none";
      document.getElementById("generalmsg5").style.display = "none";
      document.getElementById("generalmsg6").style.display = "none";
       
       // First Name
       if(document.getElementById('errorQ10005|A10005').innerHTML == "Please enter your first name.")
       {
         document.getElementById('firstname').style.display="block";
       }
       else
       {
         document.getElementById('firstname').style.display="none";   
       }
       // Last Name
       if(document.getElementById('errorQ10007|A10007').innerHTML == "Please enter your last name.")
       {
         document.getElementById('lastname').style.display="block";
       }
       else
       {
         document.getElementById('lastname').style.display="none";   
       }
       // City       
       if(document.getElementById('errorQ10019|A10019').innerHTML == "Please enter your city.")
       {
         document.getElementById('city').style.display="block";
       }
       else
       {
         document.getElementById('city').style.display="none";   
       }
       // State       
       if(document.getElementById('errorQ10020|A10020').innerHTML == "Please enter your state.")
       {
         document.getElementById('state').style.display="block";
       }
       else
       {
         document.getElementById('state').style.display="none";   
       }
       // PhoneNumber
       if(document.getElementById('errorQ10012|A10012').innerHTML == "Please enter your phone number.")
       {
         document.getElementById('phone').style.display="block";
       }
       else
       {
         document.getElementById('phone').style.display="none";   
       }
       // Email Address 
       if(document.getElementById('errorQ10015|A10015').innerHTML == "Please enter a valid e-mail address.")
       {
         document.getElementById('email').style.display="block";
       }
       else
       {
         document.getElementById('email').style.display="none";   
       }
       // Share Story
       if(document.getElementById('errorQ12918|A17603').innerHTML == "Please limit your story to 3000 characters or less. (Approximately 500 words.)")
       {
         document.getElementById('sharestory').style.display="block";
       }
       else
       {
         document.getElementById('sharestory').style.display="none";   
       }
       
       //tip1
       if(document.getElementById('errorQ13533|A19612').innerHTML == "Please Limit your tip to 250 characters or less.")
       {
         document.getElementById('tip1').style.display="block";
       }
       else
       {
         document.getElementById('tip1').style.display="none";   
       }
       
       //tip2
       if(document.getElementById('errorQ13533|A19613').innerHTML == "Please Limit your tip to 250 characters or less.")
       {
         document.getElementById('tip2').style.display="block";
       }
       else
       {
         document.getElementById('tip2').style.display="none";   
       }
       
       //tip3
       if(document.getElementById('errorQ13533|A19614').innerHTML == "Please Limit your tip to 250 characters or less.")
       {
         document.getElementById('tip3').style.display="block";
       }
       else
       {
         document.getElementById('tip3').style.display="none";   
       }
       
   }
   else
   {
//        if(document.getElementById("Q12919|A17604").checked==true)
//        {
//          document.getElementById("consentchkbox").style.display="none";
//          document.getElementById("livingwithfibro").style.display = "none"; 
//          document.getElementById("seektreatment").style.display = "none"; 
//          document.getElementById("officiallydiagnosed").style.display = "none"; 
//          document.getElementById("privacypolicy").style.display = "none"; 
//          document.getElementById("broad").style.display = "none"; 
//          document.getElementById("generalmsg").style.display = "none";
//          document.getElementById("generalmsg1").style.display = "none";
//          document.getElementById("generalmsg2").style.display = "none";
//          document.getElementById("generalmsg3").style.display = "none";
//          document.getElementById("generalmsg4").style.display = "none";
//          document.getElementById("generalmsg5").style.display = "none";
//          document.getElementById("generalmsg6").style.display = "none"; 
//          document.getElementById("firstname").style.display = "none"; 
//          document.getElementById("lastname").style.display = "none"; 
//          document.getElementById("city").style.display = "none"; 
//          document.getElementById("state").style.display = "none"; 
//        }
   }
  return false; 
}
    
function setCookieRegistration(name, value, expires, path, domain, secure)
{    
        
        document.cookie= name + "=" + escape(value) +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
  
function showhide(layer_ref) 
{
	if (document.getElementById(layer_ref).style.display == 'block') 
	{
		document.getElementById(layer_ref).style.display = 'none';
	}
	else 
	{
		document.getElementById(layer_ref).style.display = 'block';
	}
}

/* Phone Auto Tab*/
	function autoTab(input,e,len,next_field) {

	  var isNN = (navigator.appName.indexOf("Netscape")!=-1);

	  var keyCode = (isNN) ? e.which : e.keyCode; 

	  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	  if(input.value.length >= len && !containsElement(filter,keyCode))
	  {

	  next_field.focus();

	  }

}
			
function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
        found = true;
    else
        index++;
    return found;
}
function hideRow(rowid,display)
{
    var hideElements = document.getElementById(rowid);
    if(hideElements != null)
    hideElements.style.display=display;
}
function SetCheckboxandPhoneOnload()
{
    if(document.getElementById("Q12919|A17604").checked)
    document.getElementById("hdnQ12919|A17604").value = "consent";
    GetPhNumber();
}
function callFormSubmit()
{
     
     FormSubmit();
     
     if(document.getElementById("share_your_story_form")) document.getElementById("share_your_story_form").submit();
     if(document.getElementById("aspnetForm")) document.getElementById("share_your_story_form").submit();
}
		
//check Box Functions


 function getChkBI()
 {
    if(document.getElementById('Q10526|').checked==true)
    {
       document.getElementById('hdnQ10526|').value="BI";
    }
    else
    {
        document.getElementById('hdnQ10526|').value="";
    }
 }
 
 
  function getChkNI()
 {
    if(document.getElementById('Q13571|').checked==true)
    {
       document.getElementById('hdnQ13571|').value="NI";
    }
    else
    {
        document.getElementById('hdnQ13571|').value="";
    }
 }
 
 
function getHiddenValue(objCntrl,objhdn)
{
    objhdn.value = objCntrl.value;
}

function getChkbox(objControl,objHiddenControl)
{


    if(document.getElementById(objControl).checked)
    {
        getHiddenValue(document.getElementById(objControl),document.getElementById(objHiddenControl));
    }
    else
    {
        document.getElementById(objHiddenControl).value = "";
    }
}
  
 
 //Function to Get the checked values of radio button and check box
function getOptionalQuestion(objControl,objHiddenControl)
 {

    getRadioValue(document.getElementById(objControl),document.getElementById(objHiddenControl));
 }
 
 /* Including this function for the Forms  for getting the values of selected answers in to the
 hidden variables*/
    
    function getRadioValue(objCntrl,objhdn)
    {
      objhdn.value = objCntrl.value;
    }
    
    
    //For Phone Number

     function GetPhNumber()
        {
           document.getElementById("Q10012|A10012").value = document.getElementById("txt_hnp_Phone0").value + document.getElementById("txt_hnp_Phone1").value + document.getElementById("txt_hnp_Phone2").value; 
        }
     var SessionValue ="";   

function GetSessionValue(key) {
   try {
      xmlHttp = new XMLHttpRequest(); 
      }
   catch (e) {
      try {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
         }
      catch (e) {
         try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            }
         catch (e) {
            alert("Your browser does not support AJAX!"); 
            return false; 
            }
         }
      }
      
      try {
       url = "GetSessionValue.aspx?key=" + key + "&dummy=" + new Date().getTime(); 
       xmlHttp.open("GET", url, false); 
      // xmlHttp.onreadystatechange = UpdateSessionValue; 
       xmlHttp.send(null); 
          if(xmlHttp.status == 200)
          {
             SessionValue = xmlHttp.responseText; 
          }
         return SessionValue;
      }catch (e){
        //alert('BLAH');
        return false;
      }
   }

