// calendar flo web design

		var optG = '';

			function changeCalendar(da,opt,cal_view)
			{
	
					
					
					//options: return actual lists or icon (1/0), show category option or not, id of main container, small or large egg timer, abreviate names or not separated by |
					
					
					
					if (opt==0)
					{
					
					opt = optG
					
					}
					else
					{
					optG = opt;//assign value to global var
					}
					
					
							var myOpt = opt.split('|');
							
								//show a timer
								if (myOpt[3]==1)
								{
									$('#'+myOpt[2]).append('<div id="calendar_timer_small"></div>');
									$('#calendar_timer_small').css('margin-top',$('#'+myOpt[2]).height()/2-8+'px');
									
									
								}
								else
								{
								$('#'+myOpt[2]).append('<div id="calendar_timer"></div>');
								$('#calendar_timer').css('margin-top',$('#'+myOpt[2]).height()/2-16+'px');
								}
							
						
					
					
			
					//$('#cal_view2').val()==0
			
					
					//call ajax when the function is called
				$.ajax({
				
						type: "GET",
						url: "ssi/calendar/getcal.asp",
						data: {showM: da,opt: opt,catid: $('#calendar_form_select_box').val(),cal_view:cal_view},
						success: function(dataBack){
												
											
												
												$('#'+myOpt[2]).html(dataBack);
												//alert($('.calendar').width());
												 $(".calendarevents-target").ezpz_tooltip();
												//alert('back')
												//alert(dataBack)
											},
											error: function(x,e){
																if(x.status==0){
																alert('You are offline!!\n Please Check Your Network.');
																}else if(x.status==404){
																alert('Requested URL not found.');
																}else if(x.status==500){
																alert('Internel Server Error.');
																}else if(e=='parsererror'){
																alert('Error.\nParsing JSON Request failed.');
																}else if(e=='timeout'){
																alert('Request Time out.');
																}else {
																alert('Unknow Error.\n'+x.responseText);
																}
															}
				
				
				
				
				});
			
			
			
			}//end function


		function changeView()
		{
			
			changeCalendar();
			
		}






	


	function showDetail(id)
	{
	 
	 $('.click_container').slideUp(400);
	 $('#'+id).slideDown(400);
	 
	 
	 }


		function closeDetail()
		{
			
			$('.click_container').slideUp(400);
		}

emai = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
		function sendEmail()
		{
			
					//validate the input
					var error = '';
					
					if (document.event_contact.name.value==""){
								
								error = error + 'The name field is required';
								}
		
		if (document.event_contact.tel.value==""){
								
								error = error + '\nThe phone field is required';
								}
	
						if (!emai.test(document.event_contact.email.value)){
						error = error + '\nThe email field is required';
							}
							
							
					
							
								
								if (document.event_contact.comment.value==""){
								
								error = error + '\nThe comment field is required';
								}
								
								if (document.event_contact.strCAPTCHA.value==""){
								
								error = error + '\nThe security field is required';
								}
			if (error!=''){alert("Error(s) on the form:\n"+error);}
			else
			{
				
						//sed the email
							//call ajax when the function is called
								$.ajax({
								
										type: "POST",
										url: "ssi/calendar/send_mail.asp",
										data: {name: document.event_contact.name.value,email:document.event_contact.email.value,tel:document.event_contact.tel.value,comment:document.event_contact.comment.value,strCAPTCHA:document.event_contact.strCAPTCHA.value,eventId:document.event_contact.eventId.value},
										success: function(dataBack){
																
															
															if (dataBack==1)
															{
																alert("Sorry the security code entered is wrong and your email could not be sent");	
																
															}
															
															else
															{
																
																alert('Thank you, your email has been sent!');
																
																document.event_contact.name.value = '';
																document.event_contact.email.value = '';
																document.event_contact.tel.value = '';
																document.event_contact.comment.value = '';
															
																
															}
															
															
															
															
															},
															error: function(x,e){
																				if(x.status==0){
																				alert('You are offline!!\n Please Check Your Network.');
																				}else if(x.status==404){
																				alert('Requested URL not found.');
																				}else if(x.status==500){
																				alert('Internel Server Error.');
																				}else if(e=='parsererror'){
																				alert('Error.\nParsing JSON Request failed.');
																				}else if(e=='timeout'){
																				alert('Request Time out.');
																				}else {
																				alert('Unknow Error.\n'+x.responseText);
																				}
																			}
								
								
								
								
								});
						
				
				
				
			}//end else
			
		}//end of sendEmail()



/*****************************  tool tip below  *******************/

