<?php
header("Content-Type: text/html; charset=utf-8");
function tafseer_all_sora_loop($loop,$type) {
global  $htmlorphp,$q,$_GET,$Q_W;

if($loop=="1"){$width = "100%";}
elseif($loop=="2"){$width = "50%";}
elseif($loop=="3"){$width = "33%";}
elseif($loop=="4"){$width = "25%";}
elseif($loop=="5"){$width = "20%";}
elseif($loop=="6"){$width = "16%";}
else{$width = "";}

$prints = '<div class="translatesoeah_rtl">';
$prints .= '<table id="t1"><tr>';
$tr = 0;
for($i=1; $i<=114; $i++){

++$tr;
if($tr==$loop){ $trx = "</tr><tr>"; $tr = 0; }else{ $trx = ""; }

$prints .= '<td style="width:'.$width.'"><a title="'.$q[$i].'" href="'.url(13,$i,$type).'" >'.$i.''.$Q_W[26].' '.$q[$i].'</a></td>'.$trx.'';
}
$prints .= '</table>';
$prints .= '</div>';
return $prints;
}


function tafseer_form($sora){
global $htmlorphp,$_GET,$QURAN,$tafseers,$Q_W;

$ayatnumbers = count($QURAN[''.$sora.'']);
$tafseercount = count($tafseers);

$allayat = '<label for="tafseer_1">'.$Q_W[63].'</label> <select id="tafseer_1" size="1" name="aya">';
for($i2=1; $i2<$ayatnumbers+1; $i2++){
if(intval($_GET['aya'])==$i2){
$allayat .= '<option value="'.$i2.'" selected="selected">'.$i2.'</option>';
}else{
$allayat .= '<option value="'.$i2.'">'.$i2.'</option>';
}
}
$allayat .= '</select>';


$alltafseer = '<label for="tafseer_2">'.$Q_W[64].'</label> <select id="tafseer_2" size="1" name="type">';
for($i2x=1; $i2x<$tafseercount; $i2x++){
if(intval($_GET['type'])==$i2x){
$alltafseer .= '<option value="'.$i2x.'" selected="selected">'.$tafseers[$i2x].'</option>';
}else{
$alltafseer .= '<option value="'.$i2x.'">'.$tafseers[$i2x].'</option>';
}
}
$alltafseer .= '</select>';


$s = '<form method="post" action="'.url(14,0,"").'">
<input name="sora" type="hidden" value="'.$sora.'" />
<input name="ayanumber" type="hidden" value="'.$ayatnumbers.'" />
<input name="tafseernumber" type="hidden" value="'.$tafseercount.'" />
'.$allayat.' '.$alltafseer.' <input name="send" type="submit" value=" '.$Q_W[28].' " />
</form>';
return $s;
}

function tafseer_select($sora,$aya,$type){
global $folder,$q,$quran_type_view,$htmlorphp,$QURAN,$Q_W,$folder_tafseer,$allw_optionsave;

if(!isset($type) OR $type == 0){ $type = 1; }

if(file_exists(include_tafseerfilse($sora,$aya,$type))){
include(include_tafseerfilse($sora,$aya,$type));
}else{
$err = $Q_W[34];
}

//$text_tafseer = $TAFSEER[$type][$sora][$aya];
$text_tafseer = textcut(70000,$TAFSEER[$type][$sora][$aya],"tafseer.php?sora=".$sora."&type=".$type."");
$ayatext = $QURAN[$sora][$aya];
$ayaorders = $aya;

if($text_tafseer == ""){ $text = $Q_W[27]; }else{ $text = nl2br($text_tafseer); }

if($allw_optionsave == 1){ $savetofilex = tafseer_savetofile($sora,$type,$aya); }else{ $savetofilex = ''; }

$s = ''.$err.'<div class="tafseer">
<div class="ayat4tafseersearch">'.tafseer_form($sora).''.$savetofilex.'</div>
<div class="ayat4tafseer">'.Chromefix($ayatext).' <a href="'.url(9,$sora,"").'"><span>('.$ayaorders.') ('.$q[$sora].')</span></a> <a href="'.url(15,$sora,$ayaorders).'" title="'.$q[$sora].' '.$Q_W[35].' '.$ayaorders.'" rel="gb_page_center[465, 450] nofollow"><img src="'.$folder.'/icons/mp3.png" alt="mp3" /></a></div>
<div class="ayat4tafseer_text" id="TAFSEER">'.Chromefix($text).'</div>
</div>';

return $s;
}

function tafseer_savetofile($sora,$type,$aya) {
global $htmlorphp,$folder,$q,$Q_W,$allw_save_word,$allw_save_txt,$allw_save_html,$allw_print,$xy;
if($xy==1){ $paths = '../'; }else{ $paths = ''; }
if ($htmlorphp=="1"){
$linksd = $paths.'word-'.$sora.'-'.$type.'-'.$aya.'.html';
$linksdx = $paths.'notepad-'.$sora.'-'.$type.'-'.$aya.'.html';
$linksdh = $paths.'html-'.$sora.'-'.$type.'-'.$aya.'.html';
$linksdp = $paths.'x-'.$sora.'-'.$type.'-'.$aya.'.html';
}else{
$linksd = $paths.'doc.php?sora='.$sora.'&type='.$type.'&aya='.$aya.'';
$linksdx = $paths.'plain.php?sora='.$sora.'&type='.$type.'&aya='.$aya.'';
$linksdh = $paths.'html.php?sora='.$sora.'&type='.$type.'&aya='.$aya.'';
$linksdp = $paths.'print.php?sora='.$sora.'&type='.$type.'&aya='.$aya.'';
}

if($allw_save_word != 1 AND $allw_save_txt != 1 AND $allw_save_html != 1 AND $allw_print != 1){
$prints = '';
}else{
$prints = '<div class="saveoption"><p>'.$Q_W[69].'</p>';
if($allw_save_word==1){
$prints .= '<a rel="nofollow" href="'.$linksd.'"><img title="'.$Q_W[65].'" src="'.$folder.'/icons/word.png" alt="'.$Q_W[65].'" /></a>';
}
if($allw_save_txt==1){
$prints .= '<a rel="nofollow" href="'.$linksdx.'"><img title="'.$Q_W[66].'" src="'.$folder.'/icons/txt.png" alt="'.$Q_W[66].'" /></a>';
}
if($allw_save_html==1){
$prints .= '<a rel="nofollow" href="'.$linksdh.'"><img title="'.$Q_W[67].'" src="'.$folder.'/icons/html.png" alt="'.$Q_W[67].'" /></a>';
}
if($allw_print==1){
$prints .= '<a rel="nofollow" href="'.$linksdp.'"><img title="'.$Q_W[68].'" src="'.$folder.'/icons/print.png" alt="'.$Q_W[68].'" /></a>';
}
$prints .= '</div>';
}
return $prints;
}
?>