var winCol

var aLeap = new Array
aLeap[0] = 2008
aLeap[1] = 2012
aLeap[2] = 2016
aLeap[3] = 2020
aLeap[4] = 2024
aLeap[5] = 2028
aLeap[6] = 2032
aLeap[7] = 2036
aLeap[8] = 2040
aLeap[9] = 2044
aLeap[10] = 2048
aLeap[11] = 2052
aLeap[12] = 2056
aLeap[13] = 2060
aLeap[14] = 2064
aLeap[15] = 2068
aLeap[16] = 2072
aLeap[17] = 2076
aLeap[18] = 2080
aLeap[19] = 2084	

function chkSelPos(ndx,pos,day) {
	
	frm = document.forms[1]
	
	if (pos == 1) {	
		frm['cLef'+ day + '_' + ndx].checked = false;	
		frm['cRig'+ day + '_' + ndx].checked = false;
	}else if (pos == 2) {
		frm['cFea'+ day + '_' + ndx].checked = false;	
		frm['cRig'+ day + '_' + ndx].checked = false;
	}else if (pos == 3) {
		frm['cFea'+ day + '_' + ndx].checked = false;	
		frm['cLef'+ day + '_' + ndx].checked = false;
	}
}

function inputCol(col,sObj,nC) {
	
	document.getElementById(sObj).value = col
	
	if (col == '') 
		document.getElementById('bCol' + nC).style.background = 'url(ZS_images/Trans.gif)';			
	else {
		document.getElementById('bCol' + nC).style.background = ''
		document.getElementById('bCol' + nC).style.backgroundColor = '#' + col
		}
}

function blurCol(obj,nC) {

	if (obj.value != '') {
		document.getElementById('bCol' + nC).style.background = ''
		document.getElementById('bCol' + nC).style.backgroundColor = '#' + obj.value
	}else{
		document.getElementById('bCol' + nC).style.background = 'url(ZS_images/Trans.gif)'
	}	
}

function colPick(sCol,nC) {

obj = document.getElementById(sCol)

col = obj.value;
id = obj.id;

if (!winCol || winCol.closed) {
	winCol = window.open("ZS_colors/ColorPicker.asp?c=" + col + '&id=' + id + '&nC=' + nC, "winCol", "dependent=true,width=320,height=178")
	if (!winCol.opener) {
		winCol.opener = window;
	}
}else{

	winCol.LoadColor(col,id,nC);
	
	////winCol.location.href = "ZS_colors/ColorPicker.asp?c=" + col + '&id=' + id + '&nC=' + nC;
	
	winCol.focus();						
	}
}
	
function chkSub(Eid,id,act,day) {
	
	frm = document.forms[1]
	frm.action = 'zprocess.asp?d=' + day
	frm.target = ''
	
	//alert(frm.action)
		
	if (act == 'list') {
		
		frm.tSelID.value = frm.selEstabs.value
		//frm.tEveID.value = 0
		frm.tButSel.value = 'list'
		frm.submit()		

	}else if (act == 'view') {
		
		frm.tSelID.value = 0
		frm.selView.selectedIndex = 0
		//frm.tEveID.value = 0
		frm.tButSel.value = 'week'
		frm.submit()	
		
	}else if (act == 'week') {
		
		//anc = document.getElementById('aWeek')
		//anc.target = '_blank'		
		//alert(anc.target)
		
		frm.tSelID.value = 0
		frm.selView.selectedIndex = 0
		//frm.tEveID.value = 0
		frm.tButSel.value = 'week'
		frm.action = 'zprocess.asp?d=' + day + '&mailing=1&zw=yes'
		frm.target = '_blank'		
		frm.submit()			

	//}else if (act == 'view') {
		
	//	frm.tSelID.value = frm.selEstabs.value
	//	//frm.tEveID.value = 0
	//	frm.tButSel.value = 'view'
	//	frm.submit()

	}else if (act == 'id') {
		
		frm.tSelID.value = frm.tID.value
		//frm.tEveID.value = 0
		frm.tButSel.value = 'id'
		frm.submit()

	}else if (act == 'cls') {
		
		frm.selEstabs.selectedIndex = 0
		frm.tSelID.value = Eid
		//frm.tEveID.value = id	
		frm.tButSel.value = 'cls'
		frm.submit()

	}else if (act == 'new') {
		
		frm.tSelID.value = frm.selEstabs.value
		//frm.tEveID.value = 0
		frm.tButSel.value = 'new'
		frm.submit()

	}else if (act == 'edit') {
		
		frm.tSelID.value = Eid
		frm.tEveID.value = id	
		frm.tButSel.value = 'edit'				
		frm.submit()
		
	}else if (act == 'del') {			
			
		if (confirm('Are you sure you want to delete this event?')) {
			frm.tSelID.value = Eid
			frm.tEveID.value = id
			frm.tButSel.value = 'delete'
			frm.submit()
		}
	}else{
		//frm.tButSel.value = ''
		frm.submit()								
	}		
}
	
