
 function in_array(needle, haystack, argStrict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true
    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
 
    var key = '', strict = !!argStrict;
 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
 
    return false;
}


 
 function change_date(year,month, day , date_array,text_array){
 
  var myDate = new Date();

	  //year , month-1 , day

	  //set full year

  myDate.setFullYear(year,month-1,day);


var day_array = new Array();

var y =0;

var tstr = '';

  for (x=0;x<date_array.length;x++) {

	 tstr = date_array[x];

	   date_f =  tstr.split("-");

      if( date_f[0] == year && date_f[1] == month ){

         day_array[y] = date_f[2];
		 y++;

	  }
   }
   
 
    start_date =  myDate.getDay();
 
	//show day
		//alert(myDate.getDate());

	//show month
		//alert(myDate.getMonth());

	//show year
		//alert(myDate.getFullYear());
    var last_day = 30;
	
	//	1 3 5 7 8 10 12
	 if(month == 1 ||
		month == 3 ||
 		month == 5 ||
 		month == 7 ||
 		month == 8 ||
 		month == 10 ||
 		month == 12  )
	 {
         last_day = 31;

	 } else 
       if(month == 2) {

        //leap year
        if(year % 4 == 0 ){

			   last_day = 29;

		 }
	   else  last_day = 28;
    }

	else {
	//   4 6 9 11 
	   last_day = 30;
	}  

 
   cal_date(start_date,last_day,'',day_array,text_array);

 
//   alert(text_array);

 }


function cal_date(start,stop,id,day_array,text_array){
 
    var args_tr; 

	var args = new Array();

    id = id ? id : "cal_div" ;

    var html;

	html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

    html += '<tr>';
 
    var next = true;

    args =text_array


	for (x = 1;x<=stop+start;x++) {
   
      if(start >0 ) {
		  
		  if(x <= start && x >= 1)
		  cx = '' ;
		  else 
		  cx =  x- start ;

	  }

	  else cx = x;

    var now_class = '';


    if( in_array(cx, day_array,false) )
	 {
		

		now_class = 'ro';


	//	cx = '<i>'+ cx +'</i>';
	 
	
	}
	else now_class = '';


  	  if(next){

            args_tr = args[cx];


       if(now_class!='')
          html += '<td class="index_calendar_sunday_ro"  ><span style="cursor:hand" onclick="location.href=\'si_calendar.php\'" ><a class="callink" href="#" title="'+args_tr+'" alt="'+args_tr+'" >'+cx+'</a></span></td>';
	   else 
	  html += '<td class="index_calendar_sunday" onmouseover="this.className=\'index_calendar_sunday_ro\'" onmouseout="this.className=\'index_calendar_sunday\'">'+cx+'</td>';

     

     }

	  else {
      args_tr = args[cx];

		 if(now_class!='')
          html += '<td class="index_calendar_day_ro" onclick="location.href=\'si_calendar.php\'" ><span style="cursor:hand" onclick="location.href=\'si_calendar.php\'"><a class="callink" href="#" title="'+args_tr+'" alt="'+args_tr+'">'+cx+'</a></span></td>';
	     else 
		  html += '<td class="index_calendar_day" onmouseover="this.className=\'index_calendar_day_ro\'" onmouseout="this.className=\'index_calendar_day\'">'+cx+'</td>';	



	  }
	  if(  x  %  7  == 0 )   {
		  
		  html += '</tr><tr>';

		  next = true;
		  
	  }

	 else next = false;

   

	}

   html += '</table>';
  
   document.getElementById(id).innerHTML = html;


//   return html;

}

/*



getDate() Returns the day of the month from a Date object (from 1-31) 1 3 
getDay() Returns the day of the week from a Date object (from 0-6) 1 3 
getFullYear() Returns the year, as a four-digit number, from a Date object  1 4 
getHours() Returns the hour of a Date object (from 0-23) 1 3 
getMilliseconds() Returns the milliseconds of a Date object (from 0-999) 1 4 
getMinutes() Returns the minutes of a Date object (from 0-59) 1 3 
getMonth() Returns the month from a Date object (from 0-11) 1 3 
getSeconds() Returns the seconds of a Date object (from 0-59) 1 3 
getTime() Returns the number of milliseconds since midnight Jan 1, 1970 


*/
