$('.options select').change(function () {
    var id  = $(this).attr('id');

    if( id == g1 ) {
        gs1 = $(this).val();
    } else if( id == g2 ) {
        gs2 = $(this).val();
    }

    var img = 'uploads/product/front_n/' + imgdata['0'];
    if( imgdata['_' + gs1 + '_' + gs2] ) {
        img = 'uploads/product/img_n/' + imgdata['_' + gs1 + '_' + gs2];
    }
    
    $('#prod_img').attr('src', img);

    if( id == pg1 ) {
        pgs1 = $(this).val();
    } else if( id == pg2 ) {
        pgs2 = $(this).val();
    }

    $('#pprice').html(pricedata['_' + pgs1 + '_' + pgs2]);
    
    if( pricedata['_' + pgs1 + '_' + pgs2 + '_a'] != '' ) {
        $('#pprice_a').html(pricedata['_' + pgs1 + '_' + pgs2 + '_a']);
        $('#product-info .akcios').css('display', 'block');
    } else {
        $('#pprice_a').html('');
        $('#product-info .akcios').css('display', 'none');
    }

    if( fpricedata['_' + pgs1 + '_' + pgs2] ) {
        $('#ajid span').html(fpricedata['_' + pgs1 + '_' + pgs2]);
	$('#ajid').css('display', 'block');
    } else {
	$('#ajid span').html('');
	$('#ajid').css('display', 'none');	
    }
}).change();

    if( pricedata['_' + pgs1 + '_' + pgs2 + '_a'] != '' ) {
        $('#pprice_a').html(pricedata['_' + pgs1 + '_' + pgs2 + '_a']);
        $('#product-info .akcios').css('display', 'block');
    } else {
        $('#pprice_a').html('');
        $('#product-info .akcios').css('display', 'none');
    }

//    if( fpricedata['_0_0'] ) {
    if( fpricedata['_' + pgs1 + '_' + pgs2] ) {
        $('#ajid span').html(fpricedata['_' + pgs1 + '_' + pgs2]);
	$('#ajid').css('display', 'block');
    } else {
	$('#ajid span').html('');
	$('#ajid').css('display', 'none');	
    }


function show_szr() {
    var img = 'uploads/product/szr/' + szr[0];
    var html    = '<img id="bigimg" style="float:left" src="' + img + '" />';

    html    += '<div style="height:600px;overflow:auto;"><div style="width:80px;">';
    for(i=0;i<szr.length;i++) {
        html    += '<img width="70" height="70" style="padding:5px;cursor:pointer;" src="uploads/product/szr/' + szr[i] + '" onclick="javascript:setBISzr(\'' + szr[i] + '\');" />';
    }
    html    += '</div></div>';

    $.nyroModalManual({
        content: html,
        minHeight: 600,
        minWidth: 715,
        autoSizable: false
    });

    return false;
}

function setBImage(id) {
    $('#bigimg').attr('src', 'uploads/product/img_b/' + id);
}

function setBImage2(id) {
    $('#bigimg').attr('src', 'uploads/product/front_b/' + id);
}

function setBISzr(id) {
    $('#bigimg').attr('src', 'uploads/product/szr/' + id);
}

function show360(id) {
    var html = '<embed src="uploads/product/d360/' + id + '.mov" autoplay="true" width="500" height="500"><noembed>A videó lejátszásához Quick Time player szükséges. A lejátszó innen letölthető:  &lt;a href="http://www.apple.com/quicktime/download/"&gt;http://www.apple.com/quicktime/download/&lt;/a&gt;</noembed>'

    $.nyroModalManual({
        content: html
    });
}
$(document).ready(function() {
    $('#prod_img').click(function () {
        var img = 'uploads/product/front_b/' + imgdata['0'];
        if( imgdata['_' + gs1 + '_' + gs2] ) {
            img = 'uploads/product/img_b/' + imgdata['_' + gs1 + '_' + gs2];
        }

        var html    = '<img id="bigimg" style="float:left" src="' + img + '" />';

        html    += '<div style="height:600px;overflow:auto;"><div style="width:80px;">';
	html    += '<img style="padding:5px;cursor:pointer;" src="uploads/product/front_s/' + imgdata[0] + '" onclick="javascript:setBImage2(\'' + imgdata[0] + '\');" />';
        for(i=0;i<images.length;i++) {
            html    += '<img style="padding:5px;cursor:pointer;" src="uploads/product/img_s/' + images[i] + '" onclick="javascript:setBImage(\'' + images[i] + '\');" />';
        }
        html    += '</div></div>';

        $.nyroModalManual({
            content: html,
            minHeight: 600,
            minWidth: 715,
            autoSizable: false
        });

        return false;
    });
    $('#more_vid img').click(function () {
        var n   = 1;
        if( $(this).attr('id') == 'mv_2' ) {
            n   = 2;
        }
        var tmp = viddata[0];
        viddata[0]  = viddata[n];
        viddata[n]  = tmp;
        tmp = vidimgdata[0];
        vidimgdata[0]    = vidimgdata[n];
        vidimgdata[n]    = tmp;

        $('#main_vid').html(viddata[0]);
        $('#mv_' + n).attr('src', vidimgdata[n]);
    });
});

function product_send(pid) {
    var	html	= '<form id="send_prod" method="post" action=""><blockquote>';    
    html	+= '<h1>Küldés ismerősnek</h1><hr />';
    html	+= 'Név: <br /><input type="text" size="45" name="mail_mail1" /><br /><br />';
    html	+= 'E-mail (fogadó): <br /><input type="text" size="45" name="mail_mail2" /><br /><br />';
    html	+= 'Szöveg:<br />';
    html	+= '<textarea cols="60" rows="7" name="mail_text"></textarea>';
    html	+= '<div align="center"><input type="submit" value="elküld" /></div>';
    html	+= '<input type="hidden" name="pid" value="' + pid  + '" />';
    html	+= '<input type="hidden" name="action" value="sendp" />';
    html	+= '</blockquote></form>';
    
    $.nyroModalManual({
	content	: html,
	css : {
	    content : {
		'background-color': '#ffffff'
	    }
	}
    });
}

function product_show_hasonlo(url, l, t) {
    var	n	= pricedata['_' + pgs1 + '_' + pgs2 + '_n'];
    var	nl	= Math.round(n * ( 1 - l / 100 ));
    var	nt	= Math.round(n * ( 1 + t / 100 ));

    document.location	= 'product/list/' + url + '?lt=' + nl + '&t=' + nt;
}