function chkSav(d,gr) {
	
	frm = document.forms[1]		
	
	//alert(d)
	
	if (d==7) {
		frm.action = frm.action + '#saturday'
	}else if (d==6) {	
		frm.action = frm.action + '#friday'
	}else if (d==5) {
		frm.action = frm.action + '#thursday'
	}else{
		frm.action = frm.action + '#monday_tuesday'
	}
		
	frm.tSelID.value = frm.selEstabs.value
	//frm.tEveID.value = 0
	if (frm.tButSel.value == 'new') {			
		
		if (frm.selEstabs.value > 0) {
			
			frm.tButSel.value = 'savn'
		}else{
			alert('Select an establishment for this event...')
			frm.selEstabs.focus()
			return false		
		}
		
	}else{
		frm.tButSel.value = 'save'
	}
	frm.tGrid.value = gr
	if (frm.tHead && frm.tHead.value == '') {
		alert('Type at least a heading for this event...')
		frm.tHead.focus()
		return false		
	}	
	if (checkDelImg()) {
		return true
	}else{
		return false
	}		
}
	
function checkDelImg() {

	var frm = document.forms[1];

	var res = true;
	for (var i=0;i<frm.elements.length;i++)	{	
		var e = frm.elements[i];
		if (e.type=='checkbox') {		
			var at = e.name.indexOf('chkDel_');		
			if (at > -1) {			
				if (e.checked) {
					if (!confirm("Are you sure you want to delete the selected Image(s)?")) {
						return false;
					}			
					i = frm.elements.length;
				}			
			}
		}	
	}
	return true;
}	
	
