﻿
function clearText(obj,str)
{
    //var objTmp = document.getElementById(obj.id);
    //alert(objTmp.id);
    
    if(obj.id == 'PasswordField'){
        //document.getElementById(obj.id).type = 'password';
        //alert(obj.id);
    }
    else{
    }
    
    if(obj.value==str){
        obj.value='';
    }
    else{
    }
}
            
function addText(obj,str)
{
    if(obj.value == '')
        obj.value=str;
}

function getUrlParam( name ){  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    if( results == null )    
        return "";  
    else    
        return results[1];
}

function clock()
{
    var today = new Date();
    var hours = today.getHours();
    var minutes = today.getMinutes();
    var seconds = today.getSeconds();
    var time_holder; // holds the time
    // add "AM" or "PM" if the 12-hours format is chosen
    var ampm = ((hours >= 12) ? " PM" : " AM");    
    // convert the hour to 12-hours format
    // javascript returns midnight as 0, but since the time is in the 12-hours format
    // force javascript to return 12
    hours = ((hours == 0) ? "12" : (hours > 12) ? hours - 12 : hours); 
    // add a leading zero if less than 10
    minutes = ((minutes < 10) ? "0" + minutes : minutes); 
    seconds = ((seconds < 10) ? "0" + seconds : seconds);
    time_holder = hours + ":" + minutes + ":" + seconds + ampm;
    document.getElementById('jsClock').innerHTML =  time_holder;
    // keep the clock ticking
    setTimeout("clock()", 1000);
}

function adClick(id, url, loc)
{
    var aURL = loc;
    var aPosition = aURL.indexOf('www');
    
    if(aPosition>0)
    {
        window.open('adClickTracker.aspx&id=' + id + '&url=' + url + '&loc=' + loc);
    }
    else{
        window.location.href = 'adClickTracker.aspx&id=' + id + '&url=' + url + '&loc=advertiser.aspx?id=' + id;
    }
}

function submitQuestion()
{
    var comment=document.getElementById('txtAnswer').value;
    window.location.href='questionoftheday.aspx?action=add&comment=' + comment;
}

function submitChurchSearch()
{
    var search=document.getElementById('ChurchFinder').value;
     if(search=='Enter State, Zip Code, or Name'){
        return false;
    }
    else{
       window.location.href='churchfinder/?searchfor=' + search;
    }
}

function submitAdvanceChurchSearch()
{
    var church=document.getElementById('SearchChurch').value;
    var search=document.getElementById('SearchZip').value;
    var state=document.getElementById('SearchState').value;
     if(church=='Church Name' && search=='Search By Zip Code' && state==''){
        return false;
    }
    else{
        if(church=='Church Name'){
            church='';
        }
        
        if(search=='Search By Zip Code'){
            search='';
        }
        
       window.location.href='Default.aspx?searchfor=' + search + '&church=' + church + '&state=' + state;
    }
}

function submitNewsletterEmail()
{
    var email=document.getElementById('NewsletterEmail').value;
    if(email=='Email Address'){
        return false;
    }
    else{
        window.location.href='gateway.aspx?path=newsletteremail&action=add&email=' + email;
    }
}

function submitLogOn()
{
    var email=document.getElementById('EmailField').value;
    var pwd=document.getElementById('PasswordField').value;
    
    if(email=='Email Address' || pwd=='Password'){
        return false;
    }
    else{
        window.location.href='gateway.aspx?path=logon&email=' + email + '&pwd=' + pwd;
    }
}
