﻿/* jeffs code 1116  revised 1048am*/
function checkgiving(giving)
{
  if (giving.AmountToGive.value == "$"){
    giving.AmountToGive.value = 100;
    return true ;
  }
  // ** END **
}
/* jeffs code 1215  revised 252pm*/
function onLoginHandler()
{
    var elem = null;

    if(tmp) 
    {
        document.getElementById('dialog-inner').style.display = "block"; 
        document.getElementById('dialog-inner2').style.display = "none"; 
        var eventArr = $('#calendar').fullCalendar('clientEvents'); 
        if (eventArr.length >= 9) 
        { 
            cyclelength = 28; 
            periodlength = (eventArr.length / 6) - 5; 
            x=eventArr[0]; 
            y=eventArr[periodlength]; 
            var thisperiod = new Date(x.start); 
            var ovulationdate = new Date(y.start); 
            var nextperiod = new Date(y.start); 
            nextperiod.setDate(ovulationdate.getDate() + 14); 
            cyclelength = nextperiod.getDate() - thisperiod.getDate(); 
            perioddate = $.fullCalendar.formatDate(x.start, 'yyyy-MM-dd'); 
            perioddatealt = $.fullCalendar.formatDate(x.start, 'MM/dd/yyyy'); 
            $("#calendar").fullCalendar('removeEvents'); 
            $("#result_message").load('/hs.xsl/oc_Form.xml', { //ajax call to dynament 
            oc_date: perioddate, 
            oc_cycle_length: cyclelength, 
            oc_period_length: periodlength 
            }); 
        } // end eventArr check
        
        $("#calendar").fullCalendar('refetchEvents'); 
        oc_date = perioddatealt; 
        var playdate = new Date(oc_date); 
        for (i = 1; i <= 5; i++) { 
            playdate.setDate(playdate.getDate() + parseInt(cyclelength)); 
            oc_date = ($.fullCalendar.formatDate(playdate, 'MM/dd/yyyy')); 
            calendarProject(oc_date, periodlength, cyclelength); 
        } 
        $("#oc_calculate").unbind('click'); 
        $("#oc_calculate").click(function(e){ 
        var oc_date = document.getElementById("actualDate").value; 
        var oc_cycle_length = document.getElementById("oc_cycle_length").value; 
        var oc_period_length = document.getElementById("oc_period_length").value; 
        $("#result_message").load('/hs.xsl/oc_Form.xml', { //ajax call to dynament 
        oc_date: oc_date, 
        oc_cycle_length: oc_cycle_length, 
        oc_period_length: oc_period_length 
        }); 
        $("#calendar").fullCalendar('removeEvents'); 
        $("#calendar").fullCalendar('refetchEvents'); 
        oc_date = document.getElementById("oc_date").value; 
        var playdate = new Date(oc_date); 
        for (i = 1; i <= 5; i++) { 
            playdate.setDate(playdate.getDate() + parseInt(oc_cycle_length)); 
            oc_date = ($.fullCalendar.formatDate(playdate, 'MM/dd/yyyy')); 
            calendarProject(oc_date, oc_period_length, oc_cycle_length); 
        } 
        return false; 
        }); 
    }
    if ((elem = document.getElementById('sharesave')) != null)
        elem.innerHTML = '|<span class="action"><a href="javascript:void(0)" onclick="savePage();" style="color:#9c5fb5;margin-right:4px;margin-left:4px">save<\/a><\/span>';
    if ((elem = document.getElementById('switchblog')) != null)
        elem.innerHTML = '<a href="javascript:togglecomments(\'editblog\');" id="greyeditlink">edit<\/a>';
    if ((elem = document.getElementById('sharerate')) != null)
        elem.innerHTML = '|<a href="javascript:togglecomments(\'rateloggedin\')" style="color:#9c5fb5;margin-left:4px">rate<\/a>';    
    if ((elem = document.getElementById('switchchapter')) != null)
        elem.innerHTML = '<a href="javascript:togglecomments(\'editeventlogin\')" id="greyeditlink">edit<\/a>';    var tmp = document.getElementById('calendar');

    // Blog order based on user preferences
    $.ajax({
        url: "/dynaments/rotatingBlogOrder.xml",
        dataType: "json",
        data: {},
        success: function(html,textStatus){
            $("#rotatingBlogOrderTest").html( html[0].text );
        }
    });   

    // Masthead flight based on user interests
    $.ajax({
        url: "/xsl/homePageMasthead.xsl/-/dynaments/HomeModules/homePageMasthead.xml",
        dataType: "html",
        data: {},
        success: function(html,textStatus) {
            $("#slideshow").html( html );
            
            // Rebuild flight based on new banners
            $('#nav').remove();
            
            $('#slideshow').before('<ul id="nav">').cycle({
                fx:     'scrollLeft',
                speed:  'slow',
                timeout: 6000,
                nowrap:  0,
                pager:  '#nav',
                pause: 0
            });
        }
    });
}

