$(document).ready(function(){
	$('#browse-select').bind('change', function() {
		if($(this).find('option:selected').val() != "Browse by Product") {
			$.fn.form.redirect($(this).find('option:selected').val());
		}
	});
 	$('.questions-feature label').labelOver();
	$('#top-search label').labelOver();

                $('.browse-select').sSelect({ddMaxheight:'300px'});

                //set max height
                $('#my-dropdownCountries').sSelect({ddMaxHeight: '300px'});

                //set value on click
                $('#setVal').click(function(){
                    $('#my-dropdown5').getSetSSValue('4');
                });

                //get value on click
                $('#getVal').click(function(){
                    alert('The value is: '+$('#my-dropdown5').getSetSSValue());
                });

                //alert change event
                $('#my-dropdownChange').sSelect().change(function(){alert('changed')});

                //add options to select and update
                $('#addOptions').click(function(){
                    $('#my-dropdown6').append('<option value="newOpt">New Option</option>').resetSS();
                });
				
				
	$('a.one-molding').bind('click', function(){
    	$("#dialog").clone().insertAfter('#dialog').attr('id', 'one-molding-install');
        var html = '<p><a id="video1" style="display: block; width: 640px; height: 520px;" href="../../../../flash/batten_1pc_web.flv"><img src="../../../../images/video_screen_one_piece.png" alt="One Piece Molding Installation" width="638" height="523" /></a></p>';
        
		$("#one-molding-install").dialog({
                            modal: true,
                            draggable: false,
                            resizable: false,
                            zIndex: 100000,
                            width: 668,
                            minHeight: 553,
                            title: 'One Piece Molding Install',
                            open: function() {
                                $(this).html(html);
                                flowplayer("video1", "/flash/flowplayer-3.2.2.swf",{clip: {autoPlay: true}});
                            },
                            close: function() {
                                $(this).dialog('destroy');
                                $(this).remove();
                            }
                        });
						
    });
    
    $('a.two-molding').bind('click', function(){
    	$("#dialog").clone().insertAfter('#dialog').attr('id', 'two-molding-install');
        var html = '<p><a id="video2" style="display: block; width: 640px; height: 520px;" href="../../../../flash/batten_2pc_web.flv"><img src="../../../../images/video_screen_two_piece.png" alt="Two Piece Molding Installation" width="638" height="523" /></a></p>';
        
		$("#two-molding-install").dialog({
                            modal: true,
                            draggable: false,
                            resizable: false,
                            zIndex: 100000,
                            width: 668,
                            minHeight: 553,
                            title: 'Two Piece Molding Install',
                            open: function() {
                                $(this).html(html);
                                flowplayer("video2", "/flash/flowplayer-3.2.2.swf",{clip: {autoPlay: false}});
                            },
                            close: function() {
                                $(this).dialog('destroy');
                                $(this).remove();
                            }
                        });
						
    });
});

jQuery.fn.labelOver = function(overClass) {
	return this.each(function(){
		var label = jQuery(this);
		var f = label.attr('for');
		if (f) {
			var input = jQuery('#' + f);

			this.hide = function() {label.css({ textIndent: -10000 });};

			this.show = function() {
				if (input.val() == '') {
					  label.css({ textIndent: 0 });
				}
			};

			// handlers
			input.focus(this.hide);
			input.blur(this.show);
			label.addClass(overClass).click(function(){ input.focus(); });

			if (input.val() != '') {
				this.hide();
			}
		}
	});
};

