/*********************************************************************************************************************************/
/* DOCUMENT READY CALLS **********************************************************************************************************/
/*********************************************************************************************************************************/
$(document).ready(function(){
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	/* EXTERNAL LINKS end *************************************************************/
	
	$('html').addClass('js');
	
	/*contact*/
	if($(".token").length >0){
		$.get("/public/token.php", function( txt ){
			$(".token").append('<input type="hidden" name="ts" value="' + txt + '">');
		});
	}
	/*contact*/

	/*SEARCH start ********************************************************************/
	$('#search input[type="text"]').val('Search');
	$('#search input[type="text"]').focus(function(){ if(this.value=='Search') { $(this).val('');} });
	$('#search input[type="text"]').blur(function(){ if(this.value =='') { $(this).val('Search');} });
	/*SEARCH end **********************************************************************/
	
	/* QUOTE form */
	$('#form-request-quote #fob-newspress input').click(function(){
		if( $(this).val()=='No' ){
			$('#other-address').slideDown();
		}else{
			$('#other-address').slideUp();
		}
	});
	
	$('#form-format input').click(function(){
		$text = $('#format_other_text');
		if( $(this).attr('id') == 'format_other_text'){
			$('#format_other').attr('checked','checked');
			$text.val($text.attr('data'));
		}else if($(this).attr('id') == 'format_other'){
			$text.val($text.attr('data')).focus();
		}else{
			if(!$text.attr('data')){
				$text.attr('data',$text.val());
			}
			$text.val('');
		}
	});	
	
	$('#folding_necessary input').click(function(){
		$qty = $('#folding_necessary_qty');
		if( $(this).attr('id') == 'folding_necessary_qty'){
			$('#folding_necessary_yes').attr('checked','checked');
			$qty.val($text.attr('data'));
		}else if($(this).attr('id') == 'folding_necessary_yes'){
			$qty.val($qty.attr('data')).focus();
		}else{
			if(!$qty.attr('data')){
				$qty.attr('data',$qty.val());
			}
			$qty.val('');
		}
	});
	$('#plate_changes input').click(function(){
		$qty = $('#plate_changes_qty');
		if( $(this).attr('id') == 'plate_changes_qty'){
			$('#plate_changes_yes').attr('checked','checked');
			$qty.val($text.attr('data'));
		}else if($(this).attr('id') == 'plate_changes_yes'){
			$qty.val($qty.attr('data')).focus();
		}else{
			if(!$qty.attr('data')){
				$qty.attr('data',$qty.val());
			}
			$qty.val('');
		}
	});
	
	/* QUOTE form */
	
	
}); //close document.ready

/*********************************************************************************************************************************/
/* DOCUMENT READY FUNCTIONS ******************************************************************************************************/
/*********************************************************************************************************************************/
Cufon.replace('#page-title');
