// unblock when ajax activity stops 
$(document).ajaxStop($.unblockUI); 

$(function(){
	
	try{
		//timeout if too fasto
		document.postlet.getMaxFileSize();	
	}
	catch(error){
		$('#no-postlet').show();
		$('#postlet').hide();
	} 
	
	
	/*
	-------------------------------	
	Show the Job Posting Matches  	
	-------------------------------			  
	*/
	/*
	-------------------------------	
	Show the Interviews Matches  	
	-------------------------------
	*/
	var loadingDiv = $('<div>').text('loading...').attr('id', 'loadingDiv').attr('display', 'none');	
	$('.get_posting, .applicant_type').click(function(){
		//if($(this).hasClass(
		 $('body').append(loadingDiv.attr('display', 'none'));		
		 $.blockUI({			 
			 message: $('#loadingDiv'), 
				css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .5, 
				color: '#fff' 		 	
				}
		 }); 
    
		get_posting = [];		
		$('.get_posting').each(function(){
			if($(this).is(':checked')){
				get_posting.push(  $(this).attr('name') );
			}
		});
		get_posting.join('.');			
		
		//interview status array
		applicant_type = [];		
		$('.applicant_type').each(function(){
			if($(this).is(':checked')){
				applicant_type.push(  $(this).attr('name') );
			}
		});
		applicant_type.join('.');

		//Moved to $.ajax 
		var url = 'employer_job_candidates_get_posting.php?jpids=' + get_posting + '&applicant_type=' + applicant_type;
		
		$.ajax({
			url: url,
			success: function(data){
				 $('#results').html(data).delay(500).slideDown(1000);
				 loadPagination(1);			
			},
			dataType: 'html'
		});
 		
		$('#interview_no_results').hide('slow');		
		
	});	
	/*
	var loadingDiv = $('<div>').text('loading...').attr('id', 'loadingDiv').attr('display', 'none');
	$('.get_posting').click(function(){
		 $('body').append(loadingDiv.attr('display', 'none'));		
		 $.blockUI({			 
			 message: $('#loadingDiv'), 
				css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .5, 
				color: '#fff' 		 	
				}
		 }); 
       /// setTimeout($.unblockUI, 1000); 

		jpids = [];		
		$('.get_posting').each(function(){
			if($(this).is(':checked')){
				jpids.push(  $(this).attr('name') );
			}
		});

		jpids.join('.');			
		//$('#results').load('employer_job_candidates_get_posting.php?jpids=' + jpids + '&page=' + page,  $.unblockUI).delay(500).slideDown(1000);
		$('#results').load('employer_job_candidates_get_posting.php?jpids=' + jpids).delay(500).slideDown(1000);		
		$('#no_results').hide('slow');
	});
	*/
	
	
	/*
	-------------------------------	
	Show the Job Seeker Messages Matches  	
	-------------------------------
	*/			  
	$('.messages_type_id').click(function(){
		
		//if($(this).hasClass(
		 $('body').append(loadingDiv.attr('display', 'none'));		
		 $.blockUI({			 
			 message: $('#loadingDiv'), 
				css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .5, 
				color: '#fff' 		 	
				}
		 }); 
    
		messages_type_id = [];		
		$('.messages_type_id').each(function(){
			if($(this).is(':checked')){
				messages_type_id.push(  $(this).attr('name') );
			}
		});

		messages_type_id.join('.');			
		
		//Moved to $.ajax 
		var url = 'jobseeker_messages_get_messages.php?messages_type_id=' + messages_type_id;
		
		$.ajax({
			url: url,
			success: function(data){
				 $('#message_results').html(data).delay(500).slideDown(1000);
				 loadPagination(1);			
			},
			dataType: 'html'
		});
 		
		$('#message_no_results').hide('slow');		
		
	});
		
	
	/*
	-------------------------------	
	Show the Employer Messages Matches  	
	-------------------------------
	*/			  
	$('.employer_messages_type_id').click(function(){
		
		//if($(this).hasClass(
		 $('body').append(loadingDiv.attr('display', 'none'));		
		 $.blockUI({			 
			 message: $('#loadingDiv'), 
				css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .5, 
				color: '#fff' 		 	
				}
		 }); 
    
		messages_type_id = [];		
		$('.employer_messages_type_id').each(function(){
			if($(this).is(':checked')){
				messages_type_id.push(  $(this).attr('name') );
			}
		});

		messages_type_id.join('.');			
		
		//Moved to $.ajax 
		var url = 'employer_messages_get_messages.php?messages_type_id=' + messages_type_id;
		
		$.ajax({
			url: url,
			success: function(data){
				 $('#message_results').html(data).delay(500).slideDown(1000);
				 loadPagination(1);			
			},
			dataType: 'html'
		});
 		
		$('#message_no_results').hide('slow');		
		
	});	
	
	
	/*
	-------------------------------	
	Show the Interviews Matches  	
	-------------------------------
	*/			  
	$('.interview_type, .interview_status').click(function(){
		//if($(this).hasClass(
		 $('body').append(loadingDiv.attr('display', 'none'));		
		 $.blockUI({			 
			 message: $('#loadingDiv'), 
				css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .5, 
				color: '#fff' 		 	
				}
		 }); 
    
		interview_type = [];		
		$('.interview_type').each(function(){
			if($(this).is(':checked')){
				interview_type.push(  $(this).attr('name') );
			}
		});
		interview_type.join('.');			
		
		//interview status array
		interview_status = [];		
		$('.interview_status').each(function(){
			if($(this).is(':checked')){
				interview_status.push(  $(this).attr('name') );
			}
		});
		interview_status.join('.');
			
		
		//Moved to $.ajax 
		var url = 'jobseeker_interview_get_interview.php?interview_type=' + interview_type + '&interview_status=' + interview_status;
		
		$.ajax({
			url: url,
			success: function(data){
				 $('#interview_results').html(data).delay(500).slideDown(1000);
				 loadPagination(1);			
			},
			dataType: 'html'
		});
 		
		$('#interview_no_results').hide('slow');		
		
	});		
	

	$('.question_response').click(function(){
		$(this).parent().fadeOut('slow');
		$(this).parent().prev().fadeIn('slow');	
	});
	
	$('.event_response').click(function(){
		$(this).parent().fadeOut('slow');
		$(this).parent().prev().fadeIn('slow');	
	});	
	
	$('.message_board_likes_dislike').click(function(){
		$(this).parent().fadeOut('slow');
		$(this).parent().prev().fadeIn('slow');	
	});	
	
	//when pagination control is clicked
	$('.ajax_pagination a').live('click',function(){		
		var page = $(this).attr('href').replace('?page=', '');
		 
		var url = 'jobseeker_messages_get_messages.php?messages_type_id=' + messages_type_id + "&page=" + page;
		
		$('.pagination a').removeClass('current');
		$(this).addClass('current');
		
		$.ajax({
			url: url,
			success: function(data){
				 $('#message_results').html(data).delay(500).slideDown(1000);				 
				 loadPagination(page);			
			},
			dataType: 'html'
		});

		return false;
		
	});

				  
	$("#biz_form").validate({			
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted below'
					: 'You missed ' + errors + ' fields.  They have been highlighted below';
				//$(".error-span").html(message);
				$("div.error p b").html(message);
				
				
				$("div.error").show();
				
			} else {
				$("div.error").css("border", "none").hide();
			}
			
			$("label.error").css("border", "1px solid blue").hide(); //hide defaults
		},
		errorPlacement: function(error, element) {
		if (element.attr("name") == "fname" || element.attr("name") == "lname" ){
			error.insertAfter("#lastname");
		}else{
			if(element.hasClass("defaultErrorPlacement")){
				error.insertAfter(element);
			}
			{
			// Nothing Here	
			}
		}
		},	
		rules: {				
				confirmpassword: {
				required: true,
				minlength: 3,
				equalTo: "#password"
				}			
			},
			messages: {
				
				password: {
					required: "Please provide a password",
					minlength: "Your password must be at least 5 characters long"
				},
				confirmpassword: {
					required: "Please provide a password",
					minlength: "Your password must be at least 5 characters long",
					equalTo: "Please enter the same password as above"
				},
				email: "Please enter a valid email address",
				agree: "Please accept our policy"
				
			},
			submitHandler: function(form) {
				// loadinggraphic();
				form.submit();		
	
				}
			//success: function() { loadinggraphic()}
	});
	
	
  $.validator.addMethod("alphanumeric", function(value, element) {
        return this.optional(element) || /^[a-z0-9\-]+$/i.test(value);
    }, "Username must contain only letters, numbers, or dashes.");

