$(document).ready(function () {

	$(".pager_container").pager("div.pager");
	$(".readMore").click(function(){
		$(this).hide(500, function() {
			this.innerHTML='<br />';
			this.style.display='none';
		});
		$(this).next(".panelBody").slideToggle(500)
		return false;
	});

	$("#content .panelBody").hide();
	
	$(".showSpoiler").click(function(){
		$(this).hide(500, function() {
			this.innerHTML='<br />';
			this.style.display='none';
		});
		$(this).next(".spoiler").slideToggle(500)
		return false;
	});

	$("#content .spoiler").hide();
	$('input#suggestBox2').jsonSuggest(testData.webSites, {onSelect:callback});
});

function callback(item) {
	alert('You selected \'' + item.text + '\'\n\nHere is the full selected JSON object;\n' + JSON.stringify(item));
}

jQuery(function() {	
	$('input#suggestBox').jsonSuggest(testData.webSites);
});

$(document).ready(function(){
	$('#references').galleryView({
	show_panels: false,
	show_filmstrip: true,
	panel_width: 600,
	panel_height: 300,
	frame_width: 600,
	frame_height: 235,
	frame_opacity: 0.3,
	filmstrip_size: 4,
	filmstrip_size: 1,
	nav_theme: 'light',
	easing: '',
    	transition_speed: 800,
    	transition_interval: 4000,
	pause_on_hover: true
	});
});


$.fx.speeds._default = 1000;

	$(function() {
		$("#dialog").dialog({
			autoOpen: false,
			show: 'blind',
			hide: 'blind',
			height: 450,
			width: 600,
			resizable: false,
			draggable: false,
			modal: true
		});
		
		$('.opener').click(function() {
			$('#dialog').dialog('open');
			return false;
		});

	});



function addSpoilerTag() {
	document.getElementById('comment').value+='[spoiler] [/spoiler]';
}

function addTag(tag) {
	document.getElementById('comment').value+=' ['+tag+'][/'+tag+'] ';
}

function username_0()
{
	if (document.getElementById('username').value == 'Konzol ID') {
		document.getElementById('username').value = '';
	}
}
function username_1()
{
    if (document.getElementById('username').value == '') {
		document.getElementById('username').value = 'Konzol ID';
	}
}

function password_0()
{
	if (document.getElementById('password').value == 'password') {
		document.getElementById('password').value = '';
	}
}
function password_1()
{
    if (document.getElementById('password').value == '') {
		document.getElementById('password').value = 'password';
	}	
}

function activateAvatarChange()
{
	document.getElementById('avatarChanger').innerHTML='<form enctype="multipart/form-data" method="post" action="/profile.php?action=modAvatar"><input name="pictureId" type="file" /><button>Feltöltés</button></form>';
}

function confirmDeleteTopic(id, name, forum_id)
{
var agree=confirm("Biztosan törölni szeretné a következõ fórumtémát: "+name+"?");
if (agree)
	window.location="/forum.php?action=delTopic&id="+id+'&fid='+forum_id;
else
	return false ;
}

function confirmDeleteForum(id, name)
{
var agree=confirm("Biztosan törölni szeretné a következõ fórumot: "+name+"?");
if (agree)
	window.location="/forum.php?action=delForum&id="+id;
else
	return false ;
}

function addUserbar()
{
	link=prompt("A userbar linkje:","");
	if(link!=null)
		document.getElementById('forumSign').value += '<img src="'+link+'" alt="userbar" />';
}

function modifyComment(id) {
	document.getElementById('ajaxIframe').src='/forumComment.php?id='+id;
	$('#ajaxIframe').load(function() {
		document.getElementById('commentText-'+id).innerHTML=document.getElementById('ajaxIframe').document.body.innerHTML;
	});
}

function domainCheck() {
	var domain=document.getElementById('domain').value;
	document.getElementById('ajaxIframe').src='/domainCheck.php?domain='+domain;
}

function newDomainStatus() {
	if(!document.getElementById('new').checked) {
		document.getElementById('domain').disabled=true;
		document.getElementById('domainCheckBtn').disabled=true;
		document.getElementById('newDomainP').style.color='grey';
	} else {
		document.getElementById('domain').disabled=false;
		document.getElementById('domainCheckBtn').disabled=false;
		document.getElementById('newDomainP').style.color='#2e2e2e';	
	}
	
	if(!document.getElementById('have').checked) {
		document.getElementById('haveDomain').disabled=true;
		document.getElementById('haveDomainP').style.color='grey';
	} else {
		document.getElementById('haveDomain').disabled=false;
		document.getElementById('haveDomainP').style.color='#2e2e2e';	
	}
}

function showTooltip(id) {
	document.getElementById('tooltip-'+id).style.display='inline';
}

function hideTooltip(id) {
	document.getElementById('tooltip-'+id).style.display='none';
}

function checkDependencies(id) {
	var dependencies=document.getElementById('dependencies-'+id).innerHTML;
	var dep='';
	if(document.getElementById('function-'+id).checked!=false) {
		for(var i=0; i<dependencies.length; i++) {
			if(dependencies.charAt(i)==',') {
				document.getElementById('function-'+dep).checked=true;
				dep='';
				
			} else {
				dep+=dependencies.charAt(i);
			}
		}
	}
}

function checkFilledWizard() {
	var nev=document.getElementById('nev').value;
	var ceg=document.getElementById('ceg').value;
	var telefon=document.getElementById('telefon').value;
	var email=document.getElementById('email').value;
	if(!nev|!ceg|!telefon|!email) {
		document.getElementById('statusReport').innerHTML='<font color="red">Kérjük minden mezőt töltsön ki!</font>';
	}
	else {
		document.getElementById('wizardForm').submit();
	}
}



