/*
 * JobRoller theme jQuery functions
 * Written by AppThemes
 *
 * Copyright (c) 2010 AppThemes (http://appthemes.com)
 *
 * Built for use with the jQuery library
 * http://jquery.com
 *
 * Version 1.0
 *
 * Left .js uncompressed so it's easier to customize
 */

jQuery(document).ready(function() {

	/* Tag input */
	jQuery('.tag-input-commas').tag({separator: ','});

    /* Apply for job slider */
    jQuery('#share_form, #apply_form:not(.open)').hide();

    if (jQuery('#apply_form').is('.open')) jQuery('a.apply_online').addClass('active');

    jQuery('a.apply_online').click(function(){
        jQuery('#share_form').slideUp();
        jQuery('#apply_form').slideToggle();
        jQuery('a.share').removeClass('active');
        jQuery(this).toggleClass('active');
        return false;
    });

    jQuery('a.share').click(function(){
        jQuery('#apply_form').slideUp();
        jQuery('#share_form').slideToggle();
        jQuery('a.apply_online').removeClass('active');
        jQuery(this).toggleClass('active');
        return false;
    });


    // Show single job apply and print section 
    jQuery('ul.section_footer').show();

    // add jquery lazy load for images 
    jQuery('img:not(.load)').lazyload({
        effect:'fadeIn',
        placeholder: '../../images/grey.gif'
    });

    // Input placeholders
    jQuery('input.placeholder').each(function(){
    	var placeholder = jQuery(this).attr('rel');
    	jQuery(this).focus(function(){
    		if (jQuery(this).val()==placeholder) jQuery(this).val('');
    	});
    	jQuery(this).blur(function(){
    		if (jQuery(this).val()=='') jQuery(this).val(placeholder);
    	});
    	jQuery(this).blur();
    });
    jQuery('form').submit(function(){
		jQuery(this).find('input.placeholder').each(function(){
			if (jQuery(this).attr('rel')==jQuery(this).val()) jQuery(this).val('');
		});
	});
	
	jQuery('textarea.grow').autogrow();

	// qTips
	jQuery('h1.resume-title span, .resume_header img').qtip({
		content: {
			text: jQuery('.user_prefs_wrap')
		},
		position: {
			corner: {
				tooltip: 'bottomMiddle',
				target: 'topMiddle'
			},
		  	adjust: {
		  		y: 8
			}
		},
		style: {
		  width: 300,
		  border: {
		     width: 0,
		     radius: 5
		  },
		  padding: 12, 
		  textAlign: 'left',
		  tip: true, 
		  name: 'light' 
		}
    });
	jQuery('ol.resumes li').qtip({
		position: {
			corner: {
				tooltip: 'bottomMiddle',
				target: 'topMiddle'
			},
		  	adjust: {
		  		y: 14
			}
		},
		style: {
		  width: 300,
		  border: {
		     width: 0,
		     radius: 5
		  },
		  padding: 12, 
		  textAlign: 'left',
		  tip: true,
		  name: 'light'
		}
    });
});
