jQuery.noConflict();
jQuery(document).ready(function($){
	// rollover
	$('.imgover').each(function() {
		var osrc = $(this).attr('src');
		var hsrc = osrc.replace(/(\.gif|\.jpg|\.png)/, '_o$1');
		$.data(this, 'osrc', osrc);
		$.data(this, 'hsrc', hsrc);
		$('<img>').attr('src', hsrc);
	}).hover(function() {
		$(this).attr('src', $.data(this, 'hsrc'));
	},function() {
		$(this).attr('src', $.data(this, 'osrc'));
	});

	// scroll
	$('a[href^=#]').click(function() {
		var $t = $(this.hash);
		if (this.hash.length > 1 && $t.length) {
			$.scrollTo($t, 400);
			return false;
		}
	});

jQuery(function() {
	jQuery('#calendarDisplay').datepick({onSelect: showDate,  monthsToShow: 2, formatDate: 'yyyy-mm-dd' });
});

});

function showDate(date) {
	//~ <?php if(isset($_GET['UserTimezone'])) { ?>
		//~ var timeZone = "<?php echo $_GET['UserTimezone'] ; ?>" ;
		//~ window.location.href ='index.php?date='+date+'&UserTimezone='+timeZone;
	//~ <?php }else { ?>
		//~ window.location.href ='index.php?date='+date;
	//~ <?php  } ?>
	
	Expression = new RegExp("^[^0-9]*$","g");
	
	if (date == '' || date == 0) {
		var q_txt = "" ;
	}else if (Expression.test(date)){
		var q_txt = "UserTimezone=" + String(date);
	}else{
		var q_txt = "date=" + date;
	}
	 //~ <?php if(isset($_GET['UserTimezone'])) { ?>
		//~ var timeZone = "<?php echo $_GET['UserTimezone'] ; ?>" ;
		//~ var q_txt = "date="+date+"&UserTimezone="+timeZone;
	//~ <?php }else { ?>
		//~ var q_txt = "date=" + date;
	//~ <?php  } ?>
	
	var url = 'calendarForm.php';
	var myAjax = new Ajax.Request(
            url, 
            {
                method: 'get', 
		parameters: q_txt,
                onComplete: manageResponse
            });
	    
	    
}

function manageResponse(xhr)
{
    if (xhr.status == 200)
    {
        $('calendar').innerHTML = xhr.responseText;
    }
    else
    {
        $('calendar').innerHTML = "error";
    }
}


function inputformchk(thisForm)
{
    if(thisForm.firstname.value == '')
    {
         alert('Firstname field is empty, please fill it.');
         thisForm.firstname.focus();
         return false;
    }
    if(thisForm.lastname.value == '')
    {
         alert('Lastname field is empty, please fill it.');
         thisForm.lastname.focus();
         return false;
    }
    if(thisForm.month.value == '')
    {
         alert('Month field is empty, please fill it.');
         thisForm.month.focus();
         return false;
    }
    if(thisForm.day.value == '')
    {
         alert('Day field is empty, please fill it.');
         thisForm.day.focus();
         return false;
    }
    
     if(thisForm.year.value == '')
    {
         alert('Year field is empty, please fill it.');
         thisForm.year.focus();
         return false;
    }
    
     if(thisForm.sex.value == '')
    {
         alert('The gender field is empty, please fill it.');
         thisForm.sex.focus();
         return false;
    }
    
     if(thisForm.mail.value == '')
    {
         alert('Mail field is empty, please fill it.');
         thisForm.mail.focus();
         return false;
    }
    
     if(thisForm.timezone.value == '')
    {
         alert('Timezone field is empty, please fill it.');
         thisForm.timezone.focus();
         return false;
    }
    
     if(thisForm.ImAccountAccountLogin.value == '')
    {
         alert('The skypeID field is empty, please fill it.');
         thisForm.ImAccountAccountLogin.focus();
         return false;
    }
    
    return true;

}

	jQuery(document).ready(function() {
		/*
		*   TeachrBox
		*/

		jQuery("#popup1,#popup2,#popup3,#popup4,#popup5,#popup6").fancybox({
			'padding'			: 0,
			'width'				: '66%',
			'height'			: '71%',
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});

});


