﻿ function SubmitEmailForm()
{
    var btnSubmit = document.getElementsByName("SubmitPageForm")[0];
    var btnSubmitValue = "Send";
    if (btnSubmit != null)
    {
        btnSubmit.disabled = true;
        btnSubmitValue = btnSubmit.value;
        btnSubmit.value = "Sending...";
    }
    var myEmailPageForm = document.getElementById("aspnetForm");
    myEmailPageForm.action =  "/EmailSender_ProcessPage.aspx";
    var validated = validateForm( myEmailPageForm, false, true, true, false, 0);
    if (validated)
    {
        myEmailPageForm.submit();
    }
    else
    {
        if (btnSubmit != null)
        {
            btnSubmit.disabled = false;
            btnSubmit.value = btnSubmitValue;
        }
    }
    
}


function postMailingList(processAction) {
alert(processAction)
    var btnSubmit = document.getElementById("btnMLSignUp");
    var btnSubmitValue = "Send";
    if (btnSubmit != null)
    {
        btnSubmit.disabled = true;
        btnSubmitValue = btnSubmit.value;
        btnSubmit.value = "Sending...";
    }
    var myEmailPageForm = document.getElementById("aspnetForm");
    myEmailPageForm.action =  "/MailingList/" + processAction;
    var validated = validateForm( myEmailPageForm, false, true, true, false, 0);
    if (validated)
    {
        myEmailPageForm.submit();
    }
    else
    {
        if (btnSubmit != null)
        {
            btnSubmit.disabled = false;
            btnSubmit.value = btnSubmitValue;
        }
    }
}

AdvertiseClick = function(targetUrl, AdId, ZoneId)
{
    url = ("/AdTracker.aspx?adid=" + AdId + "&zoneid=" + ZoneId + "&targetURL=" + escape(targetUrl));
    window.open(url);
    
    return void(0);
}


//Scripts for ShareThis control
function getTitle()
{
    var m = document.getElementsByTagName('meta');
    var title = "";
    for(var i in m){
      if(m[i].name == "title"){
        title = m[i].content;
      }
    }
    if(title.length < 1 )
    {
      title=document.title;
    }
    return title;
}
  
var G_PageURL= location.href;
var G_PageTitle = getTitle();

function classSwap(cn, obj)
{
obj.className = cn;
}

