/**
 * @author Vlad Sancraian
 */
var Page = (new function(){
	this.index2 = function(){
//		A25Core.__validateForm('#page_advertise2', 'advertiser/json-validate-search');
		A25Core.__validateForm('#newsletter_form', 'adverteren-op-internet/json-validate-newsletter-form');
//		A25Core.__validateForm('#page_advertise2 .keywords-search', 'index/json-validate-search');
		$("#page_advertise2 button[name='st']").click(function(){
			var name=$(this).attr('name');
			var val=$(this).val();
			$.post("index/json-validate-search", { 'key_words': $("#page_advertise2 input[name='key_words']").val()},function(resp){
				if (!resp.success){
					$("#page_advertise2 input[name='key_words']").val("");
				}
				A25Core.__submitForm('#page_advertise2 .keywords-search form', name, val);
			},'json');
			return false;
		});
		var keywodsText;
		$("input.before-focus").live("focus", function(){
			keywordsText = $(this).val();
			$(this).val("");
			$(this).removeClass('before-focus');
		});
		$('input').live("blur", function(){
			var val = $(this).val();
			if (val == ''){
				$(this).val(keywordsText); 
				$(this).addClass('before-focus');
			}
		});
		$('#page_advertise2 table tbody tr:not(".details"):not(".last") td a').live('click',
			function () {
				var id = this.href.split('#')[1];
				if ($('#website_'+id).hasClass('expand')){
					//hide
					$('#website_'+id).removeClass('expand');
					$('#details_'+id).addClass('hide');
				}else{
					//hide the other expanded rows
					$('#page_advertise2 table tbody tr.expand').removeClass('expand');
					$('#page_advertise2 table tbody tr.details:not(".hide")').addClass('hide');
					//show details
					$('#website_'+id).addClass('expand');
					$('#details_'+id).removeClass('hide');
				}
				return false;
			}
//			,
//				function () {
//					var id = this.href.split('#')[1];
//					$('#website_'+id).removeClass('expand');
//					$('#details_'+id).addClass('hide');
//				}
		);
	};
	this.index= function(){
		A25Core.__validateForm('#contact_form', 'index/json-validate-contact-form');
		A25Core.__validateForm('#newsletter_form', 'index/json-validate-newsletter-form');
		var inputText;
		$("input.before-focus").live("focus", function(){
			inputText = $(this).val();
			$(this).val("");
			$(this).removeClass('before-focus');
		});
		$("textarea.before-focus").live("focus", function(){
			inputText = $(this).val();
			$(this).val("");
			$(this).removeClass('before-focus');
		});
		$('#page_home input[name="name"]').live("blur", function(){
			var val = $(this).val();
			if (val == ''){
				$(this).val(inputText); 
				$(this).addClass('before-focus');
			}
		});
		$('#page_home input[name="email_or_phone"]').live("blur", function(){
			var val = $(this).val();
			if (val == ''){
				$(this).val(inputText); 
				$(this).addClass('before-focus');
			}
		});
		$('#page_home input[name="email"]').live("blur", function(){
			var val = $(this).val();
			if (val == ''){
				$(this).val(inputText); 
				$(this).addClass('before-focus');
			}
		});
		$('#page_home textarea[name="message"]').live("blur", function(){
			var val = $(this).val();
			if (val == ''){
				$(this).val(inputText); 
				$(this).addClass('before-focus');
			}
		});
	};
//	function blurInput(input, message){
//		var val = $(input).val();
//		var text = $(this).text();
////		alert(val);
////		alert(text);
//		alert(message);
//		if (!val && !text){
//			$(input).val(message); 
//			$(input).text(message); 
//			$(input).addClass('before-focus');
//		}
//	}
});
