var currimage=0;
var currg=0;
function prevIm(i) {
	if(i==0) {
		return;
	}
	i--;
	currimage=i;
	sh(KiJUh[i][0],KiJUh[i][1],KiJUh[i][2],currg,KiJUh[i][3],currimage);
}
function nextIm(i) {
	if((i+1)>=KiJUh.length) {
		return;
	}
	i++;
	currimage=i;
	sh(KiJUh[i][0],KiJUh[i][1],KiJUh[i][2],currg,KiJUh[i][3],currimage);

}
function sh(im,w,h,gid,lab,x) {
	if(lab=='') {
		var lab2='&nbsp;';
	} else {
		var lab2=lab;
	}
	var image='<img src="/images/gallery/'+im+'" style="width:'+w+'px;height:'+h+'px;border:1px solid #b1b1b4" alt="'+lab+'" title="'+lab+'">';
	image+='<table border="0" cellpadding="0" cellspacing="0" width="100%"><col width="60"><col width="*"><col width="60"><tr><td style="padding:4px 0">';
	image+='<a id="pp" href="javascript:prevIm('+x+')"><img src="/images/2008/left.gif" style="width:56px;height:18px;border:0" alt="" title=""></a></td><td style="font-size:12px;padding:4px 0" align="center">'+lab2+'</td><td style="padding:4px 0" align="right"><a id="nn" href="javascript:nextIm('+x+')"><img src="/images/2008/right.gif" style="width:56px;height:18px;border:0" alt="" title=""></a></td></tr></table>';

	$('#g-'+gid).html(image);
	if(KiJUh.length==(x+1)) {
		//$('#nn').style.display='none';
		$('#nn').hide();
	} else {
		//$('#nn').style.display='inline';
		$('#nn').show();
	}
	if(x==0) {
		$('#pp').hide();
	} else {
		$('#pp').show();
	}
}
function array_chunk( input, size ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
    // *     example 1: array_chunk(['Kevin', 'van', 'Zonneveld'], 2);
    // *     returns 1: {0 : {0: 'Kevin', 1: 'van'} , 1 : {0: 'Zonneveld'}}

    for(var x, i = 0, c = -1, l = input.length, n = []; i < l; i++){
        (x = i % size) ? n[c][x] = input[i] : n[++c] = [input[i]];
    }

    return n;
}
function array_shift( array ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: array_shift(['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: 'Kevin'

    var i=0, first_elm=null, cnt=0, tmp_arr = {};

    // input sanitation
    if( !array || (array.constructor !== Array && array.constructor !== Object) || !array.length ){
        return null;
    }

    if( array.constructor === Array ){
        first_elm = array[0];
        for( i = 0; i < array.length; i++ ){
            array[i] = array[i+1];
        }
        array.length--;
    } else if( array.constructor === Object ){
        for(var key in array){
            if( cnt == 0 ){
                first_elm = array[key];
            } else{
                tmp_arr[key] = array[key];
            }
            cnt ++;
        }
        array = tmp_arr;
    }

    return first_elm;
}
function openWin(the_url,the_x,the_y,scrollbars)
{
    the_x -= 0;
    the_y -= 0;
    var how_wide = screen.availWidth;
    var how_high = screen.availHeight;
    var the_toolbar = "no";
    var the_addressbar = "no";
    var the_directories = "no";
    var the_statusbar = "no";
    var the_menubar = "no";
	if(scrollbars) {
		var the_scrollbars = "yes";
	} else {
		var the_scrollbars = "no";
	}
    var the_do_resize = "yes";
    var the_copy_history = "no";
    top_pos = (how_high / 2) - (the_y / 2);
    left_pos = (how_wide / 2) - (the_x / 2);
    if (window.outerWidth) {
        var option = "toolbar=" + the_toolbar + ",location=" + the_addressbar + ",directories=" + the_directories + ",status=" + the_statusbar + ",menubar=" + the_menubar + ",scrollbars=" + the_scrollbars + ",resizable=" + the_do_resize + ",outerWidth=" + the_x + ",outerHeight=" + the_y + ",copyhistory=" + the_copy_history + ",left=" + left_pos + ",top=" + top_pos;
        site = open(the_url, "DisplayWindow", option);
        var Opera = (navigator.userAgent.indexOf('Opera') !=  - 1);
        if (Opera) {
            site.resizeTo(the_x, the_y);
            site.moveTo(0, 0);
        }
    }
    else {
        var option = "toolbar=" + the_toolbar + ",location=" + the_addressbar + ",directories=" + the_directories + ",status=" + the_statusbar + ",menubar=" + the_menubar + ",scrollbars=" + the_scrollbars + ",resizable=" + the_do_resize + ",Width=" + the_x + ",Height=" + the_y + ",copyhistory=" + the_copy_history + ",left=" + left_pos + ",top=" + top_pos;
        site = open('', "DisplayWindow", option);
        site.location = the_url;
        if (site.open) {
            site.focus();
            return false;
        }
        site.resizeTo(the_x, the_y);
    }
}

function tab(NUM) {
	$("td#tab-c").html($("div#tabcontent-"+NUM).html());
	/*switch(NUM) {
	case 1:

	break;
	case 2:
	break;
	case 3:
	break;
	}*/
}
function web2share() {
	var sites = [
		['201001041854070-img.gif','http://iwiw.hu/pages/share/share.jsp?u=','IWIW'],
		['201001041853300-img.gif','http://www.facebook.com/share.php?u=','Facebook'],
		['201001041856280-img.gif','http://twitter.com/home?status=','Twitter'],
		['201001041850170-img.gif','http://del.icio.us/post?url=','Delicious'],
		['201001041855570-img.gif','http://www.tumblr.com/share?v=3&amp;u=','Tumblr.com'],
		['201001041852260-img.gif','http://digg.com/submit?phase=2&url=','Digg'],
		['201001041854340-img.gif','http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=','MySpace'],
		['201001041855160-img.gif','http://www.stumbleupon.com/submit?url=','Stumbleupon']
	];
	var sh='<b class="f12">Oszd meg, ha tetszik!</b><br>';
	for (var i = 0, item; item = sites[i]; i++) {
		sh+='<a href="'+sites[i][1]+encodeURIComponent(document.location.href)+'" target="_blank"><img src="/images/user/cikkek/'+sites[i][0]+'" style="width:24px;height:24px;border:0;margin-right:4px;margin-top:4px;" alt="'+sites[i][2]+'" title="Megosztás: '+sites[i][2]+'"></a>';
	}
	$("#w-share").css({"border-top":"1px solid #CCCCCC"}).html(sh);
}
$(document).ready(function() {
	web2share();
});