function hideShowShareThis(action)
{
    var shareDiv = document.getElementById("ShareThisBox");
    //alert(action)
    if (action=="hide" && typeof(shareDiv)=="object")
    {
    shareDiv.style.visibility = "hidden";
    shareDiv.style.display= "none";
	shareDiv.style.position= "relative";

    }
    else if(action=="show" && typeof(shareDiv)=="object" )
    {
     hideShowShareThis("hide");
  	
      //must set x y values
      var imgObj = document.getElementById("ShareThisImg");
      //var pos = Position.get(imgObj);
	  //alert(pos.top)

	  //var left = pos.left+30;
      //var top = pos.top-200;
		
	   var left =  findPosX(imgObj)+30;
	   var top =  findPosY(imgObj)-200;
	
      //alert(findPosY(imgObj))
      shareDiv.style.top=top + "px";
      shareDiv.style.left=left + "px";
      shareDiv.style.visibility = "visible";
      shareDiv.style.display= "block";
      shareDiv.style.position= "absolute";
      shareDiv.style.zIndex = 10000;

  }

}

  function findPosX(obj)
  {
      var curleft = 0;
      if (obj.offsetParent)
      {
      while (obj.offsetParent)
      {
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
      }
      }
      else if (obj.x)
      curleft += obj.x;
      return curleft;
  }
      
      
  function findPosY(obj)
  {
	var curtop = 0;
      if (obj.offsetParent)
      {
      while (obj.offsetParent)
      {
      curtop += obj.offsetTop
      obj = obj.offsetParent;
      }
      }
      else if (obj.y)
      curtop += obj.y;



			
      return curtop;
  }

  //Special Functions for Jen Womack web site

  function showverse(key, GoToExternal) {
      var verse, title, ref, html = "";
      title = key;
      switch (key) { 
        case "Salvation":
            ref = "Ephesians 2:8";
            verse = "For it is by grace you have been saved, through faith - and this is not from yourselves, it is the gift of God -";
            break;
        case "Grace":
            ref = "2 Cor. 12:9";
            verse = "But he said to me, “My grace is sufficient for you, for my power is made perfect in weakness.” Therefore I will boast all the more gladly about my weaknesses, so that Christ’s power may rest on me. ";
            break;
        case "Create":
            ref = "Psalm 51:10";
            verse = "Create in me a pure heart, O God, and renew a steadfast spirit within me.";
            break;
        case "Know":
            ref = "Psalm 46:10";
            verse = "He says, 'Be still, and know that I am God; I will be exalted among the nations,  I will be exalted in the earth.'";
            break;
        case "Delight":
            ref = "Psalm 37:4";
            verse = "Take delight in the LORD, and he will give you the desires of your heart. ";
            break;
        case "Cry":
            ref = "Psalm 34:15";
            verse = "The eyes of the LORD are on the righteous, and his ears are attentive to their cry; ";
            break;
        case "Hope":
            ref = "Psalm 33:18";
            verse = "But the eyes of the LORD are on those who fear him,  on those whose hope is in his unfailing love, ";
            break;
        case "Trust":
            ref = "Psalm 32:10";
            verse = "Many are the woes of the wicked, but the LORD’s unfailing love surrounds the one who trusts in him. ";
            break;
        case "Faith":
            ref = "Hebrews 11:6";
            verse = "And without faith it is impossible to please God, because anyone who comes to him must believe that he exists and that he rewards those who earnestly seek him. ";
            break;
        case "Savior":
            ref = "Psalm 25:4-5";
            verse = "Show me your ways, LORD, teach me your paths. Guide me in your truth and teach me, for you are God my Savior, and my hope is in you all day long. ";
            break;
        case "Sacrifice":
            ref = "Psalm 51:17";
            verse = "My sacrifice, O God, is[a] a broken spirit; a broken and contrite heart you, God, will not despise. ";
            break;
        case "Strength":
            ref = "Psalm 105:4";
            verse = "Look to the LORD and his strength; seek his face always. ";
            break;
        case "Me":
                ref = "Psalm 139:1";
                verse = "You have searched me, LORD, and you know me.";
                break;
        case "Gold":
                ref = "Proverbs 22:1";
                verse = "A good name is more desirable than great riches; to be esteemed is better than silver or gold. ";
                break;
        case "Treasure":
                ref = "Matthew 6:21";
                verse = "For where your treasure is, there your heart will be also. ";
                break;
        case "Everlasting":
                ref = "Psalm 139:23 ";
                verse = "Search me, God, and know my heart; test me and know my anxious thoughts. ";
                break;
        case "Heart":
                ref = "Proverbs 22:1 ";
                verse = "A good name is more desirable than great riches; to be esteemed is better than silver or gold. ";
                break;
        case "Weakness":
                ref = "Isaiah 40:29-31";
                verse = "He gives strength to the weary and increases the power of the weak. Even youths grow tired and weary, and young men stumble and fall; but those who hope in the LORD  will renew their strength. They will soar on wings like eagles;  they will run and not grow weary, they will walk and not be faint. ";
                break;
        case "Peace":
                ref = "Isaiah 54:10 ";
                verse = "'Though the mountains be shaken and the hills be removed, yet my unfailing love for you will not be shaken nor my covenant of peace be removed,' says the LORD, who has compassion on you.";
                break;
        case "Thoughts":
                ref = "Isaiah 55:8";
                verse = "'For my thoughts are not your thoughts, neither are your ways my ways,' declares the LORD.";
                break;
        case "Friends":
                ref = "Proverbs 22:11";
                verse = "One who loves a pure heart and who speaks with grace will have the king for a friend. ";
                break;
        case "Gift":
                ref = "James 1:17";
                verse = "Every good and perfect gift is from above, coming down from the Father of the heavenly lights, who does not change like shifting shadows.";
                break;
        case "Grace":
                ref = "2 Cor. 12:9 ";
                verse = "But he said to me, “My grace is sufficient for you, for my power is made perfect in weakness.” Therefore I will boast all the more gladly about my weaknesses, so that Christ’s power may rest on me. ";
                break;
        case "Completion":
                ref = "Phil. 1:6-8";
                verse = "being confident of this, that he who began a good work in you will carry it on to completion until the day of Christ Jesus. It is right for me to feel this way about all of you, since I have you in my heart and, whether I am in chains or defending and confirming the gospel, all of you share in God’s grace with me. 8 God can testify how I long for all of you with the affection of Christ Jesus. ";
                break;
        case "Eternity":
                ref = "2 Cor. 4:17-18";
                verse = "For our light and momentary troubles are achieving for us an eternal glory that far outweighs them all. So we fix our eyes not on what is seen, but on what is unseen, since what is seen is temporary, but what is unseen is eternal. ";
                break;
                
      }
      if (GoToExternal)
      {
          var url ="http://www.biblegateway.com/passage/?search=" + ref + "&version=NIV";
          window.open(url, "biblegateway","resizable=1,location=1,status=0,scrollbars=1, width=900,height=600");
      }

      html = "<div class='verseTitle'>" + title + "</div><div class='verse'>" + verse + "</div><div class='verseRef'>" + ref + "</div>";
        $('#scriptureBox').html(html);

      return false;

  }
  
