/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!                    
/***************************/


function centerPopup(){
    //request data for centering
   /** var windowWidth = window.clientWidth;
    var windowHeight = jQuery(window).height();
    var popupHeight = jQuery("#backgroundPopup").height();
    var popupWidth = jQuery("#backgroundPopup").width(); **/
    //centering
  /*  $left=  (windowWidth- popupWidth)/2;
    $top=   (windowHeight- popupHeight)/2; */
    if(jQuery("#afhntb").length>0)
    {
      jQuery("#afhntb").attr('checked',true);
      
    }
    else
    {
    }
   /** jQuery("#backgroundPopup").css({
        position: "absolute" ,
        top:$top
        
                  });    */
    
    //only need force for IE6
    
   
    
}


//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){
     //  jQuery("#afhntb").attr('checked',false);
    //LOADING POPUP
 
	   jQuery('#addressShop').parent().append(jQuery('#backgroundPopup'));    
    //Click the button event!
    jQuery("#afhntb").click(function(event){    
        //centering with css
        //event.preventDefault();
        if(popupStatus==0){
        centerPopup();
        //jQuery("#afhntb").attr('checked','');  
        //load popup
       
        }
        else
        {
          
       
       
        // jQuery("#afhntb").attr('checked',false); 
    }
    
    
    } );
                
    
    //Press Escape event!
   
    
        jQuery("[name^='shipping_afhntb']").click(function()
        {
			//todo: To be removed when all sites have checkout elements
			if (jQuery('#afhntb').length > 0) {
				jQuery('#afhntb').attr('checked', 'checked');//shipping    
			}
			
			//New Checkout Elements
			if (jQuery('#afhntb_afhntb').length > 0) {
				jQuery('#afhntb_afhntb').attr('checked', 'checked');//shipping
			}
        });
   
})

jQuery(function(){
    
    jQuery('#table').click(function(){

        jQuery('.productiontime').hide();
        jQuery('[name^=shipping_afhntb]').attr('checked','');
    });
    jQuery('[name^=shipping]').click(function(){
        if(jQuery(this).attr('id')!='table')
          jQuery('.productiontime').show();
          
    });
})
