function validate(){
	var flag = 0;
	var err = document.mainfrm.err_text.value;
	var name = document.mainfrm.name.value;
	var email = document.mainfrm.email.value;
	var phone = document.mainfrm.phone.value;
	var loc = document.mainfrm.location.value;
	var ename = document.mainfrm.event_name.value;
	var desc = document.mainfrm.description.value;
	var emails = document.mainfrm.emails.value;
	var day = document.mainfrm.day;
	var day_id = day.options[day.selectedIndex].value;
	var month = document.mainfrm.month;
	var month_id = month.options[month.selectedIndex].value;
	var year = document.mainfrm.year;
	var year_id = year.options[year.selectedIndex].value;
	var hour = document.mainfrm.hour;
	var hour_id = hour.options[hour.selectedIndex].value;
	var minute = document.mainfrm.minute;
	var minute_id = minute.options[minute.selectedIndex].value;
	if((flag == 0) && (name == '')){
		flag = 1;
		alert(err);
		document.mainfrm.name.focus();
	}
	if((flag == 0) && (email == '')){
		flag = 1;
		alert(err);
		document.mainfrm.email.focus();
	}
	if((flag == 0) && (ename == '')){
		flag = 1;
		alert(err);
		document.mainfrm.event_name.focus();
	}
	if((flag == 0) && (desc == '')){
		flag = 1;
		alert(err);
		document.mainfrm.description.focus();
	}
	if((flag == 0) && (loc == '')){
		flag = 1;
		alert(err);
		document.mainfrm.location.focus();
	}
	if((flag == 0) && (emails == '')){
		flag = 1;
		alert(err);
		document.mainfrm.emails.focus();
	}
	if((flag == 0) && ((day_id == '') || (month_id == '') || (year_id == '') || (hour_id == '') || (minute_id == ''))){
		flag = 1;
		alert(err);
		document.mainfrm.day.focus();
	}
	if(flag == 0){
		document.mainfrm.submit();
	}
}

function send(){
	document.mainfrm.action = "send.php";
	document.mainfrm.actionfield.value = "sendmsg";
	document.mainfrm.submit();
}

function edit(){
	document.mainfrm.action = "index.php";
	document.mainfrm.actionfield.value = "editmsg";
	document.mainfrm.submit();
}

function del(){
	document.mainfrm.action = "index.php";
	document.mainfrm.actionfield.value = "deletemsg";
	document.mainfrm.submit();
}

function sendUser(){
	document.mainfrm.action = "result.php";
	document.mainfrm.submit();
}

function showHideLocation(){
	var ms = 800;
	if(document.getElementById("tr-street").style.display == "none"){
		opacity('tr-street', 0, 100, ms);
		opacity('tr-post', 0, 100, ms);
		document.getElementById("address-link").innerHTML = document.getElementById("click-here-hide").value;
	}else{
		opacity('tr-post', 100, 0, ms);
		opacity('tr-street', 100, 0, ms);
		document.getElementById("address-link").innerHTML = document.getElementById("click-here-add").value;
		document.mainfrm.street.value = "";
		document.mainfrm.street_number.value = "";
		document.mainfrm.post_code.value = "";
		document.mainfrm.city.value = "";
	}
}

function browserDetect(){
	var browserName=navigator.appName; 
	var val;
	if (browserName == "Netscape")
	{ 
		val = "table-row";
	}else 
	{ 
		val = "inline";
	}
	return val;
}

function catchSelChange(){
	var ms = 800;
	var sel = document.mainfrm.date_form;
	var id = sel.options[sel.selectedIndex].value;
	if(id == '3'){
		opacity('tr-date', 0, 100, ms);
	}else{	
		opacity('tr-date', 100, 0, ms);
	}
}

function Bookmark() {
	var BookmarkURL = this.location;
    var BookmarkTitle = "Your page title";
	if (document.all) window.external.AddFavorite(BookmarkURL,BookmarkTitle); 
		else if (window.sidebar) window.sidebar.addPanel(BookmarkTitle,BookmarkURL,"");    
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	var ms = 800;
	var val = browserDetect();
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
		setTimeout("document.getElementById('"+id+"').style.display = 'none';", ms);
    } else if(opacStart < opacEnd) {
        document.getElementById(id).style.display = val;
		for(i = opacStart; i <= opacEnd; i++)
        {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function showHidForm(id){
	var ms = 800;
	if(document.getElementById(id).style.display == "none"){
		opacity(id, 0, 100, ms);
	}else{
		opacity(id, 100, 0, ms);
	}	
}

function sbmt(){
	document.mainfrm.actionfield.value = "sbmt";
	document.mainfrm.submit();
}

function createCal(){
	document.mainfrm.actionfield.value = "crtics";
	document.mainfrm.submit();
}