// EZPZ Tooltip v1.0; Copyright (c) 2009 Mike Enriquez, http://theezpzway.com; Released under the MIT License
(function($){
$.fn.ezpz_tooltip = function(options){
var settings = $.extend({}, $.fn.ezpz_tooltip.defaults, options);

return this.each(function(){
var content = $("#" + getContentId(this.id));
var targetMousedOver = $(this).mouseover(function(){
settings.beforeShow(content, $(this));
}).mousemove(function(e){
contentInfo = getElementDimensionsAndPosition(content);
targetInfo = getElementDimensionsAndPosition($(this));
contentInfo = $.fn.ezpz_tooltip.positions[settings.contentPosition](contentInfo, e.pageX, e.pageY, settings.offset, targetInfo);
contentInfo = keepInWindow(contentInfo);

content.css('top', contentInfo['top']-190);
content.css('left', contentInfo['left']-40);

settings.showContent(content);
});

if (settings.stayOnContent && this.id != "") {
$("#" + this.id + ", #" + getContentId(this.id)).mouseover(function(){
content.css('display', 'block');
}).mouseout(function(){
content.css('display', 'none');
settings.afterHide();
});
}
else {
targetMousedOver.mouseout(function(){
settings.hideContent(content);
settings.afterHide();
})
}

});

function getContentId(targetId){
if (settings.contentId == "") {
var name = targetId.split('-')[0];
var id = targetId.split('-')[2];
return name + '-content-' + id;
}
else {
return settings.contentId;
}
};

function getElementDimensionsAndPosition(element){
var height = element.outerHeight(true);
var width = element.outerWidth(true);
var top = $(element).offset().top;
var left = $(element).offset().left;
var info = new Array();

// Set dimensions
info['height'] = height;
info['width'] = width;

// Set position
info['top'] = top;
info['left'] = left;

return info;
};

function keepInWindow(contentInfo){
var windowWidth = $(window).width();
var windowTop = $(window).scrollTop();

var output = new Array();

output = contentInfo;

if (contentInfo['top'] < windowTop) { // Top edge is too high
output['top'] = windowTop;
}
if ((contentInfo['left'] + contentInfo['width']) > windowWidth) { // Right edge is past the window
output['left'] = windowWidth - contentInfo['width'];
}
if (contentInfo['left'] < 0) { // Left edge is too far left
output['left'] = 0;
}

return output;
};
};

$.fn.ezpz_tooltip.positionContent = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY - offset - contentInfo['height'];
contentInfo['left'] = mouseX + offset;

return contentInfo;
};

$.fn.ezpz_tooltip.positions = {
aboveRightFollow: function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY - offset - contentInfo['height'];
contentInfo['left'] = mouseX + offset;


//modified for headfort arms
contentInfo['top'] = contentInfo['top'];
contentInfo['left'] = contentInfo['left'] -170;
//end modif



return contentInfo;
}
};

$.fn.ezpz_tooltip.defaults = {
contentPosition: 'aboveRightFollow',
stayOnContent: false,
offset: 10,
contentId: "",
beforeShow: function(content){},
showContent: function(content){
content.show();
},
hideContent: function(content){
content.hide();
},
afterHide: function(){}
};

})(jQuery);

// Plugin for different content positions. Keep what you need, remove what you don't need to reduce file size.

(function($){
$.fn.ezpz_tooltip.positions.aboveFollow = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY - offset - contentInfo['height'];

contentInfo['left'] = mouseX - (contentInfo['width'] / 2);

return contentInfo;
};
/*
$.fn.ezpz_tooltip.positions.rightFollow = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY - (contentInfo['height'] / 2);


contentInfo['left'] = mouseX + offset;

return contentInfo;
};

$.fn.ezpz_tooltip.positions.belowRightFollow = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY + offset;

contentInfo['left'] = mouseX + offset;

return contentInfo;
};

$.fn.ezpz_tooltip.positions.belowFollow = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = mouseY + offset;
contentInfo['left'] = mouseX - (contentInfo['width'] / 2);

return contentInfo;
};

$.fn.ezpz_tooltip.positions.aboveStatic = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = targetInfo['top'] - offset - contentInfo['height'];
contentInfo['left'] = (targetInfo['left'] + (targetInfo['width'] / 2)) - (contentInfo['width'] / 2);

return contentInfo;
};

$.fn.ezpz_tooltip.positions.rightStatic = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = (targetInfo['top'] + (targetInfo['height'] / 2)) - (contentInfo['height'] / 2);
contentInfo['left'] = targetInfo['left'] + targetInfo['width'] + offset;

return contentInfo;
};

$.fn.ezpz_tooltip.positions.belowStatic = function(contentInfo, mouseX, mouseY, offset, targetInfo) {
contentInfo['top'] = targetInfo['top'] + targetInfo['height'] + offset;
contentInfo['left'] = (targetInfo['left'] + (targetInfo['width'] / 2)) - (contentInfo['width'] / 2);

return contentInfo;
};
*/
})(jQuery);

