/* combine : /javascript/desktop/common/jdw_commonPageLoadFunctions.js*/
/* 
 * Capture the click event of all <a> tags with rel="modal" OR 
 * all <a> tags with an href urls containing request param "modal" 
 * with value "true" e.g. "/shop/warranties.jsp?modal=true"
 */ 
$(document).ready(function () {
	$(document).delegate("a","click",function(event){
	    var url = $(this).attr('href');
	    var fromBack = $(this).attr('modalBack') ? true : false;
	    var disableClose = $(this).attr('disableModalClose') ? true : false;
	    var showScrollbars = $(this).attr('showscrollbars') ? true : false;
	    
        if($(this).attr("jdwPrefix") != undefined) {
            $prefix = $(this).attr("jdwPrefix");
            var selectedColour = $("#" + $prefix + "_optionColourSelect").attr("value");
            var selectedSize = $("#" + $prefix + "_optionSizeSelect").attr("value");
            var selectedFitting = $("#" + $prefix + "_fittingSelect").attr("value");
            
            $sizeDrop =$("#" + $prefix + "_optionSize").children('option[value="'+ selectedSize +'"]');
            $colourDrop=$("#" + $prefix + "_optionColour").children('option[value="'+ selectedColour +'"]');
            $fittingDrop=$("#" + $prefix + "_fitting").children('option[value="'+ selectedFitting +'"]');
            $currentModalContent = $('div.quickViewModalContent');
        }
        
	    if( $(this).attr('rel')=='modal' || jQuery.url.setUrl(url).param('modal')=='true' ){
		    // prevent default behaviour on click event
		    event.preventDefault(); 
		    
		    var modalCallBack = function (data) {
   		        openModalJQ(data,url,fromBack,disableClose, showScrollbars);
       		};
       		modalCallBack.hideUpdatingOverlay = true;
       		
			ajaxGet(this, modalCallBack);		
		}
	});
});

$(document).ready(function() {
	$(document).delegate('a[rel="ajaxSubmit"]','click',function(event){
    	event.preventDefault();
    	
		var urlString = $(this).attr('href'); 	
    	if (urlString == null || urlString.length == 0) { 
			urlString = $(this).parents("form").attr('action');
		}
		
		performAjaxRequest(	urlString,
							eval($(this).attr('beforeSend')),
							eval($(this).attr('completeLoading')), 
							$(this).attr('dataType'),
							$(this).parents("form").serialize(), 
							eval($(this).attr('successLoading')), 
							eval($(this).attr('errorLoading')), 
							$(this).parents("form").prop('method'),
							getUniqueClass(this)
		);
	});
});

    
/*
 * The following functions need to run on each page load in order to maintain a user based 
 * set of footer logos. The logos below will be removed based on the customers account type,
 * and also whether 3d secure has been turned on or off.
 */

$(document).ready(function(){
	if (typeof removeCreditLogo != 'undefined') {
		if (removeCreditLogo == 'true') {
			$("div[id='personalAccount']").remove();
		}
	}
});
$(document).ready(function(){
	if (typeof display3DSecureFooterLogos != 'undefined') {
		if (display3DSecureFooterLogos == 'false') {
			$("img[title='Verified by Visa']").remove();
			$("img[title='MasterCard Securecode']").remove();
		}
	}
});/* complete : /javascript/desktop/common/jdw_commonPageLoadFunctions.js*/


