/*

Copyright (c) 2009 Stefano J. Attardi, http://attardi.org/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/
(function($) {
    function toggleLabel() {
        var input = $(this);
        setTimeout(function() {
            var def = input.attr('title');
            if (!input.val() || (input.val() == def)) {
                input.prev('span').css('visibility', '');
                if (def) {
                    var dummy = $('<label></label>').text(def).css('visibility','hidden').appendTo('body');
                    input.prev('span').css('margin-left', dummy.width() + 3 + 'px');
                    dummy.remove();
                }
            } else {
                input.prev('span').css('visibility', 'hidden');
            }
        }, 0);
    };

    function resetField() {
        var def = $(this).attr('title');
        if (!$(this).val() || ($(this).val() == def)) {
            $(this).val(def);
            $(this).prev('span').css('visibility', '');
        }
    };

    $('input, textarea').live('keydown', toggleLabel);
    $('input, textarea').live('paste', toggleLabel);
    $('select').live('change', toggleLabel);

    $('input, textarea').live('focusin', function() {
        $(this).prev('span').css('color', '#ccc');
    });
    $('input, textarea').live('focusout', function() {
        $(this).prev('span').css('color', '#999');
    });

    $(function() {
        $('input, textarea').each(function() { toggleLabel.call(this); });
    });

})(jQuery);
;
(function($){
  
  
  
  Drupal.behaviors.edit_profile = {
    attach: function(context, settings) {
      
      switch (window.location.hash) {
        case '#General':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
          $('#edit-general').css('display','block');
        break;
        case '#Account':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
          $('#edit-account').css('display','block');
        break;
        case '#School':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
          $('#edit-school').css('display','block');
        break;
        case '#Extracurricular':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
          $('#edit-extra').css('display','block');
        break;
        case '#Teacher%20Spotlight':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
          $('#edit-spotlight').css('display','block');
        break;
        case '#Profile%20Picture':
          $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none'); 
          $('#edit-picture').css('display','block');
        break;
      }
      
      
      $('#block-menu-menu-user-edit .content a', context).click(function() {
        var fieldset = $(this).attr('rel');
        $('.page-user-edit .region-content fieldset.form-wrapper').css('display','none');
        switch (fieldset) {
          case 'Account':
            $('#edit-account').css('display','block');
          break;
          case 'General':
            $('#edit-general').css('display','block');
          break;
          case 'School':
            $('#edit-school').css('display','block');
          break;
          case 'Extracurricular':
            $('#edit-extra').css('display','block');
          break;
          case 'Teacher Spotlight':
            $('#edit-spotlight').css('display','block');
          break;
          case 'Profile Picture':
            $('#edit-picture').css('display','block');
          break;
        }
      });
    }
  };

})(jQuery);;
partnerSchool = function (e) {
    this.stateInput = jQuery(e);
    this.form = jQuery(this.stateInput.get(0).form);
    this.zip = null;
    this.onlineUrl = '/graduate-programs/cohort-masters/not-found/';
    var self = this;
    this.form.bind('submit', function() { self.getState(self.stateInput.val()); return false;});

    this.getState = function(zip) {

        if (!(zip.length == 5 && zip.match(/\d{5}/g))) {
            alert('Wrong ZIP code');
            return false;
        }
        this.zip = zip;
        this.getStateCallback();
    };
    
    this.getStateCallback = function(response) {
            var url = this.onlineUrl;
            for(var i in this.SchoolList) {
                if(this.SchoolList[i].zips) {
                    if(this.SchoolList[i].zips.length > 0) {
                        for(var j in this.SchoolList[i].zips) {
                            if((this.zip >= parseInt(this.SchoolList[i].zips[j][0],10)) && (this.zip <= parseInt(this.SchoolList[i].zips[j][1],10)) ) {
                                url = this.SchoolList[i].url;
                                surl=url;
                                break;
                            }
                        }
                    }
                    else {
                      url = this.SchoolList[i].url;
                    }
                }
            }
            if (url[0] != '/') {
                url = document.location.href + (document.location.href.match(/\/$/) ? '' : '/') +  url;
            }
            
           
            // add new url
            new_url="http://www.teachhub.com/graduate-programs/zip-search/"+surl;
            document.location=new_url;
    };
    
    this.SchoolList = [
        {
            school:'American International College',
            url:'american-international-college/',
            state:'Massachusetts',
            abbr:'MA',
            zips:[{0:1000, 1:2799}, {0:5500, 1:5599}]
        },
        {
            school:'Cabrini College',
            url:'cabrini-college/',
            state:'Pennsylvania',
            abbr:'PA',
            zips:[{0:15000, 1:19699}]
        },
        {
            school:'Concordia University Chicago',
            url:'concordia-university-chicago/',
            state:'Illinois',
            abbr:'IL',
            zips:[{0:60000, 1:62999}]
        },
        {
            school:'Concordia University Irvine',
            url:'concordia-university-irvine/',
            state:'California',
            abbr:'CA',
            zips:[{0:90000, 1:96199}]
        },
        {
            school:'Concordia University Portland',
            url:'not-found/',
            state:'Oregon',
            abbr:'OR',
            zips:[{0:97000, 1:97999}]
        },
        {
            school:'Concordia University St. Paul',
            url:'concordia-university-st-paul/',
            state:'Minnesota',
            abbr:'MN',
            zips:[{0:55000, 1:56799}]
        },
        {
            school:'Concordia University Texas',
            url:'concordia-university-texas/',
            state:'Texas',
            abbr:'TX',
            zips:[{0:73300, 1:73399}, {0:75000,1:76999}, {0:77800, 1:79999}, {0:88500, 1:88599}]
        },
        {
            school:'University of St. Thomas',
            url:'university-of-st-thomas/',
            state:'Texas',
            abbr:'TX',
            zips:[{0:77000, 1:77799}]
        },
        {
            school:'Concordia University Wisconsin',
            url:'concordia-university-wisconsin/',
            state:'Wisconsin',
            abbr:'WI',
            zips:[{0:53000, 1:54999}]
        },
        {
            school:'Madonna University and Concordia University Ann Arbor',
            url:'madonna-university/',
            state:'Michigan',
            abbr:'MI',
            zips:[{0:48000, 1:49999}]
        },
        {
            school:'New England College',
            url:'new-england-college-maine/',
            state:'Maine',
            abbr:'ME',
            zips:[{0:4000, 1:4299}]
        },
        {
            school:'Other/Online',
            url:'not-found/',
            state:'Maine',
            abbr:'ME',
            zips:[{0:3900, 1:3999}, {0:4300, 1:4999}]
        },
        {
            school:'New England College',
            url:'new-england-college-new-hampshire/',
            state:'New Hampshire',
            abbr:'NH',
            zips:[{0:3000, 1:3899}]
        },
        {
            school:'SAIL / OAESA',
            url:'oaesa-programs/',
            state:'Ohio',
            abbr:'OH',
            zips:[{0:22400,1:22499}, {0:32100, 1:32199}, {0:43099, 1:45999}]
        },
        {
            school:'College of Mount St. Joseph',
            url:'not-found/',
            state:'Ohio',
            abbr:'OH',
            zips:[{0:45000,1:45299}]
        },
        {
            school:'Ohio Dominican University',
            url:'not-found/',
            state:'Ohio (Cincinnati)',
            abbr:'OH',
            zips:[{0:44000,1:44199}]
        },
        {
            school:'Barry University',
            url:'barry-university/',
            state:'Florida',
            abbr:'FL',
            zips:[{0:32900,1:33499},{0:33600,1:33799},{0:33900,1:34999}]
        },
        {
            school:'Saint Leo University',
            url:'saint-leo-university/',
            state:'Florida',
            abbr:'FL',
            zips:[{0:32000,1:32699},{0:33500,1:33599},{0:33800,1:33899}]
        },
        {
            school:'Other/Online',
            url:'not-found/',
            state:'Florida',
            abbr:'FL',
            zips:[{0:32700,1:32799},{0:32800,1:32899},{0:34700,1:34799}]
        },
        {
            school:'Concordia University Chicago',
            url:'concordia-university-chicago/',
            state:'Indiana',
            abbr:'IN',
            zips:[{0:46300,1:46399}]
        },
        {
            school:'Other/Online',
            url:'not-found/',
            state:'Indiana',
            abbr:'IN',
            zips:[{0:46000,1:46299}, {0:46400, 1:47999}]
        },
        {
            school:'Concordia University Nebraska',
            url:'concordia-university-nebraska/',
            state:'Nebraska',
            abbr:'NE',
            zips:[{0:68000,1:69399}]
        },
        {
            school:'Regent University',
            url:'regent-university/',
            state:'Virginia',
            abbr:'VA',
            zips:[{0:20100, 1:20199}, {0:20500,1:20599}, {0:22000, 1:24699}]
        },
        {
            school:'Regis University',
            url:'not-found/',
            state:'Colorado',
            abbr:'CO',
            zips:[{0:80000, 1:81699}]
        },
        {
            school:'Saint Joseph College',
            url:'saint-joseph-college/',
            state:'Connecticut',
            abbr:'CT',
            zips:[{0:6000, 1:6999}]
        },
        {
            school:'Concordia University Nebraska',
            url:'concordia-university-nebraska/',
            state:'Nebraska',
            abbr:'NE',
            zips:[{0:68000, 1:69399}]
        },
        {
            school:'Gardner Webb University',
            url:'gardner-webb-university/',
            state:'North Carolina',
            abbr:'NC',
            zips:[{0:27000, 1:28999}]
        },
        {
            school:'Lipscomb University',
            url:'lipscomb-university/',
            state:'Tennessee',
            abbr:'TN',
            zips:[{0:37000, 1:38599}]
        }
    ];
};