function onLogoutHandler()
{   
    var tmp = document.getElementById('calendar');
    if(tmp) 
    {
        document.getElementById('dialog-inner').style.display = "none"; 
        document.getElementById('dialog-inner2').style.display = "block"; 
        $("#calendar").fullCalendar('removeEvents'); 
        $("#oc_calculate").unbind('click'); 
        $("#oc_calculate").click(function(e){ 
        $("#calendar").fullCalendar( 'removeEvents'); 
        var oc_date = document.getElementById("actualDate").value; 
        var oc_cycle_length = document.getElementById("oc_cycle_length").value; 
        var oc_period_length = document.getElementById("oc_period_length").value; 
        oc_date = document.getElementById("oc_date").value; 
        calendarProject(oc_date, oc_period_length, oc_cycle_length); 
        var playdate = new Date(oc_date); 
        for (i = 1; i <= 5; i++) { 
            playdate.setDate(playdate.getDate() + parseInt(oc_cycle_length)); 
            oc_date = ($.fullCalendar.formatDate(playdate, 'MM/dd/yyyy')); 
            calendarProject(oc_date, oc_period_length, oc_cycle_length); 
        } 
        oc_date = document.getElementById("oc_date").value; 
        var f = new Date(oc_date); 
        f.setDate(f.getDate() + ( oc_cycle_length - 17 )); 
        $('#calendar').fullCalendar('gotoDate', f); 
        return false; 
        }); 
    }
    document.getElementById('sharesave').innerHTML = '|<a href="javascript:togglecomments(\'save\')" style="color:#9c5fb5;margin-right:4px;margin-left:4px;">save<\/a>';
    document.getElementById('sharerate').innerHTML = '|<a href="javascript:togglecomments(\'rate\')" style="color:#9c5fb5;margin-left:4px">rate<\/a>';
    document.getElementById('switchblog').innerHTML = '<a href="javascript:togglecomments(\'signin-to-editblog\');" id="greyeditlink">edit<\/a>';   
    document.getElementById('switchchapter').innerHTML = '<a href="javascript:togglecomments(\'editevent\')" id="greyeditlink">edit<\/a>';   
}

/* jeffs code 930  revised 332pm 
Revised by MKlosner 28Nov11:
- Addition of optional second paramter 'showOrHide' to force showing or hiding of element specified in 'postid'. Possible values of this parameter
are 'show' and 'hide'.
- If 'showOrHide' is omitted, then function will toggle element's display.
- Note that this revision leaves function completely backwards compatible with previous version.
END  Revised by MKlosner 28Nov11 */
function togglecomments(postid,showOrHide) {
    if (postid == 'signin')
        document.getElementById('signup').className = 'commenthidden';
    if (postid == 'signin')
        document.getElementById('thankyou').className = 'commenthidden'; 
    if (postid == 'thankyou')
        document.getElementById('signup').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('rateloggedin').className = 'commenthidden';
    if (postid == 'email')
        document.getElementById('share').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('rateloggedin').className = 'commenthidden';
    if (postid == 'emailsent')
        document.getElementById('share').className = 'commenthidden';
    if (postid == 'save')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'save')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'save')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'save')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'save')
        document.getElementById('rateloggedin').className = 'commenthidden';
        if (postid == 'save')
        document.getElementById('share').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('rateloggedin').className = 'commenthidden';
    if (postid == 'saveloggedin')
        document.getElementById('share').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('rateloggedin').className = 'commenthidden';
    if (postid == 'rate')
        document.getElementById('share').className = 'commenthidden'; 
   
    if (postid == 'rateloggedin')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'rateloggedin')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'rateloggedin')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'rateloggedin')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'rateloggedin')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'rateloggedin')
        document.getElementById('share').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('email').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('emailsent').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('save').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('saveloggedin').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('rate').className = 'commenthidden';
    if (postid == 'share')
        document.getElementById('rateloggedin').className = 'commenthidden';
    if (postid == 'signup')
        document.getElementById('signin').className = 'commenthidden';
        
    var whichpost = document.getElementById(postid);
    
    // MKlosner 28Nov11: Allows only one of the following boxes to be displayed at a given time. If another one is displayed, all the rest are hidden.
    var elem;
    if ( (postid === 'editevent' || postid === 'editeventlogin' || postid === 'signin-to-editblog' || postid === 'editblog' || 
          postid === 'signin' || postid === 'signup' || postid === 'mini') &&  whichpost.className=="commenthidden" ) {
        if ( (elem = document.getElementById('editevent')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('editeventlogin')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('signin-to-editblog')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('editblog')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('signin')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('signup')) != null ) elem.className = 'commenthidden';
        if ( (elem = document.getElementById('mini')) != null ) elem.className = 'commenthidden';
    }
    
    if (showOrHide === "show") whichpost.className="commentshown";
    else if (showOrHide === "hide") whichpost.className="commenthidden";
    else {
        if (whichpost.className=="commentshown") { whichpost.className="commenthidden"; } else { whichpost.className="commentshown"; }
    }
}

