/**
/* ajax modul action 
*/
/*function ajax(url, params, method, onSuccessFunction)
{
	if (!params) var params = new Object();
	if (!method) var method = 'get';
	
	//activateProcessingIcon();
	
	new Ajax.Request(url, {
				 				method:method,
								parameters:params,
								onSuccess: onAjaxSuccess.bind(null, onSuccessFunction)
					 		}
						);
}

function onAjaxSuccess(runFunction, transport)
{
	runFunction(transport);
	//deactivateProcessingIcon();
}*/
function changeDetailImage (imageURL)
{
	$('productDetailImage').src = imageURL;
}
function copyInvoiceData(prefix)
{
	$(prefix + 'DeliveryName').value = $(prefix + 'Name').getValue();
	$(prefix + 'DeliverySurname').value = $(prefix + 'Surname').getValue();
	$(prefix + 'DeliveryCompany').value = $(prefix + 'Company').getValue();
	$(prefix + 'DeliveryStreet').value = $(prefix + 'Street').getValue();
	$(prefix + 'DeliveryCity').value = $(prefix + 'City').getValue();
	$(prefix + 'DeliveryZip').value = $(prefix + 'Zip').getValue();

} 

function tooglePasswordInput (checkbox, inputHolder, params)
{
	var oldValue = ($(params.id).value);	
	if (checkbox.checked)
	{
		$(inputHolder).update('<input id="'+params.id+'" type="text" name="'+params.name+'" class="'+params.className+'"/>')
	}
	else
	{
		$(inputHolder).update('<input id="'+params.id+'" type="password" name="'+params.name+'" class="'+params.className+'"/>')
	}
	$(params.id).value = oldValue;
	
}


function setDeliveryType(type)
{
	
	var deliveryTypeList = $$('div#deliveryTypeSection div.item.selected');
	for (var i=0; i < deliveryTypeList.length; i++)
	{
		deliveryTypeList[i].removeClassName('selected');
	}	
	//vysvietenie aktivneho
	if ($('deliveryTypeHolder_'+type.value)) $('deliveryTypeHolder_'+type.value).addClassName('selected');
	
	if (type.value == 'self') 
	{
		if ($('onlinePaymentTypeHolder')) $('onlinePaymentTypeHolder').show();
	}
	else
	{
		if ($('onlinePaymentTypeHolder')) $('onlinePaymentTypeHolder').hide();
	}

}
function updateDeliveryType(ajaxResponse)
{
	$('deliveryTypeSection').update(ajaxResponse.responseText);	
}
function setPaymentType(type)
{
		//vysvietenie
	var paymentTypeList = $$('div#paymentTypeSection div.item.selected');
	for (var i=0; i < paymentTypeList.length; i++)
	{
		paymentTypeList[i].removeClassName('selected');
	}	
	//vysvietenie aktivneho
	if ($('paymentTypeHolder_'+type.value)) $('paymentTypeHolder_'+type.value).addClassName('selected');
	
	if (type.value == 'online') 
	{
		if ($('onlinePaymentTypeHolder')) $('onlinePaymentTypeHolder').show();
	}
	else
	{
		if ($('onlinePaymentTypeHolder')) $('onlinePaymentTypeHolder').hide();
	}
	
	var params = new Object();	
	params['paymentType'] = type.value;	
	ajax("/order/get-delivery-type", params, "get", updateDeliveryType); 
} 



function setOnlinePaymentType(type)
{
		//vysvietenie
	
	var paymentTypeList = $$('div#onlinePaymentTypeHolder div.onlineItem.selected');
	for (var i=0; i < paymentTypeList.length; i++)
	{
		
		paymentTypeList[i].removeClassName('selected');
	}	
	//vysvietenie aktivneho
	if ($('paymentTypeHolder_'+type.value)) $('paymentTypeHolder_'+type.value).addClassName('selected');	
	
	
	var params = new Object();	
	params['paymentType'] = type.value;	
	ajax("/order/get-delivery-type", params, "get", updateDeliveryType); 
	
} 



function setIssuePlace(type)
{
	var paymentTypeList = $$('div#onlinePaymentTypeHolder div.onlineItem.selected');
	for (var i=0; i < paymentTypeList.length; i++)
	{
		paymentTypeList[i].removeClassName('selected');
	}	
	//vysvietenie aktivneho
	if ($('paymentTypeHolder_'+type.value)) $('paymentTypeHolder_'+type.value).addClassName('selected');	
} 



function pathSuggestionShown(id)
{
	if($(id)) $(id).addClassName('active');
}

function pathSuggestionHidden(id)
{
	if($(id)) $(id).removeClassName('active');
}

var categoryDescAnim = false;
function toggleCategoryDescription()
{
	if(categoryDescAnim) return;
	if($('categoryDescriptionBt').hasClassName('active'))
	{
		$('categoryDescriptionBt').removeClassName('active');
		Effect.SlideUp('categoryDescription', {duration: 0.5, afterFinish: categoryDescAnimEnd});
		Cookies.create('hideCategoryDescription', 1, 365);
		categoryDescAnim = true;
	}
	else
	{
		$('categoryDescriptionBt').addClassName('active');
		Effect.SlideDown('categoryDescription', {duration: 0.5, afterFinish: categoryDescAnimEnd});
		Cookies.create('hideCategoryDescription', 0, 365);
		categoryDescAnim = true;
	}
}

function categoryDescAnimEnd()
{
	categoryDescAnim = false;
}


function changeDetailPrice()
{
	$('detailPreloader').show(); 
	$('viewPriceWithVat').value = ($('priceWithVatCheckbox').checked ? 1 : 0); 
	$('vatForm').submit(); 
	$('detailPreloader').setStyle({backgroundImage: 'url(/images/loading-universal.gif)'}); 
}

function changeDetailBottomPrice()
{
	$('detailBottomPreloader').show(); 
	$('viewPriceWithVatBottom').value = ($('priceWithVatCheckboxBottom').checked ? 1 : 0); 
	$('vatFormBottom').submit(); 
	$('detailBottomPreloader').setStyle({backgroundImage: 'url(/images/loading-universal.gif)'}); 
}
