$(document).ready(function() {	
	enableTooltip('contentBox');
	$(".hover").hover(
			  function () {
			    $(".hoverClass").show('slow');
			  }, 
			  function () {
				  $(".hoverClass").hide('slow');
			  }
			);
	/*setInterval(function(){
	  	alert('hi');
	  },10000);*/
});

function closeClass(id) {
	$('.' + id).css('display', 'none');
}
function disposeClass(id) {
	$('.' + id).remove();
}
function disposeClassFade(id) {
	$('.' + id).fadeOut('slow', function () {$('.' + id).remove();});
}
function closeClassFade(id) {
	$('.' + id).fadeOut('slow');
}
function showClassFade(id) {
	$('.' + id).fadeIn('slow');
}
function dispose(id) {
	$('#' + id).remove();
}
function enableTooltip (id) {
	$('#' + id + ' *').tooltip({ 
	    track: true, 
	    delay: 600, 	    
	    showURL: false
	});
}
function changeSite(host, site, id, boxid, ref){
	if(site == 'member-comments')
		loaderID = 'guestbook';
	else
		loaderID = boxid;
  $(document).ready(function(){
      $.ajax({
        url: host+'index.php',
        cache: false,
        type: 'GET',    
        data: {ajax: 'true', site: site, id: id, ref: ref, box:boxid},
        beforeSend: function() {         	                          
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'block');
        },
        error: function() {        	
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'none');
        },
        success: function( neueDaten ){
        	if(boxid == 'filesUploaded')
        		$('#'+boxid).append( neueDaten );
        	else
        		$('#'+boxid).html( neueDaten );
        	enableTooltip(boxid);
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'none');
        }
      });
	});
}
function changeSiteFade(host, site, id, boxid, ref){
	if(site == 'member-comments')
		loaderID = 'guestbook';
	else
		loaderID = boxid;
  $(document).ready(function(){
      $.ajax({
        url: host+'index.php',
        cache: false,
        type: 'GET',    
        data: {ajax: 'true', site: site, id: id, ref: ref, box:boxid},
        beforeSend: function() {         	                          
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'block');
        	$('#'+boxid).fadeTo(100, 0.0);
        },
        error: function() {        	
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'none');
        },
        success: function( neueDaten ){
        	if(boxid == 'filesUploaded')
        		$('#'+boxid).append( neueDaten );
        	else {
        		$('#'+boxid).fadeTo(1500, 1.0);
        		$('#'+boxid).html( neueDaten );
        	}
        	enableTooltip(boxid);
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'none');
        }
      });
	});
}
function changeSiteDelete(host, site, id, boxid, ref){
  $(document).ready(function(){
      $.ajax({
        url: host+'index.php',
        cache: false,
        type: 'GET',    
        data: {ajax: 'true', site: site, id: id, ref: ref, box:boxid},
        beforeSend: function() {         	                          
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'block');
        },
        error: function() {        	
        	$('#'+loaderID).find('.ajaxLoader').css('display', 'none');
        },
        success: function( neueDaten ){
        	$('#'+boxid).fadeOut('slow');
        }
      });
	});
}
function sendData(host, site, id, boxid, form){
  $(document).ready(function(){  	  
  	  myArray = $('#'+form).serialize();
      $.ajax({
        url: host+'index.php',        
        cache: false,
        type: 'POST',    
        data: {ajax: 'true', site: site, id: id, myArray: encodeURIComponent(myArray)},
        beforeSend: function() {                            
        	$('#'+boxid).find('.ajaxLoader').css('display', 'block');                		     
        },
        error: function() {
        	$('#'+boxid).find('.ajaxLoader').css('display', 'none');
        },
        success: function( neueDaten ){                	           
            $('#'+boxid).html( neueDaten ); 
            enableTooltip(boxid);
        }
      });
	});
} 
function initUpload(host, boxid, folder, ref, id, button) {
	$('#uploadify').uploadify({
	'uploader'  : host + 'uploadify/uploadify.swf',
	'script'    : host + 'uploadify/uploadify.php',
	'cancelImg' : host + 'images/icons/cross.png',
	'buttonText': button,
	'queueID'   : 'fileQueue',
	'fileDesc'  : '*.gif;*.jpg;*.png',
	'fileExt'	: '*.gif;*.jpg;*.png', 
	'scriptData': {'ref': ref, 'id': id},
	'onComplete': function(event, queueID, fileObj, response, data) {
		changeSite(host, ref, response, boxid, ref);
	},
	'auto'      : false,
	'folder'    : host + folder,
	'multi'     : true
	});
}
function subNumber(id) {
	number = $('#'+id).find('span').html();
	number = parseInt(number)-1;
	$('#'+id).find('span').html(number);
}
function addNumber(id) {	
	number = $('#'+id).find('span').html();	
	number = parseInt(number)+1;	
	$('#'+id).find('span').html(number);
}
function setValue(id, value) {
	$('#'+id).html(value);
}
function setVisible(id) {
	$('#'+id).css('display', 'block');
}
function checkUncheck(object, form) {		
	if(object.checked == true)
		$('#'+form).find("input:checkbox").attr("checked","checked");	
	else
		$('#'+form).find("input:checkbox").attr("checked","");
}
function check(id) {
	var object = $('#'+id+':checked');
	if(object.val() != null)
		$('#'+id).attr("checked","");
	else
		$('#'+id).attr("checked","checked");	
}
function checky(id) {
	var object = $(id).find("input:checkbox");
	if(object.attr("checked") == true)
		$(id).find("input:checkbox").attr("checked","");
	else if(object.attr("checked") == false)
		$(id).find("input:checkbox").attr("checked","checked");	
	else if($(id).attr("checked") == true)
		$(id).attr("checked","");
	else if($(id).attr("checked") == false)
		$(id).attr("checked","checked");
}
function addScreen(boxid) {
	number =  parseInt($('#'+boxid).find('.number:last').html()) + 1;
	screenHead = $('#'+boxid).find('.lang:last').html();
	lang2 = $('#'+boxid).find('.lang2:last').html();
	lang3 = $('#'+boxid).find('.lang3:last').html();
	lang4 = $('#'+boxid).find('.lang4:last').html();
	html =  "<span class=\"lang\">"+screenHead+"</span> <span class=\"number\">"+number+"</span>" +
			"<div class=\"quote\">"+
			"  <ul>"+screenHead+"</ul>"+
			"</div>"+
			"<div class=\"fieldsetInput\">" +
			"  <p class=\"pictureText\"><input name=\"rm2k_screen[]\" type=\"file\" /></p>" +
			"</div>" +
	        "<div class=\"quote\">" +
    	    "	<ul>"+lang2+"</ul>" +
    		"</div>" +
			"<div class=\"fieldsetInput\">" +
			"  <p class=\"pictureText\"><input name=\"rm2k_title[]\" value=\"\" /></p>" +
			"</div> " +
			"<div class=\"quote\">" +
			"  <ul>"+lang3+"</ul>" +
			"</div>" +
			"<div class=\"fieldsetInput\">" +
			"  <p class=\"pictureText\"><textarea name=\"rm2k_text[]\" rows=\"6\"></textarea></p>" +
			"</div> " +
			"<div class=\"fieldsetInput\" style=\"position:relative;\" onclick=\"check(\'newTitle_"+number+"\');\">"+lang4+": <input onclick=\"check(\'newTitle_"+number+"\');\" type=\"checkbox\" class=\"checkbox\" name=\"newTitle\" id=\"newTitle_"+number+"\" value=\"'"+number+"'\"></div>" +
			"<br />";	
	$('#'+boxid).append(html);
}
function changeDropBox(object, id) {
	if(object.value == 'other')
		$('#'+id).css("display", "block");
	else 
		$('#'+id).css("display", "none");
	
}
function addNewFile(object, name) {
	html = "<input class=\"rm2k_Gametext\" type=\"file\" name=\"" + name + "[]\" />"
	$('#'+object).append(html);
}

function changeBGImage(object) {
	$(object).css("background-image", "url(../images/ajax-loader.gif)");
}
function changeHead(section) {
	$
}