function getUrl() 
{
    /* ***************************************Do not modify these!***************************************** */
    var sOriginalUrl= document.URL;
    sOriginalUrl= sOriginalUrl.replace(/%3A/g,":");
    sOriginalUrl= sOriginalUrl.replace(/%2F/g,"/");
    sOriginalUrl= sOriginalUrl.replace(/%3F/g,"?");
    sOriginalUrl= sOriginalUrl.replace(/%3D/g,"=");
    sOriginalUrl= sOriginalUrl.replace(/%26/g,"&");
    var aArgs= sOriginalUrl.substring(document.URL.indexOf("?")+1).split("&");
    var validURLs = ["http://careers.peopleclick.com/careerscp", "https://careers.peopleclick.com/careerscp", "http://careerscvv.peopleclick.com/careerscp", "https://careerscvv.peopleclick.com/careerscp", "http://careers.ri1.peopleclick.com/careerscp", "https://careers.ri1.peopleclick.com/careerscp", "http://careers.rqi.peopleclick.com/careerscp", "https://careers.rqi.peopleclick.com/careerscp"];
    var finalParameters= "";
    var finalURL= null;
    /* ***************************************Do not modify these!*****************************************    */
    /* Please set this to the production external site.  All you should need to change for this is the 
       client_clientname, and possibly the site name (external)                        */
    var fallbackURL = "http://careers.peopleclick.com/careerscp/client_marchofdimes/external/search.do";

    /* Task #1:    Loop through the querystring parameters.  If the parameter matches the base URL parameter, 
                we place that in its own string variable as it has to go in front.  The rest we simply
                rewrite into a separate string which will be tacked on to the base URL (if found).    */
    for ( x=0; x<aArgs.length; x++ )
    {
        var argName = aArgs[x].substring(0, aArgs[x].indexOf("="));
            var argValue = aArgs[x].substring(aArgs[x].indexOf("=")+1);
            if ( argName.toUpperCase()=="CPURL" ) 
        {
    /* Here we are going to check to make sure that the passed URL matches one of our matched ones, to
       prevent phishing with the frames page                                */
            for( y=0; y < validURLs.length; y++ )
            {
                if(argValue.toUpperCase().indexOf(validURLs[y].toUpperCase()) == 0)
                {
                    finalURL = argValue;
                }
            }
        }
        else 
        { 
            finalParameters = finalParameters + "&" + argName + "=" + argValue; 
        }
    }

    /* Task #2:    See if we found the proper base URL in the query string.  If not, then someone has hit
       this page manually and we should then go to the base search page                            */
    
    if ( finalURL != null ) 
    {
        finalURL += finalParameters
        } 
    else 
    {
             finalURL = fallbackURL;
        }
    return finalURL;
}
/* jeffs code end */
$(document).ready(function() {
        $('.Items').selectbox();
        
            $("#instructions").show();
    $("#results").hide();
    
    $('.ddcItems2').selectbox({
inputClass: 'selectbox100',
        containerClass: 'selectbox100-wrapper'
});
    $('.ddcItems3').selectbox({
inputClass: 'selectbox200',
        containerClass: 'selectbox200-wrapper'
});
$('.ddcItems4').selectbox({
inputClass: 'selectbox300',
        containerClass: 'selectbox300-wrapper'
});
$('.ddcItems5').selectbox({
inputClass: 'selectbox400',
        containerClass: 'selectbox400-wrapper'
});
    });

    $(document).ready(function() {
        $('.Items2').selectbox({
inputClass: 'selectbox2',
        containerClass: 'selectbox2-wrapper'
});
    });
    
    $(document).ready(function() {
        $('.Items3').selectbox({
        inputClass: 'selectbox3',
        containerClass: 'selectbox3-wrapper'
    });
        });
    $(document).ready(function() {
        $('.Items44')
        .selectbox({
           inputClass: 'selectbox44',
           containerClass: 'selectbox44-wrapper'
        });
    });
    

