
$(document).ready(function(){

    /* chaining css fix for ie6*/
    if (jQuery.browser.msie) {
       if(parseInt(jQuery.browser.version)==6){        
        $('.current_page_ancestor a').addClass('current_page_ancestor');
        $('.current_page_item a').addClass('current_page_item');        
        }else{
            iniSifr();
        }
    }else{
        iniSifr();
    }
    
    $('.newsletter-form input[type=text]').addClass('field');
    $('.newsletter-form input[type=submit]').addClass('button gbutton bt-submit right').val('');
    
    $('.vignettebutton').each(function() {
             $(this).wrap('<div class="buttonwrap">');
             $(this).find('.middle').before('<span class="block"></span><span class="front"></span>');
             $(this).append('<span class="back"></span><span class="clear"></span>');
             $(this).find('.block').width($(this).width());
             $(this).after('<div class="clear"></div>');
     });

    $('.button').hover(function(){$(this).css('opacity','0.8')}, function(){$(this).css('opacity','1')});
    $('.field').wrap('<div class="fieldWrapper">');            
    $('.tab-nav a:last').css('margin-right','0');
    $('.post-content p:first').each(function(){
        $(this).css('line-height','1.2em');
        $(this).css('font-size','1.5em');
        $(this).addClass('purple');
        
    });
    /*
    $('.accordion-area .acc-head').click(function() {
        $(this).next().toggle('fast');
        $(this).toggleClass('opened');
        return false;
    }).next().hide();
*/

    $('.accordion-area').accordion(
    {
        active: true,
        header: '.acc-head',
        navigation: true,
        event: 'click',
        fillSpace: false,
        collapsible: true,        
        autoheight:false,
        alwaysOpen: false

    });
	//$( ".openfirst" ).accordion( "activate", 0 );

    $('#s').focus(function(){
        if($(this).val()=='Search') $(this).val('');
    }).blur(function(){
        if($(this).val()=='') $(this).val('Search');
    });
    $('li:has(#other)').hide();
    
    $("input[name='apply-for']").change(function(){
        if ( $(this).val()=='Other' ) $('li:has(#other)').show();
        else $('li:has(#other)').hide();
    });
    
    /* tier 2 visa form*/
    /*
    $('#employer-1').parents('.cf-box-group').find("input[name='employer']").click(function(){
        
        if ($("input[name='employer']:checked").val()=='Employer'){ // for employers
            $('.cf-fs1').show();
            $('#Nationality,#Date-of-birth,#in-uk-1,#current-visa,#visa-expire,#salary1,#Job-offered').parents('li').hide();
            $('#Position,#sponsorship-licence-1').parents('li').show();
            $('#job-offer-1').parents('li').hide();

            $('#'+$('#sponsorship-licence-1').parents('li').attr('id').substr(0,6)).show();
            $('#'+$('#in-uk-1').parents('li').attr('id').substr(0,6)).hide();
            $('#'+$('#job-offer-1').parents('li').attr('id').substr(0,6)).hide();
            
        }else{// for employees
            $('.cf-fs1').hide();
            $('#Nationality,#Date-of-birth,#in-uk-1,#current-visa,#visa-expire,#salary1,#Job-offered').parents('li').show();
            $('#Position,#sponsorship-licence-1').parents('li').hide();
            $('#job-offer-1').parents('li').show();

            $('#'+$('#sponsorship-licence-1').parents('li').attr('id').substr(0,6)).hide();
            $('#'+$('#in-uk-1').parents('li').attr('id').substr(0,6)).show();
            $('#'+$('#job-offer-1').parents('li').attr('id').substr(0,6)).show();
        }

    });
    */

    $('#We-are-interested-in-applying-for-1').parents('.cf-box-group').find('label,label span').css('width','220px');
   /* dependant visa form*/
    $('#dependant-no-1').parents('.cf-box-group').find('.cf-after,.cf-after span').css('width','20px');
    
    $('.cf-fs2,.cf-fs3,.cf-fs4').hide();
    
    switch($("input[name='dependant-no']:checked").val()){
        case '2':$('.cf-fs2').show();break;
        case '3':$('.cf-fs2').show();$('.cf-fs3').show();break;
        case '4':$('.cf-fs2').show();$('.cf-fs3').show();$('.cf-fs4').show();break;
    }
    $('#dependant-no-1').parents('.cf-box-group').find("input[name='dependant-no']").click(function(){
        
        switch(($("input[name='dependant-no']:checked").val())){
            case '1': 
                 $('.cf-fs1 input').addClass('fldrequired');
                 $('.cf-fs1').show();
                 $('.cf-fs2').hide(); $('.cf-fs3').hide(); $('.cf-fs4').hide();
                 $('.cf-fs2 input,.cf-fs3 input,.cf-fs4 input').removeClass('fldrequired');
                break;
            case '2':
                 $('.cf-fs2').show(); $('.cf-fs3').hide(); $('.cf-fs4').hide();
                 $('.cf-fs2 input').addClass('fldrequired');
                 $('.cf-fs3 input,.cf-fs4 input').removeClass('fldrequired');
                  break;
            case '3':
                 $('.cf-fs2').show(); $('.cf-fs3').show(); $('.cf-fs4').hide();
                 $('.cf-fs2 input,.cf-fs3 input').addClass('fldrequired');
                 $('.cf-fs4 input').removeClass('fldrequired');
                  break;
            case '4': 
                 $('.cf-fs2').show(); $('.cf-fs3').show(); $('.cf-fs4').show();
                 $('.cf-fs2 input,.cf-fs3 input,.cf-fs4 input').addClass('fldrequired');
                 break;
        }
    });
    // add * next to requierd field
    $('.fldrequired').parents('li:not(.cf-box-group)').find('label span').append(' *');
    $('.fldrequired').parents('li.cf-box-group').prev().append(' *');

});

function initialize(){
    var map = new GMap2(document.getElementById("google-map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(51.595842,-1.881409), 8);
    var point = new GLatLng(51.595842,-1.881409);
    var marker = new GMarker(point);
    map.addOverlay(marker);
    GEvent.addListener(marker, "click", function()
    {marker.openInfoWindowHtml("Marker #<b>" +  + "</b>"); });
}

