var alamo = {
	URL: '',
	msie: false,
	
	initialize: function(object){
		this.URL = '';
		
		for(var key in object){
			this[key] = object[key];
		}
		
		if($.browser.msie)
			if($.browser.version == '6.0')
				this.msie = true;

		this.prepActions();
	},
	prepActions: function(){
	
		/*--------------------------------------------------*/
		this.imageTooltipActions();
		
		/*--------------------------------------------------*/
		this.makeCenter();
		
		/*--------------------------------------------------*/
		this.formActions();
		
		/*--------------------------------------------------*/
		this.linkActions();
	},
	checkEmail: function(value){
		var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
		if(!emailfilter.test(value)) return false;
		
		return true;
	},
	imageTooltipActions: function(){
		$('a.image-tooltip').click(function(e){ e.preventDefault(); });
	
		$('a.image-tooltip').each(function(e){ 
			var setting = $(this).attr('rel').split('|');
	
			if( setting[3] != '' ){
				var cont = {
					title: setting[3],
					text: '<div class="loading-black" style="height:' + setting[2] + 'px;width:' + setting[1] + 'px;"><img src="' + setting[0] + '" alt="' + setting[3] + '" /></div>'
				}
			}else{
				var cont = {
					text: '<div class="loading-black" style="height:' + setting[2] + 'px;width:' + setting[1] + 'px;"><img src="' + setting[0] + '" alt="" /></div>'
				}
			}
			
			$(this).qtip({ 
				content: cont, 
				position: { 
					target: 'mouse', 
					adjust: { mouse: true }, 
					corner: { target: 'topRight', tooltip: 'bottomRight' } 
				},
				style: { name: 'light', tip: true, padding: 0, border: { color: '#FFF', radius: 5 } }
			});
		});
	},
	makeCenter: function(){
		$('.make-it-center').each(function(){
			var width = $(this).width();
			
			$(this).css({ 'width': width, 'margin':'auto' });
			$(this).removeClass('remove-this-class');
		});	
	},
	formActions: function(){
		$('form').submit(function(){
			var retn = true;
			var message = '';
			var title = '';
			
			$(this).find('.no-empty').each(function(){
				if( $(this).val() == '' ){
					switch( $(this).attr('id') ){
						case 'full_name'	:	title = 'Full Name'; break;
						case 'from'			:	title = 'From'; break;
						case 'address'		:	title = 'Address'; break;
						case 'bussiness'	:	title = 'Bussiness'; break;
						case 'email'		:	title = 'E-mail address'; break;
						case 'country'		:	title = 'Country'; break;
						case 'company'		:	title = 'Company'; break;
						case 'phone'		:	title = 'Phone'; break;
						case 'zip'			:	title = 'ZIP'; break;
						case 'message'		:	title = 'Message'; break;
						case 'question'		:	title = 'Questions'; break;
					}
					message += '<p class="SexyAlertBox-p-message">Invalid field <strong>' + title + '</strong>!</p>';
					retn = false;
				}
			});
			
			$(this).find('.email').each(function(){
				if( $(this).val() != '' )
				{
					if( !alamo.checkEmail($(this).val()) ){
						message += '<p class="SexyAlertBox-p-message">Invalid field <strong>E-mail address</strong>!</p>';
						retn = false;
					}
				}
			});
			
			if( !retn )
				Sexy.alert(message);
			
			return retn;
		});
	},
	linkActions: function(){
		$('.content-faq .clb-link').click(function(e){
			e.preventDefault();
			var me = $(this);
			var container = $(this).parent('div').parent('li');
			
			container.find('.clb-subcontent-wrapper').slideToggle('medium');
		});	
		$('.content-faq .close-me').click(function(e){
			e.preventDefault;
			var container = $(this).parent('div').parent('div').parent('div').parent('li');
			
			container.find('.clb-subcontent-wrapper').slideUp('medium');
		});
	}
}
