
/*
========================================================
============ Forms- Validator and functions ============ 
========================================================

Files Required: None
Forms should be mapped in http://admin.plasticsurgerystudios.com/

-------------------------------------------------- */

// CLEAR FORM FUNCTION

function clearText(thefield) {
if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} function replaceText(thefield) {
if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

// FORM VALIDATOR

function MM_validateForm() { //v4.0
	if (document.getElementById){
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
			if (val) { nm=val.name; if ((val=val.value)!="") {
				if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
				} else if (test!='R') { num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
						min=test.substring(8,p); max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
	} if (errors) alert('The following error(s) occurred:\n'+errors);
	document.MM_returnValue = (errors == '');
} }


/*
	reflection.js for jQuery v1.03
	(c) 2006-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function(a){a.fn.extend({reflect:function(b){b=a.extend({height:1/3,opacity:0.5},b);return this.unreflect().each(function(){var c=this;if(/^img$/i.test(c.tagName)){function d(){var g=c.width,f=c.height,l,i,m,h,k;i=Math.floor((b.height>1)?Math.min(f,b.height):f*b.height);if(a.browser.msie){l=a("<img />").attr("src",c.src).css({width:g,height:f,marginBottom:i-f,filter:"flipv progid:DXImageTransform.Microsoft.Alpha(opacity="+(b.opacity*100)+", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy="+(i/f*100)+")"})[0]}else{l=a("<canvas />")[0];if(!l.getContext){return}h=l.getContext("2d");try{a(l).attr({width:g,height:i});h.save();h.translate(0,f-1);h.scale(1,-1);h.drawImage(c,0,0,g,f);h.restore();h.globalCompositeOperation="destination-out";k=h.createLinearGradient(0,0,0,i);k.addColorStop(0,"rgba(255, 255, 255, "+(1-b.opacity)+")");k.addColorStop(1,"rgba(255, 255, 255, 1.0)");h.fillStyle=k;h.rect(0,0,g,i);h.fill()}catch(j){return}}a(l).css({display:"block",border:0});m=a(/^a$/i.test(c.parentNode.tagName)?"<span />":"<div />").insertAfter(c).append([c,l])[0];m.className=c.className;a.data(c,"reflected",m.style.cssText=c.style.cssText);a(m).css({width:g,height:f+i,overflow:"hidden"});c.style.cssText="display: block; border: 0px";c.className="reflected"}if(c.complete){d()}else{a(c).load(d)}}})},unreflect:function(){return this.unbind("load").each(function(){var c=this,b=a.data(this,"reflected"),d;if(b!==undefined){d=c.parentNode;c.className=d.className;c.style.cssText=b;a.removeData(c,"reflected");d.parentNode.replaceChild(c,d)}})}})})(jQuery);





$(document).ready(function() {
	
	$(window).scroll(function(){
		//help
		if($(window).scrollTop() > 1600) {
			$('.TestimonialDarkNav').css('top', '0px');
			$('.TestimonialDarkNav').css('left', '50%');
			$('.TestimonialDarkNav').css('margin-left', '-270px');
			$('.TestimonialDarkNav').css('position', 'fixed');
		}
		else {
			$('.TestimonialDarkNav').css('position', 'absolute');
			$('.TestimonialDarkNav').css('top', '1600px');
			$('.TestimonialDarkNav').css('left', '50%');
			$('.TestimonialDarkNav').css('margin-left', '-270px');
		}
		
	});

//$('.VoiceTestimonials').remove();

/* 
	============================================================
	============ Multi-Tiered Dropdowns - Superfish ============ 
	============================================================
	
	Files Required: 
	jquery-1.3.2.min.js
	superfish.js
	
	-------------------------------------------------- */
	
	

		$("ul.MainNav").superfish({
			delay:         100,                // 700 the delay in milliseconds that the mouse can remain outside a submenu without it closing 
			animation:     {opacity:'show',height:'show'},   // an object equivalent to first parameter of jQuery’s .animate() method 
			speed:         100,           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
			autoArrows:    true                // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
		});



		$("ul.ProcDropdown").superfish({
			delay:         100,                // 700 the delay in milliseconds that the mouse can remain outside a submenu without it closing 
			animation:     {opacity:'show'},   // an object equivalent to first parameter of jQuery’s .animate() method 
			speed:         100,           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
			autoArrows:    true                // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
		});




	
	

/* 
============================================================
=================== Light box - FancyBox ===================
============================================================

Files Required: 
jquery-1.3.2.min.js
jquery.fancybox-1.3.1.js


-------------------------------------------------- */
	
	$('a[href*="images/"]').fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200 
		});
	
	
	
	$("a.iframe").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'type'				: 'iframe'
				});
		
	$("a.Inline").fancybox({
					'autoDimensions'    : true,
					'autoScale'			: true,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic'
				});
	
	
	
	

	
