/* SHOW EMAIL TO FRIEND POPUP*/
function email_to_a_friend(sid){ 
	$('#back_div2').fadeIn('slow');
	$.post("ajax/small_popups.php", {  sid:sid, show:'emform'},
	function(data){		
		if(data!='') $("#email_div").html(data).fadeIn('slow');
	});	
}
/* PROCESS EMAIL TO FRIEND FORM */
function process_emafriend(){	
	$('#back_div2').fadeIn('slow');
	var	w = $("#pop_name").val();
	var	x = $("#pop_email").val();
	var	y = $("#pop_fname").val();
	var	z = $("#pop_femail").val();
	var	pg = $("#pop_page").val();
	
	if(x==undefined || x=='' || w==undefined || w==''){
		alert("You must enter Your Name and Your Email address."); return false;
	}
	if(y==undefined || y=='' || z==undefined || z==''){
		alert("You must enter Your Friend's Name and Your Friend's Email address."); return false;
	}
	$.post("ajax/small_popups.php", {  w:w,x:x,y:y,z:z,pg:pg, show:'emformend'},
	function(data){		
		if(data!='') $("#email_div").html(data);
	});	
}
/* SHOW SERVICE DESCRIPTION */
function show_description(x){ 
	$('#back_div2').fadeIn('slow');
	$.post("ajax/small_popups.php", {  sid:x, show:'descriptions'},
	function(data){		
		if(data!='') $("#desc_div").html(data).fadeIn("slow");
	});	
}
/* COMPANY AVAILABILITY POPUPS*/
function showemps(sid,type) {
	$.post('ajax/small_popups.php', {show:'emp_update', sid: sid, type:type},
	function(data){
		$('#hideshow').html(data);
	}, 'html');
}
/* COMPANY AVAILABILITY UPDATE EMPLOYEE*/
function update_emp_avail(compsid, empsid) {
	$.post('ajax/small_popups.php', {show:'match_emp', compsid: compsid, empsid: empsid},
	function(data){
		if(data == 'done'){
			alert('Employee Availability Updated');
		}else{
			alert('Employee data did not update: '+data+' comp: '+compsid+' emp: '+empsid);
		}
	});
}
/* COMPANY AVAILABILITY EXCEPTIONS UPDATE EMPLOYEE*/
function update_emp_excep(compsid, empsid) {
	$.post('ajax/small_popups.php', {show:'match_exception', compsid: compsid, empsid: empsid},
	function(data){
		if(data == 'done'){
			alert('Employee Availability Exception Updated');
		}else{
			//alert('Employee data did not update: '+data+' comp: '+compsid+' emp: '+empsid);
			alert(data);
		}
	});
}

/* UPDATE ALBUM COVER FOR EMPLOYEE ALBUMS*/
function change_cover(sid, gsid){ 
	$.post("ajax/small_popups.php", {  show:'new_cover', sid: sid, gsid:gsid},
	function(data){		
		if(data!='') alert(data);
	});
}

function update_menu_contacts(val){
	$.post("ajax/small_popups.php", {  show:'update_menu_contacts', val: val},
	function(data){	
		$("#menu_contacts").html(data);
	});
}

/* GENERAL POPUPS */
function hidediv(){ //For closing all popups
	$('.hideshow,#back_div2').fadeOut('slow');
}
function showdiv(){ //For one popup use
	$('#hideshow,#back_div2').fadeIn('slow');
}


function open_gallery(gtype, x, y){
	$("#back_div").attr('class','back_div');
	$("#pop_up_div").attr('class','pop_up_div');
	$("#pop_up_div").html('');
	var xmlHttpReq = false;
	var self = this;

	$.post("ajax/small_popups.php", { show: gtype, sid: x, pic: y },
	function(data){
		document.getElementById('pop_up_div').innerHTML = data;
		document.getElementById('back_div').style.height ='100%';
		$('#popup_gal').serialScroll({
			items:'li',
			prev:'#popup_prev',
			next:'#popup_next',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:500,
			force:true,
			stop:true,
			step: 1,
			lock:false,
			exclude:3,
			cycle: true, //don't pull back once you reach the end
			//easing:'easeOutQuart', //use this easing equation for a funny effect
			jump: false //click on the images to scroll to them
		});
	});
	window.scroll(0,0);
	$("#back_div").bind("click",function(){ remove('pop_up_div'); remove('back_div'); });
}

function set_gallery_main(filename) {
	$('#gal_photo > img').attr('src','imageresize.php?imagepath=images/'+filename+'&width=450&height=300');
}

function set_empgallery_main(filename) {
	$('#gal_photo > img').attr('src','imageresize.php?imagepath=gallery_images/'+filename+'&width=450&height=300');
}

function addtoFavorites(sid) {
	$.post('ajax/small_popups.php', {show: 'addfav', sid: sid},
		function(data) {
			$('#fav').html(data);
		}, 'html');
}

function removeFavorite(sid){
	$.post('ajax/small_popups.php', { show: 'remfav', sid: sid},
		function(data) {
			$('#fav').html(data);
		}, 'html');
}

function show_instructions() {
	
}
