$(document).ready(function()
{
	$('#otherCountriesToggle').click(function()
	{
		troggleOptions($('#otherCountriesToggle'), $('#otherCountriesOptions'), $('#otherCountriesOptions2'))
	});

	$('#promoTypesPublisherToggle').click(function()
	{
		troggleOptions($('#promoTypesPublisherToggle'), $('#promoTypesPublisherOptions'))
	});

	$('#promoTypesCustomerToggle').click(function()
	{
		troggleOptions($('#promoTypesCustomerToggle'), $('#promoTypesCustomerOptions'))
	});
});

function troggleOptions(troggleNode, optionsNode, optionsNode2)
{
	optionsNode.slideToggle("fast");
	if ( optionsNode2 ) optionsNode2.slideToggle("fast");

	troggleNode.toggleClass('open');
}


function sendMMCRegLink() {
	var count = document.URL.match(/mmc/);
	if(count!=null) {
		location.href='http://myshop.zanox.com/easyshopat/registration';
	} else {
		location.href='https://ui.zanox-affiliate.de/bin/z_in_frm.dll?1001100210030&0C0&11144_54225';
	}
}

function sendMMCPassLink() {
	var count = document.URL.match(/mmc/);
	if(count!=null) {
		location.href='http://myshop.zanox.com/easyshopat/pwForgotten';
	} else {
		location.href='https://ui.zanox-affiliate.de/bin/z_in_frm.dll?1001100410010&0C0&11144_201_82';
	}
}
function formSubmit(fo)
{
	dwr.util.useLoadingMessage();
	formBean.getFormInfo(fo.login.value, function(formInfo)
	{
		if (null == formInfo)
		{
			window.location = 'http://www.zanox.com:80/logindispatcher/jsp/de/error.jsp';
		}
		else
		{
			fo.action = formInfo.action;
			fo.login.name = formInfo.userNameParam;
			fo.password.name = formInfo.passwordParam;
			fo.submit();
		}
	});
	return false;
}

function setPromoUrl(appUrl)
{
	var country = $('input[@name="country"]:checked').val();
	var industry = $('input[@name="industry"]:checked').val();
	var subtype = $('input[@name="promoType"]:checked').val();
	var sort = $('input[@name="sortBy"]:checked').val();

	var url = appUrl + '/promo?country=' + country + '&vertical=' + industry + '&subtype=' + subtype + '&sort=' + sort + '&output=html';

	document.location.href = url;
}

function setProgramUrl(appUrl, isTop10)
{
	var country = $('input[@name="country"]:checked').val();
	var type = isTop10 ? 'adrank' : 'latest';
	var sort = $('input[@name="sortBy"]:checked').val();

	var url = appUrl + '/program?country=' + country + '&type=' + type + '&sort=' + sort + '&output=html';

	document.location.href = url;
}