/*
	// Custom Validation using RegEx
    function ValidateUsername(username) {
        var expr = /(A-Za-z0-9-_)$/;
        return expr.test(username);
    };
    $("#username").live("click", function () {
        if (!ValidateUsername($("#username").val())) {
            alert("Invalid email address.");
        }
        else {
            alert("Valid email address.");
        }
    });
*/
	$('#save_thumb').click(function() {
		var x1 = $('#x1').val();
		var y1 = $('#y1').val();
		var x2 = $('#x2').val();
		var y2 = $('#y2').val();
		var w = $('#w').val();
		var h = $('#h').val();
		if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
			alert("You must make a selection first");
			return false;
		}else{
			return true;
		}
	});	

/*
-------------------------------
Start Dialog windows
-------------------------------
*/
	$('.iframe_popup_small').click(function(e) {
		e.preventDefault();			
		var $this = $(this);
		var horizontalPadding = 30;
		var verticalPadding = 30;
		
		var iframe_popup = $('<iframe id="externalSite" class="externalSite" frameborder="0" allowtransparency="true" src="' + this.href + '" />');
		iframe_popup.dialog(
		{
			title: ($this.attr('title')) ? $this.attr('title') : 'Bizcasts Info',
			autoOpen: true,
			width: 600,
			height: 150,
			modal: true,
		 //   resizable: true,
			autoResize: true,
			overlay: {
				opacity: 0.5,
				background: "black"
			}
		}).width(600 - horizontalPadding).height(150 - verticalPadding);
	});		
	
	$('.iframe_popup_medium').click(function(e) {
		e.preventDefault();			
		var $this = $(this);
		var horizontalPadding = 30;
		var verticalPadding = 30;
		
		var iframe_popup = $('<iframe id="externalSite" class="externalSite" frameborder="0" allowtransparency="true" src="' + this.href + '" />');
		iframe_popup.dialog(
		{
			title: ($this.attr('title')) ? $this.attr('title') : 'Bizcast Info',
			autoOpen: true,
			width: 600,
			height: 300,
			modal: true,
		 //   resizable: true,
			autoResize: true,
			overlay: {
				opacity: 0.5,
				background: "black"
			}
		}).width(600 - horizontalPadding).height(300 - verticalPadding);
	});	


	
	$('.iframe_popup').live('click', function(e) {
		
		e.preventDefault();			
		var $this = $(this);
		var horizontalPadding = 30;
		var verticalPadding = 30;
		
		var iframe_popup = $('<iframe id="externalSite" class="externalSite" frameborder="0" allowtransparency="true" src="' + this.href + '" />');
		iframe_popup.dialog({
			title: ($this.attr('title')) ? $this.attr('title') : 'Bizcast Info',
			autoOpen: true,
			width: 700,
			height: 500,
			modal: true,
		 //   resizable: true,
			autoResize: true,
			overlay: {
				opacity: 0.5,
				background: "black"
			}
		}).width(700 - horizontalPadding).height(500 - verticalPadding);
	});	
	
	
		
