<?php
/**
 * @package Iyosis Google Translate Module for Joomla! 1.5
 * @author Remzi Degirmencioglu
 * @copyright (C) 2011 www.iyosis.com
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<div class="jquery_translator<?php echo $params->get('moduleclass_sfx'); ?>" id="translate">
<style type="text/css">
select#translate option {
	background: url("<?php echo $baseURL; ?>modules/mod_iyosis_google_translate/tmpl/images/flags_16.png") no-repeat 0 0 transparent;
	padding-left: 19px;
}
#translate a {
	background: url("<?php echo $baseURL; ?>modules/mod_iyosis_google_translate/tmpl/images/flags_<?php echo $flagSize; ?>.png") no-repeat 0 0 transparent;
	padding: 0 5px 0 0;
	font-size: <?php echo round($flagSize-($flagSize/8)); ?>px;
	display: inline-block;
}
#translate #flag {
	width:<?php echo ($flagSize+2); ?>px;
	height:<?php echo $flagSize; ?>px;
}
select#translate option[value=""] {background: none;}
#flagcontainer {padding-bottom:3px;}
<?php
$dropDownCounter = 0;
$flagHeightCounter = 0;
$flagWidthCounter = 1;
foreach ($languages as $langcode => $language) {
	if($params->get($langcode, '1')=='0') {
		$dropDownCounter += 36;
		if ($flagSize == '16') $flagHeightCounter += 36;
		if ($flagSize == '24') $flagHeightCounter += 98;
		if ($flagSize == '32') $flagHeightCounter += 98;
		if ($flagSize == '48') $flagHeightCounter += 98;
	}
	if($params->get($langcode, '1')=='1') {
		echo "select#translate option[value=\"".$langcode."\"] {background-position: 1px -".$dropDownCounter."px;}";
		$dropDownCounter += 36;
		if ($flagSize == '16') $flagHeightCounter += 36;
		if ($flagSize == '24') $flagHeightCounter += 98;
		if ($flagSize == '32') $flagHeightCounter += 98;
		if ($flagSize == '48') $flagHeightCounter += 98;
	}
	if($params->get($langcode, '1')=='2') {
		$dropDownCounter += 2;
		$flagHeightCounter += 2;
		echo "#translate a.flag".$langcode." {background-position: -".$flagWidthCounter."px -".$flagHeightCounter."px;}";
		$dropDownCounter += 34;
		if ($flagSize == '16') $flagHeightCounter += 34;
		if ($flagSize == '24') $flagHeightCounter += 96;
		if ($flagSize == '32') $flagHeightCounter += 96;
		if ($flagSize == '48') $flagHeightCounter += 96;
	}
	if($flagHeightCounter>'1950') {
		$flagHeightCounter = 0;
		if ($flagSize == '24') $flagWidthCounter += 100;
		if ($flagSize == '32') $flagWidthCounter += 96;
		if ($flagSize == '48') $flagWidthCounter += 98;
	}
} ?>
</style>
<?php echo $html; ?>
</div>
