$(document).ready(function() {
	ArticlePrice.init();
	SelectSameLevelGroups.init();
	
	$('#downloads').bind('change', function() {
		//alert(this.value);
		if (this.value > '0') {
			Browser.gotoHref('articles/index/downloadupload/item_id/' + this.value);
		}        
    });
    
    $('#button_spy').bind('click', function() {
			//alert('Artikel wird in Warenkorb gelegt.');
            var articleNumber = $('#id_article_number_internal_0').html();
            var count = $('.article_count_details').val();
            
			Article.toSpy(articleNumber , count);
	});
    
    
	
	$('div.details-downloads-pattern select').bind('change', function() {
		//alert(this.value);
		//alert(this.id);		
		if (this.value > '0') {
			Browser.gotoHref('articles/index/downloadupload/item_id/' + this.value);
		}        
    });
	
	$('div.detail-link').bind('click', function() {
		//alert();
		Browser.gotoHref(this.firstChild.innerHTML)
	});
	
	SecteoFormSelect.setValue('downloads_1','');
	
	SelectDownloads.init();
	
})
ArticlePrice = {};

ArticlePrice.init = function() {
	//alert('ArticlePrice.init');
	$('.article_price_tooltip').tooltip({
		track: true,
		delay: 0,
		showURL: false
	});
    
    $('#id_article_pictures').cycle({
        fx: 'fade',
        speed: 1000,
        pause: 1,
        next: '#id_article_pictures',
        fastOnEvent: 1//,
        //width: '223px'
    });
}

Article = {};

Article.toSpy = function (articleNumber, count){
    var link = $('#link').val();
    var param1 = $('#param1').val();
    var param2 = $('#param2').val();
    //alert(link + '/' + param1 + '/' + articleNumber + '/' + param2 + '/' + count);
    Browser.gotoHref(link + '/' + param1 + '/' + articleNumber + '/' + param2 + '/' + count)
    //alert(link + ' ' + param1 + ' ' + param2);
}

SelectSameLevelGroups = {};
SelectSameLevelGroups.init = function()
{
	$('#same_level_groups').bind('change', function() {
		Browser.redirect(this.value);
	});
}

SelectDownloads = {};
SelectDownloads.init = function()
{
	$('div.details-downloads-pattern select.SecteoStyled').bind('change', SelectDownloads.onChangeCallback);
	$('div.details-downloads-html select.SecteoStyled').bind('change', SelectDownloads.onChangeCallback);
}

SelectDownloads.onChangeCallback = function() 
{				
		var selectId = StringUtils.getSplitedAt(1, this.id,'_');
		if (typeof(selectId) == 'undefined') {
			$('#id_select_downloads').html('Downloads');
		}
		else {
			$('#id_select_downloads_' + selectId).html('Downloads');
		}
}

