(function(a){
	function b(){
			a('.jqmain').each(function(){
				a(this).hover(function(){
					var toanimate = a(this).parent().find('.toanimate');
						toanimate.stop().css({visibility: 'visible'}).animate({opacity : 1}, 500);
				}, function() {
					var toanimate = a(this).parent().find('.toanimate');
					toanimate.stop().animate({opacity : 0}, 700, function(){
						a(this).css('visibility', 'hidden');
					});
				});
			});
	};
	function c(){
		Cufon.replace('h1,h2,h3,h4,h5,h6, .top-nolink, .top-link a, .phone', {hover : true});
	};
	function d(pageid){
		a(pageid + " ul").css({display: "none"});
		a(pageid).find('a').removeAttr('title');
		a(pageid + " ul").find('a:last').css({border: "0"});
		var kl = a(pageid + " li").filter(":has(>ul)");
		
		kl.each(function(){
			a(this).hover(function(){
				a(this).addClass('onhov');
				a(this).find('ul:first').stop().css({overflow:"hidden", height:"auto",visibility: "visible",display: "none"}).slideDown(400,
					function(){
						a(this).css({overflow:"visible", height:"auto"});
					}
				);	
			}, function(){
				var biz = kl.find('.onhov');		
				a(this).removeClass('onhov');
				a(this).find('ul:first').stop().slideUp(100,
					function(){
						a(this).css({overflow:"hidden", display:"none"});
					}
				);			
			});
		})
	};
	
/* contact form handle */	
	function ContactHandle()
	{
		a('#contact_submit').click( function() {
		
			var name = a('#name').val();
			var mail = a('#email').val();
			var phone = a('#phone').val();
			var mess = a('#message').val();
			var sendto = a('#sendto').val();
			
			a('.ajaxload').text('Please wait...');
			
			if (name != "" && mail != "" && phone != "" && mess != "")
				{
					var uril = a("#urlto").val();
					var onpage = a("#onpage").val();
					a.ajax(
						{
							url: uril,
							type: 'GET',
							data: "hname=" + name + "&hmail=" + mail + "&hphone=" + phone + "&hmess=" + mess + "&sendto=" + sendto + "&onpage=" + onpage,
							success: function(result) 
							{
								a('.ajaxload').text('');
								if(result == "email_error") {
									a('#email').next('.req').html(' ! <small>please enter your valid email address</small>');
								} else {
									a('#name, #email, #phone, #message').val("");
									a('.ajaxload').text('' + result + '');
								}
							}
						}
					);
					return false;
					
				} 
			else 
				{
					a('.ajaxload').text('');
					if(name == "") a('#name').next('.req').text(' !');
					if(mail == "") a('#email').next('.req').text(' !');
					if(phone == "") a('#phone').next('.req').text(' !');
					if(mess == "") a('#message').next('.req').text(' !');
					return false;
				}
			return false;
		});
		
			a('#name, #email, #phone, #message').focus(function(){
				a(this).next('.req').text(' *');
			});
		
	}
	
	function dap(){
		var link = a('.gallery-icon').find('a');
		link.each(function(){
			if(a(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)){
				a(this).attr('rel', 'prettyPhoto[gallery1]');
			}
		});
		a("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	}
	
a(document).ready(function(){
b(); c(); d('.topmenu'); ContactHandle(); dap();
});
})(jQuery.noConflict());
