/*  project:   		  cat software applications
	client:    		  descon conveyor systems - newmarket, on
	author:    		  chigozie 'cat' nduanya
	date:      		  may 09, 2009
	file-name: 		  processor.js
	file-type: 		  javascript library
	supporting-files: prototype-1.6.0.3.js, jquery-1.3.2.min.js, jquery-ui-1.7.1.custom.min.js, catscript-v2.js
    */

/* declarations:
   */
$cat(function(){		
	new ClsMuskokaSpaForPets();
});	

/*
	class: ClsMuskokaSpaForPets
	parameters: width, fade
	contract: must generate the internal structure, content and styles for the muskokaspaforpets website.
			  tested and passed.
	
*/
var ClsMuskokaSpaForPets=Class.create({
	initialize:function(){
		var strWidth=94, strHeight=470, fade=false;
		
		/*
			object: 	 ClsMuskokaSpaForPets->Lib
			description: defines the general variables and properties needed for the msp website.
						 tested and passed.
		*/
		var Lib={		
			borderColor:'#BBCEFD',
			containerCss:{'width':strWidth+'%'},
			containerIndentCss:function(strPad){return {'margin':0+' '+strPad+'px'};},
			darkBackgroundCss:function(){
				return {'background':'url('+this.imageDir+'background_body.png)','color':'white'};
			},
			fade:fade,
			headerColor:'#99FF00',
			imageDir:'images/',	
			imageHeight:90,
			linkBorderColor:function(borderColor){return borderColor;},
			logoCss:{'width':'100%'},
			mainImageCss:function(imageHeight){return {'height':(imageHeight*2)+'px','width':'90%'};},
			menuItemOn:function(headerColor){return {'background':headerColor};},
			muskokaImageDir:function(imageDir){return imageDir+'muskoka_images/';},
			pageBodyCss:{'height':strHeight+'px'},
			processMenuItem:function(menuItem){
				Content.pageBody(menuItem);
				Styles.pageBody();
				Styles.documentBody();
			},		
			strPad:2,
			thumbnailImageCss:function(imageHeight,strPad){
				return {
					'float':'left','height':(imageHeight+20)+'px','margin':'0 '+(strPad+8)+'px '+(strPad+8)+'px 0',
					'padding':(strPad*2)+'px','width':'160px'
				};
			}
		};
	
		/*
			object: 	 ClsMuskokaSpaForPets->Content
			description: defines the content for the msp website.
						 tested and passed.
		*/
		var Content={
			muskokaImageDir:Lib.muskokaImageDir(Lib.imageDir),
			pawThumb:function(){
				return '<img src="'+this.muskokaImageDir+'paw.gif" alt="hmmm... a paw!" class="paw-thumb" />';
			},
			
			addImage:function(imageSrc,altText){
				return '<img src="'+this.muskokaImageDir+imageSrc+'" alt="'+altText+'" />';
			},
			
			getContent:function(properties){				
				var image=(properties.imageSrc && properties.altText)?this.addImage(properties.imageSrc,properties.altText):'';
				return image+properties.content.join('');
			},
			
			petPickupAndDropoffTimes:function(){
				return '<b class="color-lime">Pet pickup and drop-off times</b><br /><br />'+
						'<b>Sunday, Monday, Tuesday</b><ul><li>Morning - 8:00AM to 11.00AM</li>'+
						'<li>Afternoon - 3:00PM to 5.30PM</li></ul>'+
						'<b>Wednesday to Saturday</b><ul><li>All day - 8:00AM to 5.30PM</li></ul>';
			},
			
			price:function(mode){
				cost=(mode && mode=='Daycare')?'Price $20.00 per day (plus GST)':'Price $28.00 per night (plus GST)';
				return '<br /><b class="color-lime">'+cost+'</b>';
			},
			
			leftContent:function(key){
				var content='<div>', image='';
				
				switch(key){
					case 'Home':
						content+=this.getContent({
							imageSrc:'muskoka_3.jpg',
							altText:'pets playing...',
							content:[
								'<b>The Muskoka spa for pets</b> is a boarding, grooming and daycare facility for dogs,',
								' located in <b class="color-lime">Bracebridge</b> in the heart of the Muskoka area.<br /><br />',
								'We take pride in providing a fun, safe and caring environment where your pet ',
								'will enjoy <b class="color-lime">both human and canine companionship!</b>'
							]
						});
					break;
					case 'Location':
						content+=this.getContent({
							imageSrc:'muskoka_12.jpg',
							altText:'at muskoka spa for pets...',
							content:[
								'<b>The Muskoka spa for pets</b> is situated amongst fifty acres of',
								' breathtakingly-beautiful landscape that is uniquely Muskoka.<br /><br />',
								this.pawThumb()
							]
						});
					break;
					case 'Grooming':
						content+=this.getContent({
							imageSrc:'muskoka_13.jpg',
							altText:'your pet at daycare!',
							content:[
								'<b>We offer full service grooming</b> for all breeds.<br /><br />Our full spa service includes',
								' nail trim, glands, ear-cleaning, deodorizing bath with gentle natural products,',
								' undercoat brush and blowout, hand drying, styling to owners\' specifications, puppy cologne,',
								' stylish bandana, <b class="color-lime">and a bag of yummy cookies to take home!</b>'
							]
						});
					break;
					case 'Boarding':
						content+=this.getContent({
							imageSrc:'muskoka_10.jpg',
							altText:'pets having a jolly time!',
							content:[
								'At the <b>Muskoka spa for pets</b>, we are pleased to offer a social pack environment for your furry friend.<br /><br />',
								'Our new facility <b class="color-lime">offers private rooms for meals and bedtime</b>, ', 
								'as well as a large indoor and fenced outdoor play areas.<br /><br />',
								'<b>The building has radiant floor heating</b> to keep pets toasty warm',
								' in the cool months and is air-conditioned in the summer.',
								'<br /><br />As well, every room has <b>natural light and fresh air exchange!</b>'
							]
						});
					break;
					case 'Daycare':
						content+=this.getContent({
							imageSrc:'muskoka_4.jpg',
							altText:'pets at daycare...',
							content:[
								'<b>Our daycare service</b> has become quite popular with many dogs visiting regularly throughout the week.<br /><br />',
								'<b class="color-lime">It is a great alternative</b> to leaving your pet at home',
								' while away at work or travelling for the day!',
								'<p>Your furry friend will have an exhausting day <b>socializing with other dogs</b> (outdoors',
								' in our safely-fenced area, as well as indoors in our large play room)</p>'
							]
						});
					break;
					case 'Contact Us':
						content+=this.getContent({
							content:[
								'<div class="contact-info"><b>Phone:</b> (705) 646-0023',
								'<br /><br /><b>Email:</b> <a href="mailto:info@muskokaspaforpets.com">info@muskokaspaforpets.com</a></div>',
								'<br /><h5>We\'d love to hear from you!</h5>'
							]
						});
					break;
				}
				return content+'</div>';
			},//Content.leftContent() ends here...
			
			rightPanelDisplay:function(properties){						
				var imageSrc='', output='', ospca='<a href="http://www.tourparrysound.com" target="_blank">OSPCA</a>',
					proudSupporters='<p>'+this.pawThumb()+
									' We are proud supporters of the <b>Bracebridge</b> '+ospca+'</p>';
				
				if(properties.mode=='image'){
					switch(properties.key){
						case 'Location':   imageSrc='muskoka_11.jpg'; break;
						case 'Grooming':   imageSrc='muskoka_9.jpg'; break;
						case 'Daycare':    imageSrc='muskoka_6.jpg'; break;
						case 'Contact Us': imageSrc='muskoka_3.jpg'; break;
						default:           imageSrc='muskoka_1.jpg'; break;
					}
					output='<img src="'+this.muskokaImageDir+imageSrc+'" alt="hmmm... comfy-comfy!" />';
					output+=(properties.key=='Home' || properties.key=='Location')?proudSupporters:'';
				}
				else if(properties.mode=='text'){
					switch(properties.key){
						case 'Location':   output+=''; break;
						case 'Grooming':    break;
						case 'Boarding': 
							output+=this.getContent({
								content:[
									'<div class="right-panel-text">',
									this.petPickupAndDropoffTimes(),
									'<b>What to bring...</b><ul><li>Proof of vaccinations</li>',
									'<li>Your pets regular foods and treats</li><li>Toys for your dog\'s room</li>',
									'<li>You may choose to bring a bed (if not, we have many here...)</li>',
									'<li>Any medication your pet is on. <i>There is no charge for administering medication</i></li></ul>',
									'<i class="color-lime">please note: boarders staying 2 nights or less <b>will be charged',
									' a $10.00 daycare fee</b> when checking out after 11:00AM</i>',
									'</div>'
								]
							});   
						break;
						case 'Daycare': 
							output+=this.getContent({
								content:['<div class="right-panel-text">'+this.petPickupAndDropoffTimes()+'</div>']
							});   
						break;
					}
				}
				
				return output;
			},//Content.rightPanelDisplay() ends here...
			
			rightContent:function(key){
				var content='<div>', image='';
				switch(key){
					case 'Home':
						content+=this.getContent({
							imageSrc:'muskoka_2.jpg',
							altText:'pets at daycare...',
							content:[
								'<h5>Our services include...</h5><b>Boarding:</b><br />Your pet will spend days playing with other ',
								'four-legged guests, and evenings snuggled up in their cozy private room.<br /><br />',
								"<b>Daycare:</b><br />It's a great way to keep your dog active and social!",
								'<p><b>All breed dog grooming:</b><br />An important part of your dog\'s health and well-being!</p>'
							]
						});
					break;
					case 'Location':
						content+=this.getContent({
							imageSrc:'muskoka_7.jpg',
							altText:'at muskoka spa for pets...',
							content:[
								'Our new facility is <b>conveniently located</b> approximately 3km from Hwy. 11 and Hwy. 118',
								' in Bracebridge, Ontario at <b class="color-lime">1918 Muskoka Beach Road.</b>'
							]
						});
					break;
					case 'Grooming':
						content+=this.getContent({
							content:[
								'<div class="right-panel-text">',
								'<b>Price</b><ul><li>small - $50.00</li><li>medium - $65.00</li>',
								'<li>large - $80.00</li><li>extra-large - $100.00 to $120.00</li></ul>',
								'<b>Bath and Dry only</b><ul><li>small - $30.00</li><li>medium - $35.00</li>',
								'<li>large - $40.00</li><li>extra-large - $45.00</li></ul>',
								'<b>Nails - $15.00</b>',
								'<p>Pending coat condition, additional charges may apply</p>',
								'<p><i class="color-lime">all prices plus GST</i></p>',
								'</div>'
							]
						}); 
					break;
					case 'Boarding':
						content+=this.getContent({
							imageSrc:'muskoka_5.jpg',
							altText:'we are well equipped to take great care of your pet!',
							content:[
								'<b>Your pet will enjoy playing all day</b> with other four-legged guests and their supervisor, ',
								'and then resting comfortably in their rooms to the sound of classical music at night!<br /><br />',
								this.price(),
								'<br />All pets must be spayed or neutered and <b>up-to-date on vaccinations</b> including bordatella (kennel cough).',
								'<p>We also recommend that your pet is on flea prevention.</p>'
							]
						});
					break;
					case 'Daycare':
						content+=this.getContent({
							imageSrc:'muskoka_8.jpg',
							altText:'nice, warm cosy room for your pet!',
							content:[
								'<b>Your pets</b> will also enjoy games of tug-a-war, fetch, and frisby with their supervisor.<br />',
								'<br /><b>At the end of the day,</b> your pet will be happy to rest quietly at your feet or snuggle into bed!',
								'<p style="text-align:center;">'+this.price('Daycare')+'</p>'
							]
						});
					break;
					case 'Contact Us':
						content+=this.getContent({
							content:[
								'<div class="contact-info"><b>Our address is:</b><br /><br />',
								'<b class="color-lime">Muskoka Spa for Pets</b><br />',
								'1918 Muskoka Beach Road<br />Bracebridge, Ontario<br />P1P 1R1</div>'
							]
						});
					break;
				}
				return content+'</div>';
			},//Content.rightContent() ends here...
			
			pageBody:function(key){
				var pageCaption=(key=='Home')?'Welcome to Our Website!':key+'...';
				var containerToSplit=$cat('.part-page-body').html('<h2>'+pageCaption+
										  '</h2><div class="page-content"></div>').find('.page-content');
				cat.divide({container:containerToSplit,widthLeft:70});
				$cat('.page-content .left-panel').html(this.leftContent(key));
				$cat('.page-content .left-panel').append(this.rightContent(key));
				var mode=(key=='Boarding' || key=='Daycare')?'text':'image';
				$cat('.page-content .right-panel').html(this.rightPanelDisplay({key:key,mode:mode}));
			},//Content.pageBody() ends here...
			
			pageHeader:function(Lib){
				var logo=cat.transform({mode:'img',arrayToTransform:['logo.gif'],imgDir:this.muskokaImageDir});
				$cat('.part-page-header').html(logo);
			}//Content.pageHeader() ends here...
		};//Content ends here...
		
		/*
			object: 	 Styles
			description: defines the styles for the msp website.
						 tested and passed.
		*/
		var Styles={
			imageDir:Lib.imageDir,
			muskokaImageDir:Lib.muskokaImageDir(Lib.imageDir),
			darkBackgroundCss:Lib.darkBackgroundCss(),
			strPad:Lib.strPad,
			borderColor:Lib.borderColor,
			containerCss:Lib.containerCss,
			fade:Lib.fade,
			pageBodyCss:Lib.pageBodyCss,
			containerIndentCss:Lib.containerIndentCss(Lib.strPad),
			headerColor:Lib.headerColor,
			thumbnailImageCss:Lib.thumbnailImageCss(Lib.imageHeight,Lib.strPad),
			mainImageCss:Lib.mainImageCss(Lib.imageHeight),
			logoCss:Lib.logoCss,
			linkBorderColor:Lib.linkBorderColor(Lib.borderColor),
			
			/*
				method: 	 Styles.documentBody()
				description: generates the styles for the document body.
							 tested and passed.
			*/
			documentBody:function(){
				$cat(document.body).css(this.darkBackgroundCss)
					.find('a:not(".menu-item")').css('color','#81A7E8')
						.hover(function(){$cat(this).css({'color':'#F20000','text-decoration':'none'});},
							   function(){$cat(this).css({'color':'#81A7E8','text-decoration':'underline'});});
			},//Styles.documentBody() ends here...
			
			/*
				method: 	 Styles.capping()
				description: generates the styles for the document's capping.
							 tested and passed.
			*/
			capping:function(){
				with($cat('.capping')){
					html('').css(cat.border({color:this.borderColor}));
					css({'background':'url('+this.imageDir+'template-6.png)','padding':(this.strPad*2-1)+'px'});
				}
			},//Styles.capping() ends here...
			
			/*
				method: 	 Styles.container()
				description: generates the styles for the document's container.
							 tested and passed.
			*/
			container:function(){
				with($cat('.container')){
					animate(this.containerCss,cat.fadeTime);
					css('margin','0 auto');
				}
			},//Styles.container() ends here...
			
			/*
				method: 	 Styles.pageBody()
				description: generates the styles for the document's page-body.
							 tested and passed.
			*/
			pageBody:function(){
				with($cat('.part-page-body')){
					(this.fade)?css(this.pageBodyCss):animate(this.pageBodyCss,cat.fadeTime);
					css(this.darkBackgroundCss);
					css(this.containerIndentCss);
					css(cat.border({mode:'left-right',color:this.borderColor}));
					css('padding',(this.strPad+5)+'px');
					find(':header').css({'color':this.headerColor});
					find('h5').css({'margin':(this.strPad*+5)+'px','text-align':'center'});
					find('b').css('color','#FF3333');
					find('.page-content').hide().fadeIn(cat.fadeTime*2);
					find('.page-content .left-panel div:first').css({'float':'left','width':'48%'});
					find('.page-content .left-panel div:last').css({'float':'right','width':'48%'});
					find('.page-content .left-panel div').css({'padding':(this.strPad*2)+'px'});
					find('img:not(".main-image")').css(this.thumbnailImageCss);
					find('.page-content .right-panel img:first').css(this.mainImageCss);
					find('.page-content .paw-thumb').css({'height':'15px','width':'20px'});
					find('img, .right-panel-text').css(cat.border({color:this.borderColor}));
					find('.color-lime').css({'color':this.headerColor});
					find('.right-panel-text').css({'padding':(this.strPad+3)+'px','text-align':'center'});
					find('ul').css({'list-style':'square','margin-top':(this.strPad+1)+'px','text-align':'left'});
					find('.contact-info').css('text-align','center');
					if(this.fade)hide().fadeIn(cat.fadeTime);
				}
			},//Styles.pageBody() ends here...
			
			/*
				method: 	 Styles.pageHeader()
				description: generates the styles for the document's page-header.
							 tested and passed.
			*/
			pageHeader:function(){
				with($cat('.part-page-header')){
					css(this.containerIndentCss);
					css(cat.border({mode:'left-right',color:this.borderColor}));
				}
				$cat('.part-page-header img').css(this.logoCss).hide().fadeIn(cat.fadeTime);
			},//Styles.pageHeader() ends here...
			
			pageMenu:function(){
				cat.menu({
					container:'.container-page-menu',strBackground:'url('+this.muskokaImageDir+'background_body.png)',
					strPadding:this.strPad,strBorderColor:this.borderColor,
					strLinkBorderColor:this.linkBorderColor,imageDir:this.imageDir,color:'black'
				});
			}//Styles.pageMenu() ends here...
		};//Styles ends here...
	
		/*
			object: 	 ClsMuskokaSpaForPets->Functionality
			description: defines the content for the msp website.
						 tested and passed.
		*/
		var Functionality={
			menuItemOn:Lib.menuItemOn(Lib.headerColor),
			pageMenu:function(){
				var menuItemOn=this.menuItemOn;
				$cat('.menu-item:first').css(menuItemOn).addClass('current');
				
				$cat('.menu-item').click(function(){
					var menuItems=$cat('.menu-item'), menuItem=$cat(this), currentBackground=menuItem.css('background'),
						menuItemOff={'background':currentBackground};					
					
					cat.highlight({
						mode:'menu-item',menuItems:menuItems,menuItem:menuItem,
						menuItemOn:menuItemOn,menuItemOff:menuItemOff,
						currentItemClassName:'menu-item current'
					});
					Lib.processMenuItem(menuItem.text());
				});
			}//ClsMuskokaSpaForPets->Functionality.pageMenu() ends here...
		};//ClsMuskokaSpaForPets->Functionality ends here...
		
		cat.bodyCss.fontSize=14;			
		cat.website(key='Home',Lib,Content,Styles,Functionality);
	}//constructor ends here...
});//ClsMuskokaSpaForPets ends here...