var defaultVal = '';

if (typeof Rovitex == "undefined") var Rovitex = new Object();
Rovitex = {
	setLang:function(langId, url){$.post('/kisker/Index/SetLang/',{langId:langId},function(response){document.location.href = url;});}
	
	/* ,callback: function callback (hash){
		if(hash) {
			// restore ajax loaded state
			if($.browser.msie) {
				// jquery's $.load() function does't work when hash include special characters like aao.
				hash = encodeURIComponent(hash);
			}
			$.post(
			'/Product/productByCat/',
			{cat:hash},
			function(response){
				$(".productListBox").html(response);
				//if($(".productMenu").hasClass('productMenuByCat')){
					Rovitex.categoryClick(hash);
					$.post(
					'/Product/getTitle/',
					{cat:hash},
					function(response){
						document.title = response;  
						document.description = response;  
					});
					/*$.post(
					'/Product/productMenu/',
					{cat:hash},
					function(response){
						$(".productMenu").html(response);		
						$(".productMenu").removeClass('productMenuByCat');
					});	//komment lezárás				
				//} 	 		
			}			
		);			
		} else {
			$.post(
			'/Product/productByCat/',
			{cat:''},
			function(response){
				$(".productListBox").html(response);
				Rovitex.categoryClick(hash);
				/* $.post(
				'/Product/productMenu/',
				{cat:hash},
				function(response){
					$(".productMenu").html(response);					
				}); //komment lezárás
			});			
		}		
	} */
	
	/* ,initHistory: function(){
		$.history.init(this.callback);
	    $("a[rel='history']").click(function(){
	        $.history.load(this.href.replace(/^.*#/, ''));
	        return false;
	    });
	}	 */
	
	,initGaleries: function(relation, imageTitle){
		$("a[rel=" + relation + "]").fancybox({			
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">' + title + '</span>';
			}
		});
	}
	
	,initFancy: function(){
		$(".fancy").fancybox({
			'frameWidth'		: '500',
			'frameHeight'		: '400',					
			'type'				: 'iframe'
		});			
	}
	
	/* ,initCategory: function(){
		$(".openThe").click(function () {
			$('li').removeClass('open');
			$('a').removeClass('active');			
			if($(this).parent('li').hasClass('root')) {
				$('ul.subul').hide();
				$('a.background').css("background","url('/img/arrow_right_small.png') right no-repeat");
			}			
			if($(this).parent('li').hasClass('open')){
				/* $(this).parent('li').removeClass('open');
				$(this).removeClass('active'); */
				/* if($(this).is('#background')){
					$(this).css("background","url('../img/arrow_right_small.png') right no-repeat");
				} */
				/* if($(this).parent('li').hasClass('root')) {
					$(this).next('ul').hide();
				} //komment lezárás
			} else {
				$(this).parent('li').addClass('open');
				$(this).addClass('active');
				if($(this).hasClass('background')){
					$(this).css("background","url('/img/arrow_down.png') right no-repeat");
				}
				$(this).next('ul').show();
			}
			return false;
		});
	}  */
	
	,login: function(){
		$.post(
			'/nagyker/Login/login/',
			{login_name:$('#email').val(), login_password:$('#pw').val()},
			function(html){
				if(html == 'ok'){
					document.location.reload();
				}else{
					var res = html.split(';');
					//Kizman.alert(res[1]);
					$("#error").html(res[1]);		
				}
			}
		);
	}
	
	,forgot: function(){
		$.post(
			'/nagyker/Customer/sendPass/',
			{email:$('#email').val()},
			function(html){
				if(html == 'ok'){
					document.location.reload();
				}else{
					var res = html.split(';');
					//Kizman.alert(res[1]);
					$("#error").html(res[1]);		
				}
			}
		);
	}
	
	,onEnter: function(event, _func){
		var theCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (theCode == 13){
			eval(_func);
		}
	}
	
	,setSorter: function(order,by){
		$.post('/kisker/Product/SetOrder/',{order:order, by:by},function(response){document.location.reload()});
	}
	
	,setPager: function(pager){
		$.post('/kisker/Product/SetPager/',{pager:pager},function(response){document.location.reload()});
	}
	
	,setList: function(){
		$.post('/kisker/Product/SetList/',{},function(response){return true;});
	}
	
	,changeColor: function(id){
		$('#bigPic').attr('src', '/Thumbnails/'+id+'.w@448.h@297.q100.jpg');
		$('#bigPic').attr('alt', $('a#im_'+id+' img').attr('alt'));
		$('#bigPic').parent('a').attr('href', '/Thumbnails/'+id+'.w-700.h-700.q100.jpg');
		$('.productTextPic a').attr('rel', 'oscar');
		$('a#im_'+id).attr('rel','');
	}
	
	,categoryClick: function(id){
		$('li').removeClass('open');
		$('a').removeClass('active');		
		if($('#cat'+id).parent('li').hasClass('root')) {
			$('ul.subul').hide();
			$('a.background').css("background","url('/img/arrow_right_small.png') right no-repeat");
		}			
		if($('#cat'+id).parent('li').hasClass('open')){
		} else {
			$('#cat'+id).parents('li').addClass('open');
			$('#cat'+id).addClass('active');
			if($('#cat'+id).hasClass('background')){
				$('#cat'+id).css("background","url('/img/arrow_down.png') right no-repeat");				
			}
			$('li.open>a.background').css("background","url('/img/arrow_down.png') right no-repeat");
			$('#cat'+id).parents('ul').show();
			$('#cat'+id).next('ul').show();
			$(".productMenu").removeClass('productMenuByCat');
		}
		return false;
	}
	
}
