/*
 * AUTHOR & LICENCE
 * 
 * @category   playnik.com
 * @package    playnik.com
 * @copyright  Copyright (c) 2008/2009 Marc Fuehnen
 * @license    http://www.marcfuehnen.com
 */

function checkBox(id) {

	if ($('#' + id).attr('checked') == true) {
	
		$('#' + id).val('');
		
	} else {
	
		$('#' + id).val('yes');
	}
	
}

function showToolTip(field) {

	$(".tooltip").hide();
	$('#' + field).fadeIn(100);
	setTimeout("hideToolTip('" + field + "')",4000);
	
}

function hideToolTip(field) {

	$('#' + field).fadeOut(400);
	
}

function hideAllToolTips() {
	
	$(".tooltip").fadeOut(400);
	
}

function ajax_changeLanguage(token) {		
	
	var url 		= unescape(window.location.pathname);
	
	var check = window.location.hostname.split('.');

	if (check.length > 2 && window.location.hostname != 'dev.playnik.it') {
		var sub = window.location.hostname;
	} else {
		var sub = 'de.' + window.location.hostname;
	}
	
	$.ajax({
			
		type: 		'POST',
		url:		'http://' + sub,
	  	data:		{ajax:true,action:'change_language',token:token,ajax_change_language:true},
		cache: 		false,
	  	success: 	function(html){

			// refresh page, no history
			window.location.replace(url); 
	  
	  	}
	
	});	

}

function ajax_addReport(support_case,support_item,support_parent,node_id) {		
		
	$('#report_' + node_id).html(lang_request);	
		
	$.ajax({
			
		type: 		'POST',
		url:		url_ajax,
	  	data:		{ajax:true,action:'new_report',support_case:support_case,support_item:support_item,support_parent:support_parent,ajax_add_report:true},
		cache: 		false,
	  	success: 	function(html){

			if (html != lang_ajax) {

				$('#report_' + node_id).html(lang_takecare);	 
	  
	  		}
	  
	  	}
	
	});	

}

function ajax_blockUser(node_id,user_id) {		
		
	$('#block_' + node_id).html(lang_request);	
		
	$.ajax({
			
		type: 		'POST',
		url:		url_ajax,
	  	data:		{ajax:true,action:'new_block',user_id:user_id,ajax_add_block:true},
		cache: 		false,
	  	success: 	function(html){

			// if no error ..
			if (html == '1') {

				$('#block_' + node_id).html(lang_blocked);	 
	  
	  		// if error ...
	  		} else {
	  		
	  			$('#block_' + node_id).html(html);
	  		
	  		}
	  
	  	}
	
	});	

}

function linkTo(optVal){
	
	if(optVal == "") {
	
		return false;	
		
	} else {
		
		window.open(optVal);
	
	}

}

/*
* *********************************************************
* POPUP
* *********************************************************
*/

function popup(file, windowname, features){

	mywindow = window.open(file, windowname, features);
	mywindow.focus();

	return false;

}

/*
 * *********************************************************
 * CHANGE VISIBILITY
 * *********************************************************
 */

function makeVisible(id) {
	
	$("#" + id).css("visibility","visible");
	
}

function makeHidden(id) {
	
	$("#" + id).css("visibility","hidden");
	
}
