/* Epione */
var COOKIE_NAME = 'epioneChatBox';
var ADDITIONAL_COOKIE_NAME = 'additional';
var pathname = window.location.pathname;
var options = { path: '/', expires: 1 };
function autoStart(){
	$("#botoxSlide").tabs().play()
}
function isNumeric(value) {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}
function illegalChar(value){
	if (value == null || !value.toString().match(/[`~!@#$%^&*()_+|"]/)) return false;
	return true
}
$(function() { 
    /* $(".trigger").tooltip(); */	
	if(pathname == '/'){
	  $("#botoxSlide").tabs("#botoxSlideContent > div", { 
   
		  effect: 'fade',  
		  rotate: true,
		  speed: 5000
   
	  }).slideshow();	
	  setInterval(function(){autoStart()}, 5000);	
	}	
	if($.cookie(COOKIE_NAME) == null || $.cookie(COOKIE_NAME) == 'chatBoxDefault'){
		$('#welcomeMessage').hide();
		$.cookie(COOKIE_NAME, 'chatBoxDefault', options);
		setTimeout(function(){ 
			$('#welcomeMessage').fadeIn()
		},4000);
	}		
	if($.cookie(COOKIE_NAME) == 'chatBox'){
		$('#welcomeMessage').css('display','none');
	}
	$('a#closeChatBox').click(function() {							   
		$.cookie(COOKIE_NAME, 'chatBox', options);
		$('#welcomeMessage').fadeOut(1000);
		return false;	
	});		
	$("#icpsignup5799 :input").tooltip({ 
		// place tooltip on the right edge 
		position: "center left", 		
		// a little tweaking of the position 
		offset: [2, -2], 		
		// use the built-in fadeIn/fadeOut effect 
		effect: "fade", 		
		// custom opacity setting 
		opacity: 0.9, 		
		// use this single tooltip element 
		tip: '.tooltip' 					
	});		
	$("#giftTerms").tooltip({ 
		// place tooltip on the right edge 
		position: "center left", 		
		// a little tweaking of the position 
		offset: [2, -2], 		
		// use the built-in fadeIn/fadeOut effect 
		effect: "fade", 		
		// custom opacity setting 
		opacity: 0.9, 		
		// use this single tooltip element 
		tip: '.tooltip' 					
	});		
	if($.cookie(ADDITIONAL_COOKIE_NAME) == 'doctorTerms'){	 
		  $("#searchIt").click(function () {
			  var botoxsearch = $('input#botoxsearch').val();
			
			  if(botoxsearch == '' || botoxsearch == 'Zip Code...'){
				  alert('Please enter your search');	
				  return false;
			  }
			  if(botoxsearch.length <= 3){
				  alert('Your input is too short. ex. 90210');	
				  return false;
			  }
			  if(illegalChar(botoxsearch)){
				  alert('Illegal Characters. Only Letters and Numbers are allowed');	
				  return false;
			  }											 			 
		  });
		  if($.browser.msie){
			$("#botoxsearch").keypress(function(e){
				  if (e.keyCode == '13') {
					  var botoxsearch = $('input#botoxsearch').val();
			  
					  if(botoxsearch == '' || botoxsearch == 'Zip Code...'){
						  alert('Please enter your search');	
						  return false;
					  }
					  if(botoxsearch.length <= 3){
						  alert('Your input is too short. ex. 90210');	
						  return false;
					  }
					  if(illegalChar(botoxsearch)){
						  alert('Illegal Characters. Only Letters and Numbers are allowed');	
						  return false;
					  }				  
				  }
			 });
		  }
	} else {
	  $("#searchIt").click(function () {
		  var botoxsearch = $('input#botoxsearch').val();
		
		  if(botoxsearch == '' || botoxsearch == 'Zip Code...'){
			  alert('Please enter your search');	
			  return false;
		  }
		  if(botoxsearch.length <= 3){
			  alert('Your input is too short. ex. 90210');	
			  return false;
		  }
		  if(illegalChar(botoxsearch)){
			  alert('Illegal Characters. Only Letters and Numbers are allowed');	
			  return false;
		  }											 
		  if (confirm('I understand that the physicians whose names appear in the following directory are in NO way affiliated with Epione Medical Corporation, its shareholders, or employees.  This list is provided for informational purposes only and may not contain the name of every physician to whom the search criteria may apply. I have read and accept the Terms of Use.')) {
		   $.cookie(ADDITIONAL_COOKIE_NAME, 'doctorTerms', options);
		   return true;
		  }else{
		  return false;	
		  }
	  });
	  if($.browser.msie){
		$("#botoxsearch").keypress(function(e){
			  if (e.keyCode == '13') {
				  var botoxsearch = $('input#botoxsearch').val();
		  
				  if(botoxsearch == '' || botoxsearch == 'Zip Code...'){
					  alert('Please enter your search');	
					  return false;
				  }
				  if(botoxsearch.length <= 3){
					  alert('Your input is too short. ex. 90210');	
					  return false;
				  }
				  if(illegalChar(botoxsearch)){
					  alert('Illegal Characters. Only Letters and Numbers are allowed');	
					  return false;
				  }
				  if (confirm('I understand that the physicians whose names appear in the following directory are in NO way affiliated with Epione Medical Corporation, its shareholders, or employees.  This list is provided for informational purposes only and may not contain the name of every physician to whom the search criteria may apply. I have read and accept the Terms of Use.')) {
				   $.cookie(ADDITIONAL_COOKIE_NAME, 'doctorTerms', options);
				   return true;
				  }else{
				  return false;	
				  }
			  }
		 });
	  }
	}
});