/*
-------------------------------
End Dialog windows
-------------------------------
*/	

	$('.delete, .remove').click(function(e) {
        //custom message pulled from title tag.
        var msg = $(this).attr('rel');
        if (msg == '') msg = "Are you sure you would like to delete this item?";
        e.preventDefault();
        var href = $(this).attr('href');
        custom_confirm(msg + ' ', function() {
            location.href = href
        }, 'Confirmation'
        );
    });
	
	$('.undo_delete, .undo_remove').click(function(e) {
        //custom message pulled from title tag.
        var msg = $(this).attr('rel');
        if (msg == '') msg = "Are you sure you would like to add this item?";
        e.preventDefault();
        var href = $(this).attr('href');
        custom_confirm_undo(msg + ' ', function() {
            location.href = href
        }, 'Confirmation'
        );
    });	
	
	if($('#current').is(':checked')){
		//alert('checked')
		$('.to-dates').hide();
		$('.still-present').show();
	}else{
		$('.to-dates').show();
		$('.still-present').hide();	
		
		//	alert('not checked');			
	}	
	
	$('#current').change(
		function(){
	  	$('.to-dates').toggle();
		$('.still-present').toggle();
		}
	);	
	
	$('.interview_type_duplicate').change(
		function(){
		$('.interview_type_speed_duplicate').toggle();
		$('.interview_type_long_duplicate').toggle();
		}
	);	

