var jQueryBrowser=function(){var addSelectors=true;var pl=navigator.platform;var ua=navigator.userAgent;var ob={gecko:/Gecko/.test(ua)&&!/like Gecko/.test(ua),webkit:/WebKit/.test(ua),aol:/America Online Browser/.test(ua),camino:/Camino/.test(ua),firefox:/Firefox/.test(ua),flock:/Flock/.test(ua),icab:/iCab/.test(ua),konqueror:/KDE/.test(ua),mozilla:/mozilla/.test(ua),msie:/MSIE/.test(ua),netscape:/Netscape/.test(ua),opera:/Opera/.test(ua),safari:/Safari/.test(ua),browser:/(MSIE|Firefox|Opera|Safari|KDE|iCab|Flock)/.exec(ua)[0],win:/Win/.test(pl),mac:/Mac/.test(pl),linux:/Linux/.test(pl),iphone:/iPhone/.test(pl),OS:/(Win|Mac|Linux|iPhone)/.exec(pl)[0],platform:pl,agent:ua,addSelectors:function(){jQuery(arguments[0]||'html').addClass([this.renderer,this.browser,this.browser+this.version.major,this.OS,'js'].join(' ').toLowerCase());},removeSelectors:function(){jQuery(arguments[0]||'html').removeClass([this.renderer,this.browser,this.browser+this.version.major,this.OS,'js'].join(' ').toLowerCase());}};ob.renderer=(ob.gecko)?'gecko':(ob.webkit)?'webkit':'';ob.version={};ob.version.string=(ob.msie)?/MSIE([^;]+)/.exec(ua)[1]:(ob.firefox)?/Firefox\/(.+)/.exec(ua)[1]:(ob.safari)?/Version\/([^\s]+)/.exec(ua)[1]:(ob.opera)?/Opera\/([^\s]+)/.exec(ua)[1]:'';ob.version.number=parseFloat(ob.version.string);ob.version.major=/([^\.]+)/.exec(ob.version.string)[1];if(addSelectors){ob.addSelectors();}jQuery.browser=ob;}();
$(document).ready( function(){
// Sifr font replacements for various headings
function do_dynamic_sifr(){
if( $.browser.linux == false ){
$('div.header h1').sifr( { path: 'http://www.bsm.ac.th/fonts/', font: 'HeliosCond', color: '#ffffff', fontSize: '18px', roY: -12, verticalAlign: 'top' } );
$('div.content_inner h2').sifr( { path: 'http://www.bsm.ac.th/fonts/', font: 'HeliosCond', color: '#033b76', fontSize: '18px' } );
}
}
do_dynamic_sifr();
// This handles the hover and click for the sidebar menu
// Hover functionality is for IE 6
// Click functionality for all
$('div#sidebar_menu li').hover( function(){
if( !$(this).hasClass('selected') ){$(this).css('background-image',"url('http://www.bsm.ac.th/images/core/sidebar_menu_item_hover.png')");
$(this).css('cursor','pointer');
}else{$(this).css('cursor','pointer');}
}, function(){
if( !$(this).hasClass('selected') ){$(this).css('background-image',"url('http://www.bsm.ac.th/images/core/sidebar_menu_item.png')");}
});
$('div#sidebar_menu li').click( function(){
if( $(this).find('a').attr('href') ){
document.location.href = $(this).find('a').attr('href');
}
});
// Handles clicking tabs at top of content window
//(switches content dynamically using divs existing on page, non-ajax)
$('div.header li a').click(function(){
curr = $('div.content_inner.visible');
curr.removeClass('visible');
curr.addClass('hidden');
$( 'div.'+$(this).attr('class') ).removeClass('hidden');
$( 'div.'+$(this).attr('class') ).addClass('visible');
do_dynamic_sifr();
$('div.header li').removeClass('selected');
$(this).parent('li').addClass('selected');
return false;
});
// Initialise Google Maps
if( $('div#map').length > 0 ){
//Bangkok School of Management";
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
}
marker = createMarker(location, html);
map.addOverlay(marker);
marker.openInfoWindow(html);
// Handles clicking of map buttons
$('a.map_goto_world').click(function(){
move_map(1, $(this));
});
$('a.map_goto_asia').click(function(){
move_map(3, $(this));
});
$('a.map_goto_thailand').click(function(){
move_map(5, $(this));
});
$('a.map_goto_bangkok').click(function(){
move_map(9, $(this));
});
$('a.map_goto_road').click(function(){
move_map(16, $(this));
});
function move_map(zoom, button){
$('div#map_navigation li').removeClass('selected');
button.parent('li').addClass('selected');
map.setCenter(location, zoom);
marker.openInfoWindow(html);
}
}
//]]>
}
// Function to be called before processing form again to clear pervious errors
function clear_errors(form){
form.find('.form_error').remove();
form.find('input[type=text], textarea, select.required').css('border', '1px solid #bbbca1');
form.find('div.checkbox_container').css('border-width', '0px').css('padding', '0px');
form.find('div.field_container').css('border-width', '0px').css('padding', '0px');;
}
// Adds an error to a form field
function form_error(form, field, error){
field.prev().after(''+error+'
');
field.css('border', '1px solid #a00c0d');
return true;
}
// This handles form submitting - if will check the form for empty fields that have
// class="required" (textarea, input, select)
$('form').submit(function(){
var form = $(this);
if( $('fieldset.step1').length > 0 ){
if( $('fieldset.step1').css('display') != 'none' ){
var form = $('fieldset.step1');
}else if( $('fieldset.step2').css('display') != 'none' ){
var form = $('fieldset.step2');
}else if( $('fieldset.step3').css('display') != 'none' ){
var form = $('fieldset.step3');
}
}
clear_errors( form );
error = false;
form.find('.required').each(function(i){
if( $(this).hasClass('checkbox_container') ){
field_container = $(this);
pass = false;
$(this).find('input[type=checkbox]').each(function(i){
if( $(this).is(":checked") ){
pass = true;
}
});
if( pass == false ){
error = form_error( form, field_container, 'Please complete this field' );
field_container.css('padding', '10px');
}
}else if( $(this).hasClass('field_container') ){
field_container = $(this);
pass = true;
$(this).find('input[type=text], textarea, select').each(function(i){
if( $(this).val()=='' ){
pass = false;
}
});
if( pass == false ){
error = form_error( form, field_container, 'Please complete this field' );
field_container.css('padding', '10px 10px 0px 10px');
}
}else if($(this).val() == ''){
error = form_error( form, $(this), 'Please complete this field' );
if( $(this).attr('name')=='field_current_address' ){
$('textarea#field_previous_address').prev().after('
');
}
}
});
form.find('.email').each(function(i){
if( !$(this).val().match( /\@/g ) ){
error = form_error( form, $(this), 'Please provide a valid email address' );
}
});
if( error != false){
return false;
}
if( $('fieldset.step1').length > 0 ){
if( $('fieldset.step1').css('display') != 'none' ){
$('fieldset.step1').hide();
$('fieldset.step2').show();
return false;
}else if( $('fieldset.step2').css('display') != 'none' ){
$('fieldset.step2').hide();
$('fieldset.step3').show();
return false;
}
}
return true;
});
// Hide extra checkboxes on load
// Also handle extending them again when clicked
$('div#extra_21bd_checks, div#extra_tpt_checks, div#extra_sc_checks').hide();
$('input#check_21bd').click(function(){
if(this.checked == false){$('div#extra_21bd_checks').hide();}else{$('div#extra_21bd_checks').show();}
});
$('input#check_tpt').click(function(){
if(this.checked == false){$('div#extra_tpt_checks').hide();}else{$('div#extra_tpt_checks').show();}
});
$('input#check_sc').click(function(){
if(this.checked == false){$('div#extra_sc_checks').hide();}else{$('div#extra_sc_checks').show();}
});
// Sort out apply online form stuff for javascript users
$('div.buttons.next').show();
$('fieldset.step2, fieldset.step3').hide();
// Remove some elements from the form for js users (they will be added dynamically)
$('a#add_row').show();
$('div#educational_background_rows').remove();
$('input.step1, input.step2, input.step3').show();
});
// This function adds content (like a row of form fields) before the given element
function add_row(before_element, content){
row_html = $(content).html();
$(before_element).before( row_html );
// And this sets the handler for the remove link in the added row
$('a.rm_row').click(function(){$(this).parents('div.row_container').remove();});
}