function openColourPage(num) {
    var ajax = new myAjax();
    ajax.action = 'openColourPage';
    ajax.post('classer=Dekoral&id=' + num);

    $('#preloader').show().css('opacity', '0.8');

    ajax.onLoad = function() {
        $('#preloader').hide();
        var resp = this.response;
        if (resp.substr(0, 3) != 'nok') {

            $('#color_sampleMain').html(resp).css('height', $('body').css('height')).fadeIn('slow');
            $('html').animate({scrollCenter : 0}, 500, function() {

                    var sifrColor = $('#color_sample').css('color');
		   var sifrColorHexString = getColorHex( sifrColor );
                    sIFR.replace(stag, {
                        selector: 'h2.sample-header-h2'
                        ,css: {
                            '.sIFR-root': {
                                'color':sifrColorHexString
                                ,'letter-spacing':'1'
                            }
                        }
                    });

                    sIFR.replace(stag, {
                        selector: 'h3.sample-header-h3'
                        ,css: [
                            '.sIFR-root {color: ' + sifrColorHexString + ';letter-spacing:1;text-align:center}'
                            ,'a {color:' + sifrColorHexString + ';text-decoration: none;}'
                            ,'a:hover {color:' + sifrColorHexString + ';text-decoration: none;}'
                        ]
                    });

                });
        }

    }
}

function getColorHex( sifrColor ) {
    sifrColor = trim( sifrColor );
     if( sifrColor.match( /^#\d{6}$/ )) {
	var sifrColorHexString = sifrColor;
    } else {
	var parts = sifrColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	delete (parts[0]);
	for (var i = 1; i <= 3; ++i) {
	    parts[i] = parseInt(parts[i]).toString(16);
	    if (parts[i].length == 1) parts[i] = '0' + parts[i];
	}
	var sifrColorHexString = '#' + parts.join('');
    }
    return sifrColorHexString;
}

function changeColourPage(num) {
    var ajax = new myAjax();
    ajax.action = 'openColourPage';
    ajax.post('classer=Dekoral&id=' + num);
    ajax.onLoad = function() {
        var resp = this.response;
        if (resp.substr(0, 3) != 'nok') {
            $('#color_sampleMain').animate({ 'opacity':'0.3' }, 300, function() {
                    $(this).html(resp).animate({ 'opacity':'1' }, 'slow', function() {

                            var sifrColor = $('#color_sample').css('color');
			    var sifrColorHexString = getColorHex( sifrColor );

                            sIFR.replace(stag, {
                                selector: 'h2.sample-header-h2'
                                ,css: {
                                    '.sIFR-root': {
                                        'color':sifrColorHexString
                                        ,'letter-spacing':'1'
                                    }
                                }
                            });

                            sIFR.replace(stag, {
                                selector: 'h3.sample-header-h3'
                                ,css: [
                                    '.sIFR-root {color:' + sifrColorHexString + ';letter-spacing:1;text-align:center}'
                                    ,'a {color:' + sifrColorHexString + ';text-decoration: none;}'
                                    ,'a:hover {color:' + sifrColorHexString + ';text-decoration: none;}'
                                ]
                            });

                        });
                });
        }
    }
}

function closeColourPage() {
    $('#color_sampleMain').fadeOut('slow', function() {
        $(this).html('');
    });
}

