$(function(){$('.content').hide().fadeIn('slow');$('#mainimage').hide().slideDown(800);$('#overlay').css({top:-150}).animate({top:415},800);$('.active').parents('ul, li').addClass('active').children('ul').addClass('active');$('#nav li ul').not('.active').hide();$('#callback').hide();$('#callme').change(function(){$('#callme').is(':checked')?$("#callback").slideDown(300):$("#callback").slideUp(300);});veneers();$("#searchveneers").validate({rules:{keyword:{required:true,minlength:3}},messages:{keyword:{required:'Enter keywords',minlength:'Enter a longer phrase'}},submitHandler:function(){$('#searchveneers .submit').val('WORKING').attr('disabled','disabled');$('#searchveneers').ajaxSubmit({success:formResponseVeneer})}});$("#contact").validate({rules:{name:{required:true,minlength:3},email:{required:true,email:true},message:{required:true,minlength:10},phone:{required:{depends:function(element){return $("#callme").is(':checked');}},minlength:5},country:{required:{depends:function(element){return $("#callme").is(':checked');}}},callwhen:{required:{depends:function(element){return $("#callme").is(':checked');}}}},messages:{name:{required:'Enter your name',minlength:'Enter a longer name'},email:{required:'Enter your email',email:'Enter a valid address'},message:{required:'Enter your message',minlength:'Enter a longer message'},phone:{required:'Enter your phone number',minlength:'Enter a longer number'},country:{required:'Select country'},callwhen:{required:'Enter time'}},submitHandler:function(){$('#contact .submit').val('WORKING').attr('disabled','disabled');$('#contact').ajaxSubmit({success:formResponseContact2})}});});function formResponseContact2(responseText,statusText){if(responseText=='false'){$('#contact').prepend('<div id="errormessage">ERROR: Your email could not be sent. Please check the code and try again.</div>');$('#errormessage').hide().slideDown().animate({opacity:1},10000).slideUp();}
if(responseText=='true'){$('#contact').prepend('<div id="successmessage">Thank you, your email was sent.</div>');$('#successmessage').hide().slideDown().animate({opacity:1},10000).slideUp();$('#contact').clearForm();$("#callback").slideUp(300);}
$('#contact .submit').val('SEND').attr('disabled','');}
function formResponseVeneer(responseText,statusText){$('#searchresults').html(responseText).hide().fadeIn('slow');veneers();$('#searchveneers .submit').val('SEARCH').attr('disabled','');}
function veneers(){$('.widget-article-grid .box a, .widget-article-grid .box .details').hide();var openSwatch=false;$('.widget-article-grid .box').hover(function(){$(this).append('<img src="images/zoom-in.png" width="13" height="13" class="zoom" />');},function(){$('.zoom').remove();}).click(function(){if(openSwatch==false){var position=$(this).position();var top;var left;if(position.left==533){left=position.left-162;}else{left=position.left;}
if(position.top==359){top=position.top-225;}else{top=position.top;}
$(this).clone()
.addClass('zoomed')
.css({opacity:0,left:position.left,top:position.top})
.appendTo('.widget-article-grid')
.animate({width:'298px',opacity:1,left:left,top:top},350)
.children('.imagecrop')
.click(function(){$(this).parent().animate({width:'136px',opacity:0,left:position.left,top:position.top},350,function(){$(this).remove();openSwatch=false;});$('.widget-article-grid .overlay').animate({opacity:0},350,function(){$(this).remove();});})
.hover(function(){$(this).parent().append('<img src="images/zoom-out.png" width="13" height="13" class="zoom" />');$('.zoomed .button').fadeIn();$('.zoomed .details').fadeIn();},function(){$('.zoom').remove();})
var width=$('.widget-article-grid').width();var height=$('.widget-article-grid').height();var position2=$('.widget-article-grid').position();$('<div></div>')
.addClass('overlay')
.css({width:width,height:height,left:position2.left,top:position2.top,opacity:0})
.appendTo('.widget-article-grid')
.animate({opacity:0.7})
.click(function(){$('.zoomed').animate({width:'136px',opacity:0,left:position.left},350,function(){$(this).remove();openSwatch=false;})
$(this).animate({opacity:0},350,function(){$(this).remove();})});openSwatch=true;}});}
