jQuery(document).ready(function($) {
	play_movies();// play movies in the babes TV page
	jQuery(".datepicker").datepicker({
								dateFormat: 'yy-mm-dd', 
								changeMonth: true, 
								changeYear: true, 
								gotoCurrent: true,
								showOn: 'button',
								buttonImage: '/wp-content/plugins/job-manager/images/calendar.gif',
								buttonImageOnly: true
							});// Call calenda Job Section
	$('.job-table:last').find('p.separate_image').remove(); //For job list
});

// Babes TV play video

function file_get_ext(filename)
{
    return typeof filename != "undefined" ? filename.substring(filename.lastIndexOf(".")+1, filename.length).toLowerCase() : false;
}
function play_movies()
{
	//select all the a tag with name equal to modal
	jQuery('a[class=babestv_play]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		//Get the A tag
		var id = jQuery(this).attr('href');
		var link_id = jQuery(this).attr('rel');
		
		var babestv_title = '<h3 class="babestv_title">' + jQuery(this).parent(".babes_tv_thumb").find('h3').html() + '</h3>';
		//var babestv_content = '<p>' + jQuery(this).parent(".babes_tv_thumb").find('p').html() + '</p>';
		var babestv_content = '';
        jQuery(this).parent(".babes_tv_thumb").find('p').each(function(){
            babestv_content+='<p>' + jQuery(this).html() + '</p>';
        });
		
		if(file_get_ext(link_id)=='mov')
		{
			var play_mov = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="355" width="425">';
				play_mov += '<param name="src" value="'+link_id+'"/>';
				play_mov += '<param name="controller" value="true" />';
				play_mov += '<param name="autoplay" value="true" />';
				play_mov += '<param name="scale" value="tofit" />';
				play_mov += '<embed type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" scale="tofit" height="355" width="425" src="'+link_id+'" controller="true" autoplay="true" /></object>';
				play_mov += babestv_title;
				play_mov += babestv_content;
			jQuery("#babes_video_position").html(play_mov);
		}
		else if(file_get_ext(link_id)=='flv')
		{
			var flash = '<div class="video"><p id="player_tv" style="display:none"><a href="http://www.macromedia.com/go/getflashplayer">Get the latest Flash Player</a> to see this player.</p>';
				flash += "<noscript><p>[Javascript required to view Flash movie, please turn it on and refresh this page]</p></noscript>";
				flash += '<script type="text/javascript">';
				flash += 'document.getElementById("player_tv").style.display = "";';
				flash += 'var babestv1 = new SWFObject("http://babes.dev/wp-content/plugins/flv-embed/flvplayer.swf","player_tv","458","394","7");';
				flash += 'babestv1.addParam("wmode","transparent");';
				flash += 'babestv1.addParam("allowscriptaccess","always");';
				flash += 'babestv1.addParam("allowfullscreen","true");';
				flash += 'babestv1.addVariable("autostart","1");';
				flash += 'babestv1.addVariable("height","394");';
				flash += 'babestv1.addVariable("width","458");'; 
				flash += 'babestv1.addVariable("displayheight","177");';
				flash += 'babestv1.addVariable("file","'+link_id+'");';
				flash += 'babestv1.addVariable("image","/wp-content/uploads/2010/06/Avalde_FLV.jpg");';
				flash += 'babestv1.addVariable("shownavigation","false");';
				flash += 'babestv1.write("player_tv");';
				flash += '</script>';
				flash += '</div>';
				flash += babestv_title;
				flash += babestv_content;
				jQuery("#babes_video_position").html(flash);
		}
		else if(link_id != '')
		{
			var play_youtube = '<object width="425" height="355" type="application/x-shockwave-flash" data="http://www.youtube.com/v/'+link_id+'&amp;autoplay=1">;';
		  		play_youtube += '<param name="movie" value="http://www.youtube.com/v/'+link_id+'&amp;autoplay=1" />This video was embedded using the YouTuber plugin by <a href="http://www.roytanck.com">Roy Tanck</a>. Adobe Flash Player is required to view the video.</object>';
		  		play_youtube += babestv_title;
				play_youtube += babestv_content;
		  	jQuery("#babes_video_position").html(play_youtube);
		}
	});
}
// For babes, check job validation
function check_validation(frm)
{
	var job_type = false;
	jQuery("#jobman-job-edit").find(':checkbox').each(function(i){
		if(jQuery(this).val() == 'Full-Time' || jQuery(this).val() == 'Part-Time' || jQuery(this).val() == 'Freelance'){
			if(jQuery(this).is(':checked')){
				job_type = true;
				return;
			}
		}
	});
	if(!job_type){
		alert('Required Full Time or Part Time or Freelance job!');
		return (false);
	}
}
