/*User js Objects*/

/* Defaul Menu class*/
var Dmenu = {
	Init: function(el){
		var self = this;
		self.CloseAll(el);
	},
	CloseAll: function(el){
		$(el+' li:not([class=active]) ul').hide();
	}
}
var Dlang = {
	SetLangPosition: function(){
		$(window).scroll(function(){
			$('.langs').css('top',($(window).scrollTop()+10)+'px');
		});
	}
}

var Dpage = {
	SetBorderForInput: function(){
		$('input').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).focus(function(){$(this).addClass('backlight')});
		$('input').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).blur(function(){$(this).removeClass('backlight')});
		$('textarea').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).focus(function(){$(this).addClass('backlight')});
		$('textarea').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).blur(function(){$(this).removeClass('backlight')});
		$('select').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).focus(function(){$(this).addClass('backlight')});
		$('select').filter(function(){if($(this).hasClass('error-field') || $(this).hasClass('no-border')) return false;else return true;}).blur(function(){$(this).removeClass('backlight')});
	},
	SetFooterPosition: function(){
		Dpage.FooterPosition();
		$(window).resize(function(){Dpage.FooterPosition();});
		$('.content-box').bind("DOMSubtreeModified",function(){Dpage.FooterPosition();});
	},
	FooterPosition: function(){
		var body_height = $('body').outerHeight(true);
		var wrapper_height = $('#wrapper').outerHeight(true);
		var footer_height = $('.footer').outerHeight(true);
		if(body_height-(wrapper_height+footer_height) > 0){
			$('body').css('position','relative');
			$('.footer').css('position','absolute');
		}else{
			$('body').css('position','static');
			$('.footer').css('position','static');
		}
	},
	SetFocusBlur: function(el,val,function_focus,function_blur){
		$(el).bind({
			'focus': function(){
				if($(this).val() == val){$(this).val('');function_focus;}
			},
			'blur': function(){
				if($(this).val() == ''){$(this).val(val);function_blur;}
			}
			});
	},
	SetMainBoxSize: function(){
		var center_size = $('#main #center-box').height();
		var right_size = $('#main #right-box').height();
		if(center_size > right_size) $('#main #right-box').height(center_size-10);
		else  $('#main #center-box').height(right_size);
	}
}