/*
-------------------------------
Start Inbox
-------------------------------
*/	
	$('.msg_mark_save').click(function(){
		$('#action_to_take').val('msg_mark_save');	
		$('#messages_form').submit();
	});

	$('.msg_mark_read').click(function(){
		$('#action_to_take').val('msg_mark_read');	
		$('#messages_form').submit();
	});
	
	$('.msg_mark_unread').click(function(){
		$('#action_to_take').val('msg_mark_unread');	
		$('#messages_form').submit();
	});
	
	$('.msg_mark_spam').click(function(){
		$('#action_to_take').val('msg_mark_spam');	
		$('#messages_form').submit();
	});
	
	$('.msg_mark_delete').click(function(){
		$('#action_to_take').val('msg_mark_delete');
		$('#messages_form').submit();
	});		
			
	$('#check_all').click(function(){
		$('.msg_checkboxes').each(function(){
			$(this).attr('checked','checked');
		});		
	});

	$('#check_none').click(function(){
		$('.msg_checkboxes').each(function(){
			$(this).attr('checked','');
		});		
	});	

	$('#check_read').click(function(){
		$('.read').each(function(){
			$(this).attr('checked','checked');
		});		
	});
	
	
	
/*
-------------------------------
Start Messages Filters 
-------------------------------
*/
	if($('#contacts_request').is(':checked')){
		//alert('checked')
		$('.messages_contact_request').show();
	}else{
		$('.messages_contact_request').hide();		
		//	alert('not checked');			
	}
	
	$('#contacts_request').change(
		function(){
	  	$('.messages_contact_request').toggle();
		}
	);
	
	if($('#messages').is(':checked')){
		//alert('checked')
		$('.messages').show();
	}else{
		$('.messages').hide();				
		//	alert('not checked');			
	}
	$('#messages').change(
		function(){
	  	$('.messages').toggle();
		}
	);	
