// <![CDATA[

jQuery.noConflict();
jQuery.validator.addMethod(
  "selectNone",
  function(value, element) {
	if (element.value == "0000")
	{
	  return false;
	}
	else return true;
  },
  "Maak een keuze."
);
jQuery(function() {
	jQuery("#tabs").tabs();
});	
var savedHTML;
jQuery(document).ready(function() {

		jQuery("ul.distinav > li").click(function(){
			target = jQuery(this).attr("name");
			/*
			jQuery(this).css("background-color","#F90");
			if(distiNavTarget != null) {
				jQuery(distiNavTarget).css("background-color","#666");
			}			
			distiNavTarget = this;
			*/
			accountID = jQuery("#accountID").html();
			jQuery("#distiContent").html('<p><span>Loading</span></p>');
			jQuery.ajax({
				url:"index.php/shoppingcart/ajax?showtemplate=false",
				global: false,
				type: "POST",
				data: ({ action: 'menu',
					     menuOption: target,
						 accountID: accountID
				}),
				dataType: "html",
				failure: function(msg) {
					jQuery("#distiContent").html('Please try again later');					
				},
				success: function(msg) {
					switch(target) {
						case 'disti_1':
							if(msg['error']!=null) {
								jQuery("#distiContent").html(msg['error']);
								break;
							}
							htmlBlob = "<table width='400px' cellpadding='0px' cellspacing='0px'><tr><td colspan='3' height='40'><span class='big'><strong>"+msg['company']+"</strong></span></td></tr>";
							htmlBlob += "<tr><td>Contact:</td><td>&nbsp;</td><td>"+msg['firstName']+" "+msg['lastName']+"</td></tr>";
							htmlBlob += "<tr><td width='200px'>BTW Nummer:</td><td width='5px'>&nbsp</td><td>"+msg['btwnumber']+"</td></tr>";
							htmlBlob += "<tr><td>KvK Nummer:</td><td>&nbsp</td><td>"+msg['kvk']+"</td></tr>";
							htmlBlob += "<tr><td>Telefoonnummer:</td><td>&nbsp</td><td>"+msg['phonenumber']+"</td></tr>";
							htmlBlob += "<tr><td>Emailadres:</td><td>&nbsp</td><td>"+msg['email']+"</td></tr>";
							htmlBlob += "<tr><td colspan='3'>&nbsp;</td></tr>";
							htmlBlob += "<tr><td><strong>Factuuradres</strong></td><td>&nbsp</td><td><strong>Verzendadres</strong></td></tr>";
							htmlBlob += "<tr><td>"+msg['billingStreet']+"</td><td>&nbsp</td><td>"+msg['shippingStreet']+"</td></tr>";
							htmlBlob += "<tr><td>"+msg['billingZipcode']+" "+msg['billingCity']+"</td><td>&nbsp</td><td>"+msg['shippingZipcode']+" "+msg['shippingCity']+"</td></tr>";
							htmlBlob += "<tr><td>"+msg['billingCountry']+"</td><td>&nbsp</td><td>"+msg['shippingCountry']+"</td></tr>";
							htmlBlob += "</table>";
							jQuery("#distiContent").html(htmlBlob).css('margin-left','50px');
							break;
						case 'disti_2':
							jQuery("#distiContent").html(msg);
							break;
						case 'disti_3':
							jQuery("#distiContent").html(msg);
							break;
						case 'disti_4':
							jQuery("#distiContent").html(msg);
							break;
						case 'disti_5':
							jQuery("#distiContent").html(msg);
							break;
						case 'disti_6':
							jQuery("#distiContent").html(msg);														
							break;						
						}
					

					// jQuery("#distiContent").html('<p><span>Loading of <strong>'+target+'</strong> complete.</span></p>');
					// if(msg == "false") window.location = "login.html";
				}
			});
		});
		jQuery("#gallery > a").click(function() {									
				imageName = jQuery(this).attr('name');
				savedHTML = jQuery("#distiContent").html();
				jQuery("#distiContent").html('<img src="uploads/assets4partners/images/'+imageName+'" width="650px" /><a href="back" name="backButton">terug</a>');
				jQuery("#distiContent > a").click(function() {										
					jQuery("#distiContent").html(savedHTML);
					return false;
				});
				return false;
		});
	
		jQuery(".scrollableNews").scrollable({
				vertical: true,				
				size: 1
		}).circular().autoscroll(5000);				
		
		/*
		jQuery("#distiRegister :input").tooltip({
			position: "center right",
			offset: [-2, 10],
			effect: "fade",
			opacity: 0.7,
			tip: '.tooltip'					
		});
		
		jQuery("#createAccount :input").tooltip({
			position: "center right",
			offset: [-2, 10],
			effect: "fade",
			opacity: 0.7,
			tip: '.tooltip'					
		});
		*/
		
	    // select #flowplanes and make it scrollable. use circular plugin 
		jQuery("#infopanes").scrollable({size: 1}).circular().autoscroll(
			{
					autopause:true,
					interval: 20000 }
			);
		
		jQuery(function() {
			// setup ul.tabs to works as tabs for each div directly under div.panes			
			jQuery("ul.tabs").tabs("div.panes > div", {
					effect: 'fade'
					})
		});
		
		jQuery("#infinite").scrollable().circular();
		
		// http://jquery.lukelutman.com/plugins/flash
		jQuery('#flashPlayer').flashembed(
			{
				src : 'uploads/videos/Bobby.swf',
				params : {
					play: false
				},
				width : 320,
				height : 240 }
		);
		jQuery('img').click(function() 
			{	
				if(jQuery(this).attr('id')=='flashVideo') {
					$name = jQuery(this).attr('name');					
					jQuery("#flashPlayer").html(""); // empty innerHTML
					jQuery("#flashPlayer").flashembed(
					{
						src : 'uploads/videos/'+$name+".swf",
						width : 320,
						height : 240
					});
					return false;
				}			
			}
		);
		
		jQuery('.fg-button').hover(
			function(){ 
				jQuery(this).addClass("ui-state-hover"); 
			},
			function(){ 
				jQuery(this).removeClass("ui-state-hover"); 
			}
		);

		// checkSessionTimeEvent = setInterval("checkSessionTime()",10*1000);
		jQuery('#ex3a').jqm({
			trigger: '#ex3aTrigger',
			overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
			overlayClass: 'whiteOverlay'})
			.jqDrag('.jqDrag'); /* make dialog draggable, assign handle to title */
		  
		  // Close Button Highlighting. IE doesn't support :hover. Surprise?
		  jQuery('input.jqmdX')
		  .hover(
			function(){ JQuery(this).addClass('jqmdXFocus'); }, 
			function(){ jQuery(this).removeClass('jqmdXFocus'); })
		  .focus( 
			function(){ this.hideFocus=true; jQuery(this).addClass('jqmdXFocus'); })
		  .blur( 
			function(){ jQuery(this).removeClass('jqmdXFocus'); });
		  
		jQuery('#ex3b').jqm({
			trigger: '#ex3bTrigger',
			overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
			overlayClass: 'whiteOverlay'})
			.jqDrag('.jqDrag'); /* make dialog draggable, assign handle to title */
		  
		  // Close Button Highlighting. IE doesn't support :hover. Surprise?
		  jQuery('input.jqmdX')
		  .hover(
			function(){ jQuery(this).addClass('jqmdXFocus'); }, 
			function(){ jQuery(this).removeClass('jqmdXFocus'); })
		  .focus( 
			function(){ this.hideFocus=true; jQuery(this).addClass('jqmdXFocus'); })
		  .blur( 
			function(){ jQuery(this).removeClass('jqmdXFocus'); });
		  
		jQuery("#cntnt01moduleform_idealForm").validate({
			rules: {
			  issuer: {
				selectNone: true
			  }
			}
		});
		
		jQuery('#formContactUs').validate();

		jQuery('#createAccount').validate({
 
          rules: {
              firstName: "required",
              lastName: "required",
              billingStreet: "required",
              billingZipcode: "required",
              billingCity: "required",
              shippingStreet: "required",
              shippingZipcode: "required",
              shippingCity: "required",
              email: {
                  required: true,
                  email: true
              },
              password: {
                required: true,
                minlength: 5
              },
              password_again: {
                equalTo: "#password"
              }
          },
          messages: {
            firstName: "Uw voornaam of voorletter",
            lastName: "Uw achternaam",
            billingStreet: "Uw straatnaam",
            billingZipcode: "Uw postcode",
            billingCity: "Uw plaatsnaam",
            shippingStreet: "Uw straatnaam",
            shippingZipcode: "Uw postcode",
            password: {
              minlength: "Vul een wachtwoord in van minimaal 5 tekens"
            },
            password_again: {
              equalTo: "Wachtwoorden komen niet overeen"
            },
            shippingCity: "Uw plaatsnaam",
            email: {
              required: "We hebben uw email adres nodig om u te contacteren",
              email: "Uw email adres moet in het formaat naam@domain.nl zijn"
            }
          },
          errorPlacement: function(error, element) {
            if (element.attr("name") == "password" 
                 || element.attr("name") == "password_again" )
              error.insertAfter("#password_again");
            else
              error.insertAfter(element);
          }
        });
		
		jQuery('#distiRegister').validate({
 
          rules: {
			  company: "required",
			  kvk: "required",
              firstName: "required",
              lastName: "required",
              billingStreet: "required",
              billingZipcode: "required",
              billingCity: "required",
              shippingStreet: "required",
              shippingZipcode: "required",
              shippingCity: "required",
              email: {
                  required: true,
                  email: true
              },
              password: {
                required: true,
                minlength: 5
              },
              password_again: {
                equalTo: "#password"
              }
          },
          messages: {
			company: "Uw bedrijfsnaam",
			kvk: "Kamer van Koophandel nummer",
            firstName: "Uw voornaam of voorletter",
            lastName: "Uw achternaam",
            billingStreet: "Uw straatnaam",
            billingZipcode: "Uw postcode",
            billingCity: "Uw plaatsnaam",
            shippingStreet: "Uw straatnaam",
            shippingZipcode: "Uw postcode",
            password: {
              minlength: "Vul een wachtwoord in van minimaal 5 tekens"
            },
            password_again: {
              equalTo: "Wachtwoorden komen niet overeen"
            },
            shippingCity: "Uw plaatsnaam",
            email: {
              required: "We hebben uw email adres nodig om u te contacteren",
              email: "Uw email adres moet in het formaat naam@domain.nl zijn"
            }
          },
          errorPlacement: function(error, element) {
            if (element.attr("name") == "password" 
                 || element.attr("name") == "password_again" )
              error.insertAfter("#password_again");
            else
              error.insertAfter(element);
          }
        });
		
		jQuery('#nieuwsbrief').validate({			
			});
	
        jQuery('#cntnt01moduleform_lostPasswordForm').validate({
          rules:{
            email: {
              email:true,
              required:true
            }
          },
          messages: {
            email: {
              required: "Vul hier uw email adres in",
              email: "Voer een geldig email adres in"
            }
          }
        });

        jQuery('#cntnt01moduleform_loginForm').validate({
          rules: {
            email: {
              email:true,
              required:true
            },
            password: "required"
          },
          messages: {
            email: {
              required: "Uw email adres aub",
              email: "Ongeldig email adres"
            },
            password: "Uw wachtwoord"
          }
        });
        jQuery('#disti_login_form').validate({
          rules: {
            email: {
              email:true,
              required:true
            },
            password: "required"
          },
          messages: {
            email: {
              required: "Uw email adres aub",
              email: "Ongeldig email adres"
            },
            password: "Uw wachtwoord"
          }
        });

        jQuery("#shippingIsBilling").click(function() {
         jQuery("#cshippingZipcode").attr("value",jQuery("#cbillingZipcode").attr("value"));
         jQuery("#cshippingStreet").attr("value",jQuery("#cbillingStreet").attr("value"));
         jQuery("#cshippingCity").attr("value",jQuery("#cbillingCity").attr("value"));
        });	
	jQuery("#tab2").hide();
	jQuery("#tab3").hide();
		jQuery("#tab3-title").click(function () { 
      		jQuery("#tab3").show();
			jQuery("#tab2").hide(); 
			jQuery("#tab1").hide(); 
			jQuery("#tab3-title").addClass("on");
			jQuery("#tab2-title").removeClass("on");
			jQuery("#tab1-title").removeClass("on");
   		 });
		jQuery("#tab1-title").click(function () { 
      		jQuery("#tab1").show();
			jQuery("#tab3").hide(); 
			jQuery("#tab2").hide(); 
			jQuery("#tab1-title").addClass("on");
			jQuery("#tab3-title").removeClass("on");
			jQuery("#tab2-title").removeClass("on");
   		 });
		jQuery("#tab2-title").click(function () { 
      		jQuery("#tab2").show();
			jQuery("#tab3").hide(); 
			jQuery("#tab1").hide(); 
			jQuery("#tab2-title").addClass("on");
			jQuery("#tab3-title").removeClass("on");
			jQuery("#tab1-title").removeClass("on");
   		 }) 
	});
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() { 
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// ]]>