function mDate(m,a,s) {

	frm = document.forms[1]
		
	if (s == 1) {
		
		oIM = frm.inAccMon
		oID = frm.inAccDay
		oIY = frm.inAccYear
		
		oOM = frm.outAccMon
		oOD = frm.outAccDay
		oOY = frm.outAccYear
			
	}else{	
		
		oIM = frm.inMonth
		oID = frm.inDay
		oIY = frm.inYear
		
		oOM = frm.outMonth
		oOD = frm.outDay
		oOY = frm.outYear
	}	
		
	//alert(oIM)
	//alert(oID)
	//alert(oIY)
	//alert(oOM)
	//alert(oOD)
	//alert(oOY)
		
	var b = typeof(oOM) == 'object'
			
	bLeap = false

	for (i=0; i<20; i++) {		
		if (oIY.value == aLeap[i]) {			
			bLeap = true
			i = 20
		}			
	}
		
	if (m.substr(0,1) == 'i') {
			
		if (b && m.substr(1,1) == 'y') {

			oOY.value = oIY.value
					
		}else{
				
			if (b && m.substr(1,1) == 'd') {
					
				if (oIM.value == oOM.value) {
								
					//alert(oIM.value)
					//alert(oOM.value)
					
					//alert(oID.value)
					//alert(oOD.value)
					
					//alert(oOD.selectedIndex)
						
					if (oID.value > oOD.value) {oOD.selectedIndex = oID.value-1}
				}
				
			}else{
					
				inM = oIM.value
				
				//if (b && a != 1) {oOM.value = inM}				
				
				if (b) {oOM.value = inM}
				if (b) {ouM = oOM.value}
						
				if (inM == 4 || inM == 6 || inM == 9 || inM == 11) {
						
					if (oID.length > 27 && oID.length < 30) {
						if (oID.length == 28) {
							NewOpt1 = new Option;
							NewOpt1.value = 29;	
							NewOpt1.text =	'29'
							oID.options[oID.length] = NewOpt1;
						}	
						NewOpt1 = new Option;
						NewOpt1.value = 30;
						NewOpt1.text =	'30'
						oID.options[oID.length] = NewOpt1;
					}else{
						if (oID.length > 30) {oID.options[oID.length-1] = null}	
					}
						
				}else if (inM == 2){
						
					if (oID.length == 31 && !bLeap) {
						oID.options[oID.length-3] = null
					}
					oID.options[oID.length-2] = null
					oID.options[oID.length-1] = null				
						
				}else{
					if (oID.length < 31) {
							
						if (oID.length > 27 && oID.length < 30) {
								
							if (oID.length == 28) {
							
								NewOpt1 = new Option;
								NewOpt1.value = 29;	
								NewOpt1.text =	'29'
									
								oID.options[oID.length] = NewOpt1;
							}
								
							NewOpt1 = new Option;
							NewOpt1.value = 30;
							NewOpt1.text =	'30'
							
							oID.options[oID.length] = NewOpt1;
												
						}
				
						NewOpt1 = new Option;
						NewOpt1.value = 31;							
						NewOpt1.text =	'31'
							
						oID.options[oID.length] = NewOpt1;
					}					
				}	
						
				if (b) {
						
					if (ouM == 4 || ouM == 6 || ouM == 9 || ouM == 11) {
						
						if (oOD.length > 27 && oOD.length < 30) {
							if (oOD.length == 28) {
								NewOpt1 = new Option;
								NewOpt1.value = 29;	
								NewOpt1.text =	'29'
								oOD.options[oOD.length] = NewOpt1;
							}	
							NewOpt1 = new Option;
							NewOpt1.value = 30;
							NewOpt1.text =	'30'
							oOD.options[oOD.length] = NewOpt1;
						}else{
							if (oOD.length > 30) {oOD.options[oOD.length-1] = null}	
						}
						
					}else if (ouM == 2){
						
						if (oOD.length == 31 && !bLeap) {
							oOD.options[oOD.length-3] = null
						}
						oOD.options[oOD.length-2] = null
						oOD.options[oOD.length-1] = null				
						
					}else{
						if (oOD.length < 31) {
							
							if (oOD.length > 27 && oOD.length < 30) {
								
								if (oOD.length == 28) {
							
									NewOpt1 = new Option;
									NewOpt1.value = 29;	
									NewOpt1.text =	'29'
									
									oOD.options[oOD.length] = NewOpt1;
								}
								
								NewOpt1 = new Option;
								NewOpt1.value = 30;
								NewOpt1.text =	'30'
							
								oOD.options[oOD.length] = NewOpt1;
												
							}
				
							NewOpt1 = new Option;
							NewOpt1.value = 31;							
							NewOpt1.text =	'31'
							
							oOD.options[oOD.length] = NewOpt1;
						}					
					}
				}
			}
		}
	}
			
	if (b && m.substr(0,1) == 'o') {
				
		ouM = oOM.value
					
		if (ouM == 4 || ouM == 6 || ouM == 9 || ouM == 11) {
					
			if (oOD.length > 27 && oOD.length < 30) {
				if (oOD.length == 28) {
					NewOpt1 = new Option;
					NewOpt1.value = 29;	
					NewOpt1.text =	'29'
					oOD.options[oOD.length] = NewOpt1;
				}	
				NewOpt1 = new Option;
				NewOpt1.value = 30;
				NewOpt1.text =	'30'
				oOD.options[oOD.length] = NewOpt1;
			}else{
				if (oOD.length > 30) {oOD.options[oOD.length-1] = null}	
			}
					
		}else if (ouM == 2){
					
			if (oOD.length == 31 && !bLeap) {
				oOD.options[oOD.length-3] = null
			}
			oOD.options[oOD.length-2] = null
			oOD.options[oOD.length-1] = null				
					
		}else{
			if (oOD.length < 31) {
					
				if (oOD.length > 27 && oOD.length < 30) {
							
					if (oOD.length == 28) {
						
						NewOpt1 = new Option;
						NewOpt1.value = 29;	
						NewOpt1.text =	'29'
								
						oOD.options[oOD.length] = NewOpt1;
					}
							
					NewOpt1 = new Option;
					NewOpt1.value = 30;
					NewOpt1.text =	'30'
						
					oOD.options[oOD.length] = NewOpt1;
											
				}
				
				NewOpt1 = new Option;
				NewOpt1.value = 31;							
				NewOpt1.text =	'31'
						
				oOD.options[oOD.length] = NewOpt1;
			}					
		}
	}
}	
	
function ancU(o) {o.className = "sH"}

function ancD(o) {o.className = "s"}
	
function anrU(o) {o.className = "sRH"}

function anrD(o) {o.className = "sR"}