/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */
document.write('<style type="text/css">.tabber{display:none;}<\/style>');
            //<![CDATA[
function VerifyNoNumbers(sString)
  {
    for (var i = 0; i < sString.length; i++)
    {
      if ((sString.charAt(i) == "0") || (parseFloat(sString.charAt(i))))
      {
        return false;
      }
    }
    return true;
  }
 
function check_numeric_keypress() {
        var numbers = "0123456789";
        numbers += String.fromCharCode(8);
        numbers += String.fromCharCode(13);
        numbers += String.fromCharCode(27);
    
        var key = window.event.keyCode;
        if (numbers.indexOf(String.fromCharCode(key)) == -1) {
            window.event.returnValue = false;
        }
    }
    
        function remove_spaces(str) { return str.replace(/[ ]/g, ''); }
 
        
        function goZip7()
    {
        var f = document.forms.zipcode7
        if ((VerifyOnlyNumbers7(f.z.value))&&(f.z.value.length == 5)){
            return true;
        } else {
            alert('Please enter a valid 5 digit zip code.')
            return false;
        }
    }
 
    function VerifyOnlyNumbers7(sString)
    {
        for (var i = 0; i < sString.length; i++)
        {
            if ((sString.charAt(i) != "0") && (sString.charAt(i) != "-") && !(parseFloat(sString.charAt(i))))
            {
            return false;
            }
        }
        return true;
    }
    
    
        //]]> 
 
$(document).ready(function() {
    // ----- Artists: View Artworks Slideshow -----
    // Start our cycle
    $('#slideshow').before('<ul id="nav">').cycle({
            fx:     'scrollLeft',
            speed:  'slow',
            timeout: 6000,
               nowrap:  0,
        pager:  '#nav',
        pause: 0
    });
    
    // Pause the cycle
    $('#pausebtn').click(function() { 
        $('#slideshow').cycle('pause');
        $(this).hide();
        $('#playbtn').show();
        return false;
    });
    
    // Resume the cycle
    $('#playbtn').click(function() { 
        $('#slideshow').cycle('resume');
        $(this).hide();
        $('#pausebtn').show();
        return false;
    });
    
});//end ready function
 
 $(function() {
    $('#blogposts').before('<ul id="navblog">').cycle({
        fx:     'fade',
        timeout: 0,
        nowrap:  0,
        sync: 0, // in and out transitions are not simultaneous
        speedIn: 1,  // speed of the 'in' transition 
        speedOut: 'medium',  // speed of the 'out' transition 
        pager:  '#navblog',
        pause: 1
    });
});
 
 $(function() {
    $('#mostposts').before('<ul id="navmost">').cycle({
        fx:     'scrollLeft',
        speedIn: 'medium',  // speed of the 'in' transition 
        speedOut: 'medium',  // speed of the 'out' transition 
        delay: 1000,
        timeout: 0,
        nowrap:  0,
        pager:  '#navmost',
 pause: 1
    });
});
 
function togglemini () {
    togglecomments('mini');
}

function userlogin () {
    document.getElementById('gridsignin').style.display = 'none';
    document.getElementById('gridsignedin').style.display = 'block';
    document.getElementById('gridpersonal').style.display = 'none';
    document.getElementById('gridwelcome').style.display = 'block';
    document.getElementById('signup').className = 'commenthidden';
    document.getElementById('signin').className = 'commenthidden';
    document.getElementById('mini').className = 'commentshown';
 
}
function userlogout () {
    document.getElementById('gridsignin').style.display = 'block';
    document.getElementById('gridsignedin').style.display = 'none';
    document.getElementById('gridwelcome').style.display = 'none';
    document.getElementById('gridpersonal').style.display = 'block';
 
    document.getElementById('mini').className = 'commenthidden';
 
}