/*
-------------------------------
End Messages Filters 
-------------------------------
End Inbox
-------------------------------
*/	
	
	/*
	--------------------
	Start Search 
	--------------------
	*/
		$( "#people_search" ).autocomplete({
			source: "jobseeker_search.php",
			minLength: 2,
			select: function( event, ui ) {
				log( ui.item ?
					 //ui.item.email : 0
					 //ui.item.id: 0					 
					 ui.item.username : 0
					 );
			},
			html: true
	});	
	
		$( "#employee_search" ).autocomplete({
			source: "employee_search.php",
			minLength: 2,
			select: function( event, ui ) {
				log( ui.item ?
					 //ui.item.email : 0
					 //ui.item.id: 0					 
					 ui.item.username : 0
					 );
			},
			html: true
	});		
	
	function log( message ) {
			//remove html!
		    message =   message.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/ig, "");
			$('#username_search').val(message);			
	}
	

	function split( val ) {
		return val.split( /,\s*/ );
	}
	
	function extractLast( term ) {
			return split( term ).pop();
		}
	/*
	--------------------
	End Search 
	--------------------
	Start Message Search 
	--------------------
	*/
	$( "#contact" ).autocomplete({
			source: "jobseeker_messages_search.php",
			minLength: 2,
			select: function( event, ui ) {
				contact_log( ui.item ?
					 //ui.item.email : 0
					 ui.item.id: 0					 
					 //ui.item.username : 0
					 );
			}
		});	
		
	 $( "#contact-new" )
			// don't navigate away from the field on tab when selecting an item
			.bind( "keydown", function( event ) {
				if ( event.keyCode === $.ui.keyCode.TAB &&
						$( this ).data( "autocomplete" ).menu.active ) {
					event.preventDefault();
				}
			})
			.autocomplete({
				source: function( request, response ) {
					$.getJSON( "jobseeker_messages_search.php", {
						term: extractLast( request.term )
					}, response );
				},
				search: function() {
					// custom minLength
					var term = extractLast( this.value );
					if ( term.length < 2 ) {
						return false;
					}
				},
				focus: function() {
					// prevent value inserted on focus
					return false;
				},
				select: function( event, ui ) {
					var terms = split( this.value );
					// remove the current input
					terms.pop();
					// add the selected item
					terms.push( ui.item.value );
					// add placeholder to get the comma-and-space at the end
					terms.push( "" );
					this.value = terms.join( ", " );
					
					//put id into alt field
					var valToPut = new Array();
					var currVal = $('#contact_id').val();
					
					valToPut.push(currVal);
					valToPut.push(ui.item.id);
					
					var value = valToPut.join(",");
 					//$('#contact_id').val( ui.item ? ui.item.id: 0);	
					contact_log( value );
					
					return false;
				}
			});	
		
	/*
	--------------------
	Start Search for yor contacts
	--------------------
	*/		
	$( "#user_contact" ).autocomplete({
			source: "jobseeker_contact_search.php",
			minLength: 2,
			select: function( event, ui ) {
				contact_log( ui.item ?
					 ui.item.id: 0
					 );
			}
		});			
		
	$( "#contact_message" ).autocomplete({
			source: "jobseeker_messages_search.php",
		
			focus: function() {
				// prevent value inserted on focus
				return false;
			},
			minLength: 1,
			select: function( event, ui ) {
					var terms = split( this.value );
					// remove the current input
					terms.pop();
					// add the selected item
					terms.push( ui.item.value.replace("  ", "") );
					// add placeholder to get the comma-and-space at the end
					terms.push( "" );
					this.value = terms.join( ", " );
					
					
					//alert(this.value);
					
					return false;
				}

		});	
	
	function contact_log( message ) {
			$('#contact_id').val(message);			
	}
	
	/*
	--------------------
	End Search 
	--------------------
	*/		

	//http://jqueryui.com/demos/autocomplete/remote.html
	//http://net.tutsplus.com/tutorials/javascript-ajax/how-to-use-the-jquery-ui-autocomplete-widget/
	$( "#college_name" ).autocomplete({
			source: "jobseeker_profile_education_search.php",
			minLength: 2
		});

	$( "#company_name" ).autocomplete({
			source: "jobseeker_profile_experience_search.php",
			minLength: 2
		});

	/*
	--------------------
	Start Languages 
	--------------------
	*/
	$( ".languages" ).autocomplete({
			source: "jobseeker_profile_languages_search.php",
			minLength: 2
		});									
	/*
	--------------------
	End General Skills 
	--------------------
	Start General Skills 
	--------------------
	*/
	$( ".general_skills" ).autocomplete({
			source: "jobseeker_profile_skills_general_search.php",
			minLength: 2
		});									
	/*
	--------------------
	End General Skills 
	--------------------	
	Start Industry Name
	--------------------
	*/
	$( "#industry_name" ).autocomplete({
			source: "jobseeker_profile_industry_search.php",
			minLength: 2
		});	
	/*
	--------------------
	Start Specific Skills 
	--------------------
	*/		
	$( ".specific_skills" ).autocomplete({
			source: "jobseeker_profile_skills_specific_search.php",
			minLength: 2
		});
	/*
	--------------------
	End Specific Skills 
	--------------------
	*/	
	$( ".cert_name" ).autocomplete({
			source: "jobseeker_profile_certifications_search.php",
			minLength: 2
		});

	$( ".honor_name" ).autocomplete({
			source: "jobseeker_profile_honor_search.php",
			minLength: 2
		});	
		
	$( ".security_name" ).autocomplete({
			source: "jobseeker_profile_security_clearance_search.php",
			minLength: 2
		});				
		
	/*
	--------------------
	Start Event Keywords
	--------------------
	*/		
	$( ".event_keywords" ).autocomplete({
			source: "jobseeker_events_keyword_search.php",
			minLength: 2
		});
	/*
	--------------------
	End Event Keywords
	--------------------
	Start Event Location
	--------------------
	*/
	$( ".event_location_name" ).autocomplete({
			source: "jobseeker_events_location_search.php",
			minLength: 2
		});	
	/*
	--------------------
	End Event Keywords		
	*/			
		
		
		
		// Accordion
		$("#accordion").accordion({ header: "h3" });

		// Tabs
		$('#tabs').tabs();

		// Dialog			
		$('#dialog').dialog({
			autoOpen: false,
			width: 600,
			buttons: {
				"Ok": function() { 
					$(this).dialog("close"); 
				}, 
				"Cancel": function() { 
					$(this).dialog("close"); 
				} 
			}
		});
		
		// Dialog Link
		$('#dialog_link').click(function(){
			$('#dialog').dialog('open');
			return false;
		});
	
		// Datepicker
		$('.datepicker').datepicker({
			inline: true
		});
		
		
		$('.elastic').prettyComments({
			animate: true,
			animationSpeed: 'normal',
			maxHeight: 250
		});
		
		$('.elastic_small').prettyComments({
			animate: true,
			animationSpeed: 'normal',
			maxHeight: 100
		});		
		$(".elastic_small").attr('maxlength','400');			
		
		
		// Slider
		$('#slider').slider({
			range: true,
			values: [17, 67]
		});
		
		// Progressbar
		$("#progressbar").progressbar({
			// value: 25 
			value: parseInt($("#profile_completed_percentage").html())
		});
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);	
		
	
		// Auto Select Section on Inbox	
		if( getParameter( 'message_type_id' ).length > 0 ){
			var message_type_id = getParameter( 'message_type_id' );
			errLog('message worked yo' + message_type_id )
			$('#message_type_id_' + message_type_id).attr('checked', 'checked').click().attr('checked', 'checked');
		}else{		
			$('#message_type_id_1').attr('checked', 'checked').click().attr('checked', 'checked');		
		}
		
		// Auto Select Section on Job Candidates
		if( getParameter( 'get_posting' ).length > 0 ){
			var get_posting = getParameter( 'get_posting' );
			errLog('Message: Posting id = ' + get_posting )
			$('#get_posting_' + get_posting).attr('checked', 'checked').click().attr('checked', 'checked');
		}		
		
		// Auto Select Interview Type
		$('#interview_type_speed').attr('checked', 'checked').click().attr('checked', 'checked');		
		
		
		
		$("area[rel^='prettyPhoto']").prettyPhoto();
		
		// Image Gallery 
		$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: true});
		$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});

		$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
			custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
			changepicturecallback: function(){ initialize(); }
		});

		$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
			custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
			changepicturecallback: function(){ _bsap.exec(); }
		});
				
		
		$('#click_view_older_msg').click(function() {
		  $('#view_older_msg').show('slow', function(){
		  });
		  $('#click_view_older_msg').hide('slow', function(){
		  });
		});
		
	/*
	Show payment form 
	*/
	$("#payment_paypal").css("display","none");
	$("#payment_google").css("display","none");	
            
    $(".payment_type").click(function(){
    	if ($('input[name=payment_type]:checked').val() == "payment_cc" ) {
            $("#payment_paypal").slideUp("fast");	//Slide Up Effect
            $("#payment_google").slideUp("fast");	//Slide Up Effect			
        	$("#payment_cc").slideDown("fast"); //Slide Down Effect   
		} 
		
		if ($('input[name=payment_type]:checked').val() == "payment_paypal" ) {
            $("#payment_cc").slideUp("fast");	//Slide Up Effect
            $("#payment_google").slideUp("fast");	//Slide Up Effect
        	$("#payment_paypal").slideDown("fast"); //Slide Down Effect   
		}
		
		if ($('input[name=payment_type]:checked').val() == "payment_google" ) {
            $("#payment_cc").slideUp("fast");	//Slide Up Effect
            $("#payment_paypal").slideUp("fast");	//Slide Up Effect
        	$("#payment_google").slideDown("fast"); //Slide Down Effect   
        }
     }); 		


	/*
	Sorting Elements
	*/
	$(function() {
		$("#reorder-gallery ul").sortable({ 
			opacity: 0.6
			, cursor: 'move'
			, update: function() {
				var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
					$.post("jobseeker_multimedia_sort_save.php"
					, order
					, function(theResponse){
					$("#contentRight").html(theResponse);
			});
		}
		});
	});


}); // end function


