$(function(){
	
	/*add target blank to agr external links*/
	$('a[href="http://americanglassresearch.com"], a[href="http://www.americanglassresearch.com"] ').each(function(){
		$(this).attr ('target', '_blank');
	});
	$('#header input[type=text]').focus(function() {
        var v = $(this).val();
        $(this).val(v === this.defaultValue ? '' : v);
    }).blur(function() {
        var v = $(this).val();
        $(this).val(v.match(/^\s+$|^$/) ? this.defaultValue : v);
    });
	
	$("[rel='colorbox']").colorbox({ 
        width:"auto", 
        height: "auto", 
        rel: 'nofollow'                 
    });
    $("a[rel='colorboxVideo']").colorbox({ 
    	iframe: true, 
    	height: "500px", 
    	width: "750px", 
    	current: "Video {current} of {total}" });
    $('a[rel=htmltooltip]').tooltip({
 	   showURL: false,
 	   track: true,
 	   fade: 250,
 	   delay:0,
 	   opacity: 1
    });
    
    
    //This only portrays to the display order page
    var inputs = new Array();
    
    $('.alpha input').each(function(i){
    	inputs[i] = $(this).val();
    })
    
    $('.clearAll').click(function(){
    	$('.alpha input').each(function(){
    		var v = $(this).val();
            $(this).val(v === this.defaultValue ? '' : v);
    	})
    })
    $('.restoreAll').click(function(){
    	$('.alpha input').each(function(i){
    		$(this).val(inputs[i]);
    	})
    })
    $('.addOne').click(function(){
    	$('.alpha input').each(function(){
    		if($(this).val()=='')
    		{
    			$(this).val(0);
    		}
    		var v = parseInt($(this).val());
    		
            $(this).val(v+1);
    	})
    })
    $('.subtractOne').click(function(){
    	$('.alpha input').each(function(){
    		var v = parseInt($(this).val());
    		if(v=='')
    		{
    			$(this).val(0);
    		}
    		if(($(this).val()-1)<0)
    		{
    			$(this).val(0);
    		}
    		else
    		{
    			$(this).val(v-1);
    		}
    	})
    })
	
});
$(document).oneTime(50, function(){
	   
	$('#messageBox').fadeIn('slow');
	
	$('#messageBox').oneTime(3000, function(){
		
			$(this).fadeOut('slow');
		
		});

});
		
