function isValidEmailAddress(emailAddress) {
 		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
 		return pattern.test(emailAddress);
	}

function css() {

// 	Cufon.replace('h1, #featured h4, #featured h3, #featured ul, .blog-bar h4.header, #content .blog-post h2.title, #content h4, .bar .header, #content h2, #content h3, #content .blog-post-comment, #wrapper.contact span.address', {
// 		fontFamily: 'DINPro-Regular',
// 		hover: true
// 	});
// 	Cufon.replace('#mod-options h3, #uniqe-serivce #side-bar1 a', {
// 		fontFamily: 'DINPro-Medium',
// 		hover: true
// 	});
	
	jQuery('input[type=text], textarea').clear();
	
	/* go on for IE in generall */
	if(jQuery.browser.msie){
        jQuery('#nav li:last-child').addClass('last-child');


//         function refresh(cont) {
//             if(jQuery.browser.msie) jQuery( cont ).each( function() { this.fireEvent('onmove') } );
//         }
//         // Workaround for PIE.htc
//         jQuery('#nav li').bind('mouseenter mouseleave', function () {   
//             jQuery(this).find('ul').toggle();
//             //refresh(jQuery(this).find('ul'));
//         });


		/* take care IE 6 only */
		if(jQuery.browser.version <= 6) {
		
			jQuery('#nav li:first-child, #footer ul li:first-child').addClass('first-child');
		
			//if(jQuery('body').is('.home')){
				
				img = jQuery('#featured-img img').attr('src');
				jQuery('#featured-img img').hide();
				jQuery('#featured-img').css({filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='image')"})
			//}
					
			
		}
		
		jQuery('hr.separator').wrap('<span class="separator"></span>');
	}
	
	jQuery('.mod-stats a, .gm-link, .link-live-site').attr('target','_blank');
	
	//if(jQuery("*").index( jQuery('#mod-address')[0]) != -1){
	if(jQuery('#mod-address').length){
		var email = jQuery('#mod-address em[title=mail] span').html();
		if(email){
			email = email.replace('[at/]','@'); 
			jQuery('#mod-address em[title=mail] span').html('<a href="mailto:'+email+'>'+email+'</a>');
		}
	}
	
	//jQuery('.cs-list .item-8').after('<li class="divider"></li>');
	
	
	//if(jQuery("*").index( jQuery('#mod-us-contact')[0]) != 0)
	if(jQuery('#mod-us-contact').length)
		jQuery('#mod-us-contact input[name="us-type"]').val(jQuery('body').attr('service')).hide();
	
	jQuery('#mod-video a').each(function(v){
		$attr_rel = jQuery(this).attr('rel');
		if($attr_rel == '_blank')
			jQuery(this).attr('target',$attr_rel);
		if($attr_rel == 'pop-up')
			jQuery(this).addClass($attr_rel);
			

		
	});
	
	jQuery('.mod-follow li a').attr('target','_blank');
	
	jQuery('.pop-up').fancybox({
		'width'				: 480,
		'height'			: 385,
		'autoScale'			: false,
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	}); 		
		
	jQuery('a.fb').fancybox({
		'titleShow': true,
		'autoScale': false
	}); 	
		
	jQuery('.mod-di-map-widget .fb-map').fancybox({
		'titleShow': false,
		'autoScale': false
	}); 	
		
    // Hide it only in homepage
	jQuery('#homepage #mod-us-contact').css({'height':'370px', 'overflow':'hidden'});
    if(jQuery.browser.msie){ jQuery('#homepage #mod-us-contact p').hide(); }

    // Collapse functionality
	jQuery('#mod-us-contact h4').unbind().bind('click',function(e){
		if (jQuery('#mod-us-contact').height() != 66 ) {	
			if(jQuery.browser.msie){ jQuery('#mod-us-contact p').hide(); }		
			jQuery('#mod-us-contact').animate({
				style: 'height:66px'
			},{duration:1000});
		} else {
			//jQuery('#mod-us-contact').css({'height':'300px'});
			if(jQuery.browser.msie){ jQuery('#mod-us-contact p').show(); }
			jQuery('#mod-us-contact').animate({
				style: 'height:370px'
			},{duration:1000});
		}
	});
    jQuery('#mod-us-contact').css({'overflow':'hidden'});
}

function newsletter() {
	jQuery('#FormNewsletter #ns').unbind().bind('click',function(e){
				e.preventDefault();
				var email = jQuery("#ne").val(); 
				if(email != 0) 
 					if(isValidEmailAddress(email)) 
						jQuery('#FormNewsletter').submit();
					else 
 						alert("Please enter a valid email");
				else
					alert("Please enter an email address");
			});
}

jQuery(document).ready(css);
jQuery(document).ready(newsletter);

jQuery.fn.clear = function() {
	return this.each(function(i){
		var val;
		
		jQuery(this).focus(function(){ 
            if(jQuery(this).is('.input-on-edit') == false)
            jQuery(this).val('').addClass('input-on-edit'); 
		}); // focus
		
	}); // each	
};
