<?php
// $Id: function.php,v 1.1 2004/07/11 10:27:56 Farsus Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Nobse, Bama
// Author Website : http://www.e-xoops.de, http://service.bama-webdesign.de
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
function getMonthName($month) {
        if ($month == "01") {
                $monthname = _CALJAN;
        } elseif ($month == "02") {
                $monthname = _CALFEB;
        } elseif ($month == "03") {
                $monthname = _CALMAR;
        } elseif ($month == "04") {
                $monthname = _CALAPR;
        } elseif ($month == "05") {
                $monthname = _CALMAY;
        } elseif ($month == "06") {
                $monthname = _CALJUN;
        } elseif ($month == "07") {
                $monthname = _CALJUL;
        } elseif ($month == "08") {
                $monthname = _CALAUG;
        } elseif ($month == "09") {
                $monthname = _CALSEP;
        } elseif ($month == "10") {
                $monthname = _CALOCT;
        } elseif ($month == "11") {
                $monthname = _CALNOV;
        } elseif ($month == "12") {
                $monthname = _CALDEC;
        }
        return $monthname;
    }


function buildMonthSelect($month) {
        for ($i = 1; $i <= 12; $i++) {
                if ($i == $month) $sel = "SELECTED";
                else $sel = "";
				$nm = getMonthName($i);
                echo "<option $sel value=\"$i\">$nm\n</option>";
        }
}


function buildDaySelect($day) {
        for ($i = 1; $i <= 31; $i++) {
                if ($i == $day) $sel = "SELECTED";
                else $sel = "";
                echo "<option $sel value=\"$i\">$i\n</option>";
        }
}


function buildYearSelect($year) {
        for ($i = 1997; $i <= 2030; $i++) {
                if ($i == $year) $sel = "SELECTED";
                else $sel = "";
                echo "<option $sel value=\"$i\">$i\n</option>";
        }
}

$time24Hour = 1;  // 1 = 24 hour time... 0 = AM/PM time


function buildHourSelect($hour) {
	global $time24Hour, $pntable;
	if (!($time24Hour)) {
        	for ($i = 1; $i <= 12; $i++) {
                	if ($i == $hour) $sel = "SELECTED";
                	else $sel = "";
                	echo "<option $sel value=\"$i\">$i</option>\n";
        	}
	} else {
		for ($i = 0; $i <= 23; $i++) {
                	if ($i == $hour) $sel = "SELECTED";
                	else $sel = "";
                	echo "<option $sel value=\"$i\">";
			if ($i<10) echo "0";
			echo "$i</option>\n";
        	}
	}
}


function buildMinSelect($min) {
        for ($i = 0; $i <= 55;) {
                echo $i;
                if (($i == $min) | (($i == 0) & ($min == "00"))) $sel = "SELECTED";
                else $sel = "";
                	echo "<option $sel value=\"";
			if ($i<10) echo "0";
					echo "$i\">";
			if ($i<10) echo "0";
			echo "$i</option>\n";
                $i = $i + 5;
        }
}



function buildAMPMSelect($ampm) {
        if ($ampm == "AM") $sel = "SELECTED";
        else $sel = "";
        echo "<option $sel value=\"AM\">AM</option>\n";
        if ($ampm == "PM") $sel = "SELECTED";
        else $sel = "";
        echo "<option $sel value=\"PM\">PM</option>\n";
}


function getTimeFormat($hour,$min,$ampm) {
        if (($ampm == "AM") & ($hour == "12")) {
                $hour = "00";
        } elseif (($ampm == "PM") & ($hour != "12")) {
                $hour = 12 + $hour;
        }
        $time = "$hour:$min:00";
        return $time;
}


function littlecal($month,$year) {	
global $beginn;
	if (empty($year))
	$year=date("Y");
if (empty($month))
	$month=date("m");

$date=01;
$day=01;
$off=0;

while (checkdate($month,$date,$year)):
$date++;
endwhile;

echo "<table border='0' cellpadding='1' cellspacing='1'  class='bg2'><tr class='bg1' align='center'>";
if ($beginn == 0) {
	echo "<td>"._CAL_SUN."</td>";
	echo "<td>"._CAL_MON."</td>";
	echo "<td>"._CAL_TUE."</td>";
	echo "<td>"._CAL_WED."</td>";
	echo "<td>"._CAL_THU."</td>";	
	echo "<td>"._CAL_FRI."</td>";
	echo "<td>"._CAL_SAT."</td>";
	echo "<tr>";
	$ng_1 = "Sunday";
	$ng_2 = "Monday";
	$ng_3 = "Tuesday";
	$ng_4 = "Wednesday";
	$ng_5 = "Thursday";
	$ng_6 = "Friday";
	$ng_7 = "Saturday";
}else{
	echo "<td>"._CAL_MON."</td>";
	echo "<td>"._CAL_TUE."</td>";
	echo "<td>"._CAL_WED."</td>";
	echo "<td>"._CAL_THU."</td>";
	echo "<td>"._CAL_FRI."</td>";	
	echo "<td>"._CAL_SAT."</td>";
	echo "<td>"._CAL_SUN."</td>";
	echo "<tr>";
	$ng_1 = "Monday";
	$ng_2 = "Tuesday";
	$ng_3 = "Wednesday";
	$ng_4 = "Thursday";
	$ng_5 = "Friday";
	$ng_6 = "Saturday";
	$ng_7 = "Sunday";
}
while ($day<$date):
	if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_1) {
		echo "<td valign='top' height='10' width='10' class='bg3'>";
		echo "<input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off = '01';
	} 

	elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_2) {
		echo "<td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '02';
	} 

	elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_3) {
		echo "<td></td><td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '03';
	} 

	elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_4) {
		echo "<td></td><td></td><td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '04';
	} 

	elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_5) {
		echo "<td></td><td></td><td></td><td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '05';
	} 

	elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_6) {
		echo "<td></td><td></td><td></td><td></td><td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '06';
	} 

	elseif ($day =='01' and date('l', mktime(0,0,0,$month,$day,$year)) == $ng_7) {
		echo "<td></td><td></td><td></td><td></td><td></td><td></td><td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
		$off= '07';
	} 