//used jQuery modal dialog to replace js confirm.

function custom_confirm(prompt, action, title) {

    if (title === undefined) title = "Are you sure?";
    $('body').append('<div id="confirm" title="' + title + '">' + prompt + '</div>');
    $("#confirm").dialog({
        modal: true,
        resizable: false,
        buttons: {
            'Delete': function() {
                $(this).dialog('close'); action();
            },
            Cancel: function() {
                $(this).dialog('close');
            }
        },
        close: function(ev, ui) {
            $(this).remove();
        }
    });
}

function custom_confirm_undo(prompt, action, title) {

    if (title === undefined) title = "Are you sure?";
    $('body').append('<div id="confirm" title="' + title + '">' + prompt + '</div>');
    $("#confirm").dialog({
        modal: true,
        resizable: false,
        buttons: {
            'Yes': function() {
                $(this).dialog('close'); action();
            },
            'No': function() {
                $(this).dialog('close');
            }
        },
        close: function(ev, ui) {
            $(this).remove();
        }
    });
}


function loadPagination(page){
	
	
	total_pages =  $('#lastpage').val();;
	 
	$('.ajax_pagination').load('_functions/pagination_ajax.php?page=' + page + '&total_pages=' + total_pages);

}
	
	//gets url in js like $_GET['name'];
function getParameter( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return false;//  "";
  else
    return results[1];
}


function removeDiv(jQueryGroupedSet){
	jQueryGroupledSet.remove();
	
	}
	
function errLog(str){
	if (window.console && window.console.log) {
		window.console.log(str);
	}
}
	
