var Across = {

	reload : false,

	Toggle : function (id)
	{
		$(id).style.display = ($(id).style.display == 'block') ? 'none' : 'block';
	},
	
	clearField : function (item)
	{
		$(item).attr('value', '');
	},

	sendM : function (thisFom)
    {
        Across.actualForm = thisFom;

		$.post("/", 
			'Func=contacts.sendMessage&'+$(thisFom).serialize(), 
			function(data) {

				if (data.error)
				{
					jQuery.each(data.items, function(i, val) {
						$('#'+i).val(val);
				    });
				}
				else
				{
					Across.actualForm.reset();
					alert(data.message);
				}
			},
			"json"
		);
    },

	updateBasket : function (thisFom)
    {
		if ( $('#transport_date').val() == '' || $('#project_price').val() == '' )
		{
			alert('Adja meg az Árat és a Szállítási határidőt!');
			return false;
		}

        Across.actualForm = thisFom;
		Across.reload = arguments[1] ? arguments[1] : false;

		$.post("/", 
			'Func=products.updateBasket&'+$(thisFom).serialize(), 
			function(data) {
				Across.reloadWin(Across.reload);
			},
			"text"
		);
	},

	pushBasket : function (items)
    {
		Across.reload = arguments[1] ? arguments[1] : false;

		$.post("/", 
			{
				Func : 'products.updateBasket',
				items : items
			},
			function(data) {
				Across.reloadWin(Across.reload);
			},
			"text"
		);
	},

	updateGifts : function (thisFom)
    {
        Across.actualForm = thisFom;
		Across.reload = arguments[1] ? arguments[1] : false;

		$.post("/", 
			'Func=products.updateGifts&'+$(thisFom).serialize(), 
			function(data) {
				Across.reloadWin(Across.reload);
			},
			"text"
		);
	},

	removeItem : function (item)
	{
		$('#'+item).val('');
	},

	back : function ()
	{
		history.go(-1);
	},

	reloadWin : function (to)
	{
		if (to == false)
		{
			window.location = window.location.href;
		}
		else
		{
			window.location = to;
		}
	},
	
/** from this **/
	showHide : function (id, parent)
	{
        var items = $(parent).getElementsByClassName('promo-body');
        
        for (i=0;i<items.length;i++)
        {
            if($(items[i]).id == id)
            {
               $(items[i]).style.display = 'block'; 
            }
            else
            {
               $(items[i]).style.display = 'none';  
            }
        }
	},
	
	activePager : function (id, parent)
	{
	    var items = $(parent).getElementsByClassName('promo-box-pager-link');
        
        for (i=0;i<items.length;i++)
        {
            if($(items[i]).id == id)
            {
               //$(items[i]).class = 'promo-box-pager-link promo-box-pager-link-active';
               $(items[i]).setAttribute("class", "promo-box-pager-link promo-box-pager-link-active");  
               $(items[i]).setAttribute("className", "promo-box-pager-link promo-box-pager-link-active");
            }
            else
            {
               $(items[i]).setAttribute("class", "promo-box-pager-link");  
               $(items[i]).setAttribute("className", "promo-box-pager-link");
               //$(items[i]).class = 'promo-box-pager-link';  
            }
        }

	}

};