else {
echo "<td valign='top' height='10' width='10' class='bg3'><input type='checkbox' name='Day[$i]' value='$day'>$day</td>";
}

$day++;
$off++;

if ($off>7) {
		echo "</tr><tr>";
		$off='01';
	} else {
		echo "";
}

endwhile;

echo "</tr></table>";		
}


function move() {
echo "<SCRIPT LANGUAGE=\"javascript\">
<!--
window.moveTo(10,10);
//-->
</SCRIPT>";
}


//bama

    function form_last_month($lastmonth, $lastyear, $pid){
        global $xoopsConfig;
        echo "<form method='post' action='index.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/".$lastmonth."l.gif'>";
        echo "<input type='hidden' name='month' value='".$lastmonth."'>";
        echo "<input type='hidden' name='year' value='".$lastyear."'>";
        echo "<input type='hidden' name='pid' value='".$pid."'>";
        echo "</form>";
    }

    function form_next_month($nextmonth, $nextyear, $pid){
        global $xoopsConfig;
        echo "<form method='post' action='index.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/".$nextmonth."r.gif'>";
        echo "<input type='hidden' name='month' value='".$nextmonth."'>";
        echo "<input type='hidden' name='year' value='".$nextyear."'>";
        echo "<input type='hidden' name='pid' value='".$pid."'>";
        echo "</form>";
    }

    function form_add_event($month, $year){
        global $xoopsConfig;
        echo "<form method='post' action='addevent.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/language/".$xoopsConfig['language']."/images/icon_addevent.gif'>";
        echo "<input type='hidden' name='month' value='".$month."'>";
        echo "<input type='hidden' name='year' value='".$year."'>";        
        echo "</form>";
    }

    function form_ret_ecal($month, $year){
        global $xoopsConfig;
        echo "<form method='post' action='index.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/language/".$xoopsConfig['language']."/images/icon_retour_cal.gif'>";
        echo "<input type='hidden' name='month' value='".$month."'>";
        echo "<input type='hidden' name='year' value='".$year."'>";
        echo "</form>";
    }

    function form_last_day($lastday, $currentmonth, $currentyear){
        global $xoopsConfig;
        echo "<form method='post' action='display.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/".$lastday."l.gif'>";
        echo "<input type='hidden' name='month' value='".$currentmonth."'>";
        echo "<input type='hidden' name='year' value='".$currentyear."'>";
        echo "<input type='hidden' name='day' value='".$lastday."'>";
        echo "</form>";
    }

    function form_next_day($nextday, $currentmonth, $currentyear){
        global $xoopsConfig;
        echo "<form method='post' action='display.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/".$nextday."r.gif'>";
        echo "<input type='hidden' name='month' value='".$currentmonth."'>";
        echo "<input type='hidden' name='year' value='".$currentyear."'>";
        echo "<input type='hidden' name='day' value='".$nextday."'>";
        echo "</form>";
    }

    function form_last_week($lastweek){
        global $xoopsConfig;
        echo "<form method='post' action='week.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/icon_weekl.gif'>";
        echo "<input type='hidden' name='week' value='".$lastweek."'>";
        echo "</form>";
    }

    function form_next_week($nextweek){
        global $xoopsConfig;
        echo "<form method='post' action='week.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/images/icon_weekr.gif'>";
        echo "<input type='hidden' name='week' value='".$nextweek."'>";
        echo "</form>";
    }

    function form_nav_top_day($lastday, $currentmonth, $currentyear, $nextday, $currentday){
        echo "<table border='0' width='100%' class='bg3' cellpadding='2' cellspacing='0'><tr><td width='25%' align='left'>";
        form_last_day($lastday, $currentmonth, $currentyear);
        echo "</td>";
		echo "<td width='50%' align='center'>";
        echo "<b>".$currentday.". ".getMonthName($currentmonth)." ".$currentyear."</b>";
		echo "</td><td width='25%'align='right'>";
        form_next_day($nextday, $currentmonth, $currentyear);
        echo "</td></tr></table>";
    }

    function form_new_location(){
        global $xoopsConfig;
        echo "<form method='post' action='addlocation.php'>";
        echo "<input type='image' src='".XOOPS_URL."/modules/ecal/language/".$xoopsConfig['language']."/images/icon_new_loc.gif'>";
        echo "</form>";
    }
    
?>

