// Phone Field Tab Sequence: moves the user from one phone field to the next without using the TAB
function WireAutoTab(CurrentElementID, NextElementID, FieldLength) {
    //Get a reference to the two elements in the tab sequence.
    var CurrentElement = $('#' + CurrentElementID);
    var NextElement = $('#' + NextElementID);
 
    CurrentElement.keyup(function(e) {
        //Retrieve which key was pressed.
        var KeyID = (window.event) ? event.keyCode : e.keyCode;
 
        //If the user has filled the textbox to the given length and
        //the user just pressed a number or letter, then move the
        //cursor to the next element in the tab sequence.   
        if (CurrentElement.val().length >= FieldLength
            && ((KeyID >= 48 && KeyID <= 90) ||
            (KeyID >= 96 && KeyID <= 105)))
            NextElement.focus();
    });
}
    $(document).ready(function() {
        WireAutoTab('uc$TextBoxPhone1',
            'uc$TextBoxPhone2', 3);
        WireAutoTab('uc$TextBoxPhone2',
            'uc$TextBoxPhone3', 3);
        WireAutoTab('uc$TextBoxPhone3',
            'uc_TextBoxEmail', 4);
    });
	
var is_flash_movie=false;
var current_modal_id=false;

$(document).ready(function() {  
	//select all the a tag with name equal to modal
	
	$('*[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
		
		if ($.browser.msie && $.browser.version.substr(0,1)<7) { $('select').hide(); }
		//Get the window height and width
		 if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
		
		var winH = yScroll;
		var winW = $(window).width();	
	  
		//Set the popup window to center
		$(id).css('top', winH+150);
		$(id).css('left', winW/2-$(id).width()/2);
		
		
		current_modal_id=id;
		$(id).fadeIn(1000,after_fade_in);
		if(id=="#get_clear_modal"){
			is_flash_movie=true;
		}else{
			is_flash_movie=false;
		}
				
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen
		$('.mask').css({'width':maskWidth,'height':maskHeight});
		
		
		
		
		//transition effect             
		$('.mask').fadeIn(500);
		$('.mask').fadeTo("fast",0.4);  
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('.mask').hide();
		$('.window').removeShadow();
		$('.window').hide();
		
		$('select').show();
		stop_modal_video();
	});             
	
	//if mask is clicked
	$('.mask').click(function () {
		$(this).hide();
		$('.window').removeShadow();
		$('.window').hide();
		$('select').show();
		
		stop_modal_video();
	});  
	
        
});	

function open_modal_from_flash(){
	
		
		//set explicitly in this case
		var id = "#what_comes_in_the_kit_modal";
		
		if ($.browser.msie && $.browser.version.substr(0,1)<7) { $('select').hide(); }
		//Get the window height and width
		 if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
		
		var winH = yScroll;
		var winW = $(window).width();	
	  
		//Set the popup window to center
		$(id).css('top', winH+150);
		$(id).css('left', winW/2-$(id).width()/2);
		
		
		current_modal_id=id;
		$(id).fadeIn(1000,after_fade_in);
		if(id=="#get_clear_modal"){
			is_flash_movie=true;
		}else{
			is_flash_movie=false;
		}
				
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen
		$('.mask').css({'width':maskWidth,'height':maskHeight});
		
		
		
		
		//transition effect             
		$('.mask').fadeIn(500);
		$('.mask').fadeTo("fast",0.4);  
	
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('.mask').hide();
		$('.window').removeShadow();
		$('.window').hide();
		
		$('select').show();
		stop_modal_video();
	});             
	
	//if mask is clicked
	$('.mask').click(function () {
		$(this).hide();
		$('.window').removeShadow();
		$('.window').hide();
		$('select').show();
		
		stop_modal_video();
	}); 
	
}

function start_modal_video(){
	
}

function stop_modal_video(){
	
}

function after_fade_in(id){
	if(is_flash_movie){
		start_modal_video();
	}
	//dropshadow

	var shadow_options={left:-1, top:-1, blur:10, opacity:0.5, color:"black", swap:false};
	//$(id+' .dropshadow').dropShadow();
	//$(".dropshadow").dropShadow();
	//transition effect of window
	$(current_modal_id).dropShadow(shadow_options);
}
