/*
 * Common JS functions to most if not all Filmetrics pages including translated sites
 * @Author: Nichole Shannon - red-head.biz
 * @Company: Filmetrics, Inc.
 *
 * JQuery API - http://docs.jquery.com/Main_Page
 *
 */
/*A Simple FrameBuster*/
if (top.frames.length!=0){ top.location=self.document.location; }


$(document).ready(function(){
	$('ul.sf-menu').superfish({
		delay:         200,
		speed:         'fast',
		disableHI:     true,
		autoArrows:  false,   
        dropShadows: false
	});
	if(document.getElementById("contact-form")){
		// validate signup form on keyup and submit
	    var validator = $("#contact-form").validate({
	        rules: {
	            name: {
	                required: true,
	                minlength: 2
	            },
	            company: {
	                required: true,
	                minlength: 2
	            },
	            email: {
	                required: true,
	                email: true
	            }
	            ,
	            country: {
	                required: true
	            }
	        },
	        messages: {
	            name: nameInputField,
	            company: companyInputField,
	            email: emailInputField,
	            country: countryInputField
	            /*
	            phone: phoneInputField,
	            
	            */
	        },
	        /* the errorPlacement has to take the table layout into account
	        errorPlacement: function(error, element) {
	            if ( element.is(":radio") )
	                error.appendTo( element.parent().next().next() );
	            else if ( element.is(":checkbox") )
	                error.appendTo ( element.next() );
	            else
	                error.appendTo( element.parent().next() );
	        },*/
	        errorClass: "error",
	        errorContainer: "#messageBox1",
	        errorLabelContainer: "#messageBox2",
	        wrapper: "div", 
	        highlight: function(element, errorClass) {
	            $(element).addClass(errorClass);
	         },
	         unhighlight: function(element, errorClass) {
	            $(element).removeClass(errorClass);
	         },
	        debug:false,
	        // set this class to error-labels to indicate valid fields
	        success: function(label) {
	            // set as text for IE
	            label.html(" ").addClass("checked");
	        },
	        submitHandler: function(form) {
	        	$("#contact-form").append("<input type=\"hidden\" name=\"valid\" value=\"true\"/>");
	        	form.action = $("#contact-form").attr("action");
	        	form.submit();
	        }
	        
	        
	    });
	}
    
    
});