/* 
============================================================
============ Image Slideshow- Fading In and Out ============ 
============================================================

Files Required: 
jquery-1.3.2.min.js
jquery.cycle.all.js

-------------------------------------------------- */
	
	$(".MediaLoop").cycle({ 
		fx: "fade",			/* controls transition effect -- see below for more effects */
		timeout: 2000,		/* milliseconds between slide transitions  */	
		speed:  1000,		/* controls speed of transition */	
		pause: 1
	
	});



/* 
============================================================
========================== Tabs ============================
============================================================

-------------------------------------------------- */
	
	var ts = $('.TabSection');	
	var tl = $('.TabLinks a'); var tlFirst = tl.filter(':first-child');
	var tc = $('.TabContent');	
	var tls = 'tabSelected'; var tlsClass = '.'+tls; 
	var tds = 'tabDivs';
	var dur = 400;
	
	tc.css({'position':'relative'});
	tl.each(function(){
			href = $(this).attr('href');
			$(href).hide().css({'position': 'absolute', 'top':'0', 'left':'0'}).addClass(tds);
			$(this).filter(':last-child').addClass('Last');
		});
	tl.parent().append('<br class="Clear" />');
	
	if(tlFirst){
		tlFirst.each(function(){
			href = $(this).attr('href');
			tlFirst.addClass(tls);
			$(href).show();
		});
		
	}
	
	
	tl.click(function(){
			selected = $(this).siblings(tlsClass);
			selectHref= selected.attr('href');
			thisHref = $(this).attr('href');
			
			selected.removeClass(tls);
			$(selectHref).fadeOut(dur);
			$(this).addClass(tls);
			$(thisHref).delay(dur/1.5).fadeIn(dur);
			
			if ($(this).hasClass(tls)){return false;}//Stops jumping
		});
	



/* 
============================================================
======================= ScrollingTo ========================
============================================================

-------------------------------------------------- */

	
	$('.MiniNav a').ScrollingTo();
	$('.Top').ScrollingTop();
	
	

/* 
============================================================
========================== Misc ============================
============================================================

-------------------------------------------------- */

	/* DropDown List Arrows */
	$('.ProcDropdown ul div li').prepend('<span>&raquo;</span>');	
	$('.ProcDropdown ul div li:nth-child(3n+0)').addClass('Last').after('<br clear="all" />');
	$('.ProcDropdown ul h3:first').addClass('First');
	
	
	
	
	//Search Button Value set to nothing
	$('.search_button').val('');
	
	
	
	
	// Testimonial Sorting
	$('#DoubleColT').children('.TestimonialBox:even').addClass('TestimonialLeft');
	$('#DoubleColT').children('.TestimonialBox:odd').addClass('TestimonialRight').after('<br class="Clear" /><hr/>');
	
	
		
	

});	// End Document.ready function





$(window).load(function (){

	/* 
	============================================================
	======================= Reflections ========================
	============================================================
	
	-------------------------------------------------- */


	$("#PatientList img").reflect({
		opacity:0.2,height:0.5
	}).parent().css({'float':'left','padding-right':'15px'});

	$('#PatientList li').contents().filter(function(){return this.nodeType == 3;}).wrap('<span />').end().end().append('<br class="Clear"/>');

		$("img.ImplantStyles").reflect({
		opacity:0.5,height:0.2
	});

    $("img.ImplantStyles2").reflect({
		opacity:0.5,height:0.5
	});
	
	$("img.ImplantStyles3").reflect({
		opacity:0.5,height:0.1
	});
	
	$("ImplantStyles2").reflect({
		opacity:0.5,height:0.5
	});
	
	$(".ImgReflect").reflect({
		opacity:0.5,height:0.2
	}).parent().css({'float':'left','padding-right':'15px'});


});