// CSS Hack (added by MKlosner 5 Dec 11)
function mkl_whichBrowser() {
    var ua, s, i;
    
    this.browser = null;
    this.version = null;
    this.platform = null;
    
    ua = navigator.userAgent;
    // Platform
    if ( ua.indexOf("iPad") >= 0 ) this.platform = "IPAD";
    else if ( ua.indexOf("iPhone") >= 0 ) this.platform = "IPHONE";
    else if ( ua.indexOf("Windows") >= 0 ) this.platform = "WINDOWS";
    else if ( ua.indexOf("Macintosh") >= 0 ) this.platform = "MACINTOSH";
    else if ( ua.indexOf("Linux") >= 0 ) this.platform = "LINUX";
    
    // Browser & version
    s = "Chrome";
    if ((i = ua.indexOf(s)) >= 0) {
      this.browser = "CHROME";
      this.version = parseInt(ua.substr(i + s.length + 1));
      return;
    }
    
    s = "Opera";
    if ((i = ua.indexOf(s)) >= 0) {
      this.browser = "OPERA";
      this.version = parseInt(ua.substr(i + s.length + 1));
      return;
    }
    
    s = "Safari";
    if ((i = ua.indexOf(s)) >= 0) {
      this.browser = "SAFARI";
      i = ua.indexOf("Version") + 8;
      this.version = parseInt(ua.substr(i));
      return;
    }
    
    s = "Firefox";
    if ((i = ua.indexOf(s)) >= 0) {
      this.browser = "FIREFOX";
      this.version = parseInt(ua.substr(i + s.length + 1));
      return;
    }
    
    s = "MSIE";
    if ((i = ua.indexOf(s)) >= 0) {
      this.browser = "MSIE";
      this.version = parseInt(ua.substr(i + s.length));
      return;
    }
}
function mkl_replaceWithBrowser() {
    var agent = new mkl_whichBrowser();
    if (agent.browser != null) $(".replaceWithBrowserName").removeClass("replaceWithBrowserName").addClass(agent.browser);
    if (agent.version != null) $(".replaceWithBrowserVersion").removeClass("replaceWithBrowserVersion").addClass("VERSION" + agent.version);
    if (agent.platform != null) $(".replaceWithBrowserPlatform").removeClass("replaceWithBrowserPlatform").addClass(agent.platform);
}
$(document).ready( function() {mkl_replaceWithBrowser();} );
// END CSS Hack

<!--
    function toggle_visibility(id) {
    
    var f = document.getElementById('selectac');
       var e = document.getElementById(id);
       if(e.style.display == 'block') {
        f.src =  '/images/select_ac_hover.png';
          e.style.display = 'none';
       } else {
          e.style.display = 'block';
      f.src =  '/images/select_ac_over.png';
    }
 
        
 
    }
//-->
<!--
    function restore_image() {
    
    var f = document.getElementById('selectac');
       var e = document.getElementById('navmenu');
       if(e.style.display == 'block') {
          f.src =  '/images/select_ac_over.png';
          //f.src =  '/images/select_ac_over.png';
        
           } else {
          f.src =  '/images/select_ac.png';
          //f.src =  '/images/select_ac.png';

    }
 
        
 
    }
 
 function swap_image() {
    
    var f = document.getElementById('selectac');
       var e = document.getElementById('navmenu');
       if(e.style.display == 'block') {
          f.src =  '/images/select_ac_hover.png';
          //f.src =  '/images/select_ac_hover.png';

        
           } else {
          f.src =  '/images/select_ac_rollover.png';
          //f.src =  '/images/select_ac_rollover.png';

    }
 
        
 
    }
 
 
 
function internalLabelFocus(elm) {
    if (elm.value == elm.defaultValue)
        elm.value = "";
    elm.className = elm.className.replace("internal-label","internal-label-emph");
}
function internalLabelBlur(elm) {
    if (!elm.value)
        elm.value = elm.defaultValue;
    if (elm.value == elm.defaultValue)
        elm.className = elm.className.replace("internal-label-emph","internal-label");
}

function stripHTML(){
    var re = /(<([^>]+)>)/gi;
    for (i=0; i < arguments.length; i++)
    arguments[i].value=arguments[i].value.replace(re, "")
}
//-->
