jQuery.noConflict();
(function($) {
	$(function() {

        /*
        * @ The Sans
        * @ The Sans Black
        * @ The Sans Black Caps
        *
        */
//         Cufon.replace('#nav a', {
//             fontFamily: 'The Sans',
//                       color: '-linear-gradient(#000, #393939)',
//                       textShadow: '1px 2px rgba(255,255,255, 0.2)',
//                       hover: {
//                           color: '-linear-gradient(#fff, #dedede)',
//                           textShadow: '1px 2px rgba(0,0,0, 0.6)'
//                       }
//         });
        Cufon.replace('.block-title, .footer .block-content strong, .phone-no-mod, #news-mod h3, #enquiryForm h2, .one-page-checkout-progress h4, .one-page-checkout .head, .one-page-checkout .active .head', {
            fontFamily: 'The Sans Black Caps',
            hover: true
        });
        Cufon.replace('.page-title h1, /*.postTitle h2*/', {
            fontFamily: 'The Sans Black Caps',
            color: '-linear-gradient(#82a13f, 0.5=#9fc54d)',
            hover: true
        });
        Cufon.replace('.footer-container h5, .footer-container h6', {
            fontFamily: 'The Sans Black',
            hover: true
        });

        Cufon.replace('.block-subtitle, .home-info-mod .m', {
            fontFamily: 'The Sans',
            hover: true
        });
	//$('.home-top-data').corners();

        $('body').append('<div id="cms-overlay"></div>');
        $('.btn-inq').unbind().bind('click',function(c){
            c.preventDefault();

            attrHref = $(this).attr('href').split('#')[1];

            $('#cms-overlay').show();
            $('#'+attrHref).addClass('overlay').appendTo('#cms-overlay');
            $('.overlay').css({
                'display':  'block'
            }).prepend('<span id="close-overlay">Close window</span>');

            optWidth = parseInt($('#cms-overlay .overlay').innerWidth());
            optHeight = parseInt($('#cms-overlay .overlay').height());


            winWidth = parseInt($(window).width());
            winHeight = parseInt($(window).height());

            optLeft = winWidth>optWidth ?  (winWidth-optWidth)/2 : 0;
            optTop = winHeight>optHeight ? (winHeight-optHeight)/2 : 0;

            $('.overlay').css({
                'position': 'relative',
                              'margin':   '0',
                              'left': optLeft+'px',
                              'top':  optTop+'px'
            });

            Cufon.refresh();


            $('#close-overlay').unbind().bind('click',function(){
                $('#cms-overlay .overlay').hide();
                $('#cms-overlay').fadeOut();
            });

        });

		/* go on for IE in generall */
		if(jQuery.browser.msie){


			/* take care IE 6 only */
			if(jQuery.browser.version <= 7) {

				$('.block-narrow-by li ul a').append('<span class="after"> </span>');

			}
			else{

			}
			$('.home-top-data .m, .button span').corners({sufix: 2});
			$('.form-search .button span').corners({sufix: 0});

			$('li:last-child, td:last-child').addClass('last-child');
			
		}// ie


	});

	jQuery.fn.corners = function(option) {
		option = jQuery.extend({
			tl: 1,
			tr: 1,
			bl: 1,
			br: 1,
			sufix: 1
		}, option);

		return this.each(function(i){
			path = '/skin/frontend/default/neconew/images/';
			if(option.sufix == 0){
				$(this).find('.corner').remove();
			}
			else{

				if(option.tl)
					$(this).append('<img src="'+path+'img-cor'+option.sufix+'-NW.png" class="corner corner-nw" />');
				if(option.tr)
					$(this).append('<img src="'+path+'img-cor'+option.sufix+'-NE.png" class="corner corner-ne" />');
				if(option.bl)
					$(this).append('<img src="'+path+'img-cor'+option.sufix+'-SW.png" class="corner corner-sw" />');
				if(option.br)
					$(this).append('<img src="'+path+'img-cor'+option.sufix+'-SE.png" class="corner corner-se" />');



				$(this).css('position','relative').children('.corner').css({
					'position'	: 'absolute',
					'z-index'	: '1'
				});

				cBorderT = parseInt($(this).css('border-top-width'));
				cBorderR = parseInt($(this).css('border-right-width'));
				cBorderB = parseInt($(this).css('border-bottom-width'));
				cBorderL = parseInt($(this).css('border-left-width'));

				cBorderT = cBorderT > 0 ? '-'+cBorderT+'px' : '0';
				cBorderR = cBorderR > 0 ? '-'+cBorderR+'px' : '0';
				cBorderB = cBorderB > 0 ? '-'+cBorderB+'px' : '0';
				cBorderL = cBorderL > 0 ? '-'+cBorderL+'px' : '0';

				$(this).find('.corner-nw').css({
					'top'	: cBorderT,
					'left'	: cBorderL
				});
				$(this).children('.corner-ne').css({
					'top'	: cBorderT,
					'right'	: cBorderR
				});
				$(this).children('.corner-sw').css({
					'bottom': cBorderB,
					'left'	: cBorderL
				});
				$(this).children('.corner-se').css({
					'bottom': cBorderB,
					'right'	: cBorderR
				});

			}


		}); // each
	}
})(jQuery)
