function calendar (){
	month = document.getElementById('month_select').value;
	year = document.getElementById('year_select').value;
	window.location.replace("index.php?pg=events&mnth="+month+"&yr="+year)
}

function deleteRow(item, msg){
	if(typeof(msg) == 'undefined')
		msg = "";
	if(confirm("Are you sure you want to delete "+item+"?"+msg))
		return true;
	else
		return false;
}

function pointer (seqn){
	document.getElementById(seqn).style.cursor="pointer"
}


function check (id, type, error){	
	
	var ids = new Array();
	ids = id.split(',');

	var types = new Array();
	types = type.split(',');

	var errors = new Array();
	errors = error.split(',');		

	for (loop=0;loop<ids.length;loop++){
		if(types[loop] != 3)
			mail = document.getElementById(ids[loop]).value;

		if(types[loop] == 0){	
			if(isBlank(mail)){
				alert ("Please fill in the required "+errors[loop]+"!");	
				return false;
			}					
		}else if(types[loop] == 1){	
			if(isBlank(mail)){
				alert ("Please fill in the required "+errors[loop]+"!");	
				return false;
			}else{
				apos=mail.indexOf("@");
				dotpos=mail.lastIndexOf(".");
				if (apos<1||dotpos-apos<2){
					alert("Please fill in a valid Email Address!");
					return false;
				}			
			}
		}else if(types[loop] == 2){	
			if(isNaN(mail)){
				alert("Please fill in a valid Price!");
				return false;
			}
		}else if(types[loop] == 3){

			if(!document.getElementById("row_2")){
				alert ("A new set requires at least 2 paintings!");	
				return false;
			}					
		}
	}
}

function isBlank(string) {
	if (string.length == 0)
		return true
		for (var i = 0; i <= string.length-1; i++)
			if (string.charAt(i) != " ")
				return false
			return true
} 

function setdays (towatch, tochange, toyear) {	

	var daybox = document.getElementById(tochange);

	if(daybox.options.length < 31){
		for(loop=daybox.options.length+1;loop<=31;loop++)
			daybox.options[daybox.options.length] = new Option(loop,loop);
	}
			
	if (towatch=='Feb' || towatch=='Apr' || towatch=='Jun' || towatch=='Sep' || towatch=='Nov') {		

		if(towatch=='Feb'){
			if(toyear%4==0)
				daybox.options.length = 29;
			else
				daybox.options.length = 28;
			
		}else{			
			daybox.options.length = 30;	 		
		}		
	}
}










var active = '0';
var browser = "";

sub_hover=new Image()
sub_hover.src="images/sub_hover.gif"

sub=new Image()
sub.src="images/sub.gif"

function getBrowser(){
	var browser=navigator.appName;
	var version=navigator.appVersion;
	version=version.match("MSIE 6.0");
	if(browser == "Microsoft Internet Explorer" && version == "MSIE 6.0"){
		active = '1';
	}
}

function setBGColor (element, color){
	element.style.backgroundColor = color;
}

function onOver (element){
	if(browser == ""){
		getBrowser();
	}
	if(active == '1'){
		displaySubmenu(element, 'visible');
	}
}

function onOut (element){
	if(browser == ""){
		getBrowser();
	}
	if(active == '1'){
		displaySubmenu(element, 'hidden');
	}
}

function displaySubmenu (element, display){

	var submenus = element.getElementsByTagName('span');
	for(loop1=0;loop1<submenus.length;loop1++){
		if(submenus[loop1].id == 'menu_item'){
			if(display == "visible"){
				submenus[loop1].style.backgroundImage = "url('images/main_hover.png')";
				submenus[loop1].style.backgroundPosition = "28px 0px";
				submenus[loop1].style.backgroundRepeat = "no-repeat";
			}else{
				submenus[loop1].style.backgroundImage = "none";
			}
		}
	}

	var submenus = element.getElementsByTagName('div');
	for(loop1=0;loop1<submenus.length;loop1++){
		if(submenus[loop1].id == 'submenu'){
			var subitems = submenus[loop1].getElementsByTagName('div');
			for(loop2=0;loop2<subitems.length;loop2++){
				subitems[loop2].style.visibility = display;
			}
		}
	}
}

function subOver (element, display){
	if(browser == ""){
		getBrowser();
	}
	if(active == '1'){
		if(display == "visible"){
			element.style.backgroundImage = "url('images/sub_hover.png')";
			element.style.backgroundColor = "#42a9a6";		
			element.style.backgroundPosition = "2px 1px";
			element.style.backgroundRepeat = "no-repeat";
		}else{
			element.style.backgroundImage = "url(images/sub.gif)";
			element.style.backgroundPosition = "0px 0px";
			element.style.backgroundRepeat = "no-repeat";
			element.style.backgroundColor = "#42a9a6";
		}
	}
}

function positionSubmenu(){
	if(browser == ""){
		getBrowser();
	}
	if(active == '1'){
		var submenus = document.getElementsByTagName('div');
		for(loop1=0;loop1<submenus.length;loop1++){
			if(submenus[loop1].id == 'submenu'){
				submenus[loop1].style.position = "absolute";
				var subitems = submenus[loop1].getElementsByTagName('div');
				for(loop2=0;loop2<subitems.length;loop2++){
					subitems[loop2].style.top = "-9px";	
					subitems[loop2].style.left = "20%";
				}				
			}
		}
	}
}