(function(jQuery){
// -------------------------------------------------------------------------------------------------------
// Form Validation script - used by the Contact Form script
// -------------------------------------------------------------------------------------------------------
jQuery.validity.setup({ outputMode:"label" });
function validateMyAjaxInputs() {
jQuery.validity.setup({ outputMode:"label" });
jQuery.validity.start();
// Validator methods go here:
jQuery("#name").require();
jQuery("#email").require().match("email");
jQuery("#subject").require();
// End the validation session:
var result = jQuery.validity.end();
return result.valid;
}
// -------------------------------------------------------------------------------------------------------
// Comment Form - Validation
// -------------------------------------------------------------------------------------------------------
jQuery("#comment-form").validity(function() {
jQuery("#author").require();
jQuery("#email").require().match("email");
jQuery("#comment").require();
});
// -------------------------------------------------------------------------------------------------------
// ClearForm
// -------------------------------------------------------------------------------------------------------
jQuery.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form')
return jQuery(':input',this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};
jQuery(document).ready(function(){
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------------------------------------
// Dropdown Menu
// -------------------------------------------------------------------------------------------------------
jQuery("ul#dropdown-menu li").hover(function () {
jQuery(this).addClass("hover");
jQuery('ul:first', this).css({visibility: "visible",display: "none"}).slideDown(200);
}, function () {
jQuery(this).removeClass("hover");
jQuery('ul:first', this).css({visibility: "hidden"});
});
if ( ! ( jQuery.browser.msie && (jQuery.browser.version == 6) ) ){
jQuery("ul#dropdown-menu li ul li:has(ul)").find("a:first").addClass("arrow");
}
// -------------------------------------------------------------------------------------------------------
// Contact Form
// -------------------------------------------------------------------------------------------------------
jQuery("#contact-form").submit(function () {
if (validateMyAjaxInputs()) { // procced only if form has been validated ok with validity
var str = jQuery(this).serialize();
jQuery.ajax({
type: "POST",
url: themePath + "/_layout/php/send.php",
data: str,
success: function (msg) {
jQuery("#formstatus").ajaxComplete(function (event, request, settings) {
if (msg == 'OK') { // Message Sent? Show the 'Thank You' message
result = '
Your message has been sent. Thank you!
';
jQuery('#contact-form').clearForm();
} else {
result = msg;
}
jQuery(this).html(result);
});
}
});
return false;
}
});
// -------------------------------------------------------------------------------------------------------
// Newsletter form
// -------------------------------------------------------------------------------------------------------
jQuery('.subscribe-submit-btn').click(function(){
var mail = jQuery('#subscribe-email').attr('value');
if (mail == msg_newsletter_label) {
jQuery('#subscribe-email').attr(msg_newsletter_error);
return false;
}
if (mail == msg_newsletter_error) {
return false;
}
if (isValidEmailAddress(mail)){
jQuery.post(themePath+'/_layout/php/subscribe.php', {subscribe: mail},
function(data){
if (data.success == '1'){
jQuery('#subscribe-email').attr('value',data.message);
}else{
if (data.err == '100'){
jQuery('#subscribe-email').attr('value',data.message);
}
if (data.err == '101'){
jQuery('#subscribe-email').attr('value',data.message);
}
}
});
}else{
jQuery('#subscribe-email').attr('value', msg_newsletter_error);
}
return false;
});
// -------------------------------------------------------------------------------------------------------
// Make entire service overviews clickable
// -------------------------------------------------------------------------------------------------------
jQuery(".service-overview li, .service-overview-index li").click(function(){
window.location=jQuery(this).find("a").attr("href");
return false;
});
// -------------------------------------------------------------------------------------------------------
// Portfolio options fade
// -------------------------------------------------------------------------------------------------------
jQuery('.preview-options').css('opacity', '0');
jQuery('.portfolio-item-preview').hover(
function () {
jQuery(this).find('.preview-options').stop().fadeTo(400, 1);
}, function () {
jQuery(this).find('.preview-options').stop().fadeTo(200, 0);
}
);
// -------------------------------------------------------------------------------------------------------
// Portfolio Filter - the filter dropdown
// -------------------------------------------------------------------------------------------------------
jQuery("ul#portfolio-filter li").hover(function () {
jQuery(this).addClass("hover");
jQuery('ul:first', this).css({
visibility: "visible",
display: "none"
}).slideDown(200);
}, function () {
jQuery(this).removeClass("hover");
jQuery('ul:first', this).css({
visibility: "hidden"
});
});
// -------------------------------------------------------------------------------------------------------
// Protfolio Fade - on hover over a portfolio item overview the iamge gets faded
// -------------------------------------------------------------------------------------------------------
if (jQuery.browser.msie && jQuery.browser.version < 7) return;
jQuery(".portfolio-overview li img").fadeTo(1, 1);
jQuery(".portfolio-overview li").hover(
function () {
jQuery(this).find('img').fadeTo("fast", 0.80);
}, function () {
jQuery(this).find('img').fadeTo("slow", 1);
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
});
})(window.jQuery);
// non jQuery scripts below
//Function for e-mail validation on newsletter field
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/);
return pattern.test(emailAddress);
}