//------------------------------------------------------------------------------
function ShowLamp(txtcolor,bgcolor){
   elem = window.event.srcElement;
   elem.style.cursor = "hand";
   elem.style.color= txtcolor;
   elem.style.backgroundColor = bgcolor;
   //status = elem.innerText;
}
//------------------------------------------------------------------------------
function HideLamp(txtcolor,bgcolor){
   elem = window.event.srcElement;
   elem.style.cursor = "auto";
   elem.style.color= txtcolor;//"#fadc93";
   elem.style.backgroundColor = bgcolor;
   //status = "";
}
//------------------------------------------------------------------------------
function dolink(newurl) {
	parent.location = newurl;
}
//------------------------------------------------------------------------------
function doExtLink(newurl) {
//    alert(newurl);
    win = parent.open(newurl, null,
      	'height=600,width=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes');
    win.focus();
}
//------------------------------------------------------------------------------
function showPicture(url) {
  win = parent.open(url, "Фото",'resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no');
  win.document.write("<html><head>	<title> Фотогалерея </title></head>");
  win.document.write("<BODY bgcolor='#CFD9FD' LEFTMARGIN='0' TOPMARGIN='0' MARGINWIDTH='0' MARGINHEIGHT='0'>");
  win.document.write("<IMG id='pic' src='"+url+"' onload='window.resizeTo(pic.width+28,pic.height+70);window.focus();'></img></BODY></html>");
  win.focus();
}
//-------------------------------------------------------------------------------------------
function showcalendar(showDate) {
	var linkcount=0;
	monthdays = new Array(12);
	monthdays[0]=31;
	monthdays[1]=28;
	monthdays[2]=31;
	monthdays[3]=30;
	monthdays[4]=31;
	monthdays[5]=30;
	monthdays[6]=31;
	monthdays[7]=31;
	monthdays[8]=30;
	monthdays[9]=31;
	monthdays[10]=30;
	monthdays[11]=31;
//	todayDate=new Date();
	todayDate=showDate;
	selectedDate=showDate;
	var strHtml="";
	
	thisday=todayDate.getDay();
	thismonth=todayDate.getMonth();
	thisdate=todayDate.getDate();
	thisyear=todayDate.getYear();
	thisyear = thisyear % 100;
	thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
	if (((thisyear % 4 == 0)&& !(thisyear % 100 == 0))||(thisyear % 400 == 0)) 
		monthdays[1]++;
	startspaces=thisdate;
	while (startspaces > 7) 
		startspaces-=7;
	startspaces = thisday - startspaces;
	if (startspaces < 0) 
		startspaces+=7;
		
	strHtml +="<TABLE width=100% border=0 cellPadding=0 cellSpacing=0 valign='top' bgcolor=\"white\">";
	strHtml +="<tr>";
	strHtml +="<td width=100% height=100%>";
	strHtml +="<TABLE width=100% valign='top'  border=0 cellpadding=2 cellspacing=0  class=cal background='images/news_back.gif'>";
	strHtml +="<tr class=cHilight2 height='15'><td class=cal2>П</td><td class=cal2>В</td><td class=cal2>С</td><td class=cal2>Ч</td><td class=cal2>П</td><td class=cal2>С</td><td class=cal2>В</td></tr>";
	strHtml +="<tr class=cMain>";
	for (s=0; s<startspaces; s++) {
		strHtml +="<td></td>";
	}
	count=1;
	while (count <= monthdays[thismonth]) {
		for (b = startspaces; b<7; b++) {
			strHtml +="<td class=caldata valign=middle height=100% onmouseover='style.backgroundColor=\"silver\"' onmouseout='style.backgroundColor=\"white\"' onclick='selectedDate.setDate("+count+");calDay.value=selectedDate.getDate();'>";
			if (count==thisdate) {
				strHtml +="<span class='curdata'>";
			}
			if (count <= monthdays[thismonth]) {
				strHtml +=count;
			}
			else {
				strHtml +="&nbsp";
			}
			if (count==thisdate) {
				strHtml +="</span>";
			}
			strHtml +="</td>";
			count++;
		}
		strHtml +="</tr>";
		strHtml +="<tr>";
		startspaces=0;
	}
	strHtml +="<td></td></tr></TABLE>";
	//strHtml +="<tr><td><span id=dateSpan>"+selectedDate.toLocaleString()+"</span>";
	strHtml +="<input type=hidden name=calDay value="+selectedDate.getDate()+">";
	strHtml +="<input type=hidden name=calMonth value="+selectedDate.getMonth()+">";
	strHtml +="<input type=hidden name=calYear value="+selectedDate.getYear()+">";
	strHtml +="</td></tr></TABLE>";
	
	return strHtml;
}
//-----------------------------------------------------------------------------------------------------------------
var workDate;
function showCalendarDiv(day,month,year){
	if(day!=0 && year!=0) 	workDate=new Date(year,month,day);
	else	               	workDate=new Date();
	monthName = new Array(12);
	monthName[0] = 'Январь';
	monthName[1] = 'Февраль';
	monthName[2] = 'Март';
	monthName[3] = 'Апрель';
	monthName[4] = 'Май';
	monthName[5] = 'Июнь';
	monthName[6] = 'Июль';
	monthName[7] = 'Август';
	monthName[8] = 'Сентябрь';
	monthName[9] = 'Октябрь';
	monthName[10] = 'Ноябрь';
	monthName[11] = 'Декабрь';
	document.write("<div style='width:120;height:80;border:1px outset silver;'>");
	document.write("<TABLE width=100% border=0 cellPadding=0 cellSpacing=0 valign='top'>");
	document.write("<tr>");
	document.write("<td align=left style='cursor:hand' onclick='workDate.setMonth(workDate.getMonth()-1);mnameTD.innerText=monthName[workDate.getMonth()]+\", \"+workDate.getYear();innerTD.innerHTML=showcalendar(workDate)'><");
	document.write("<td id=mnameTD align=center class=cal2>"+monthName[workDate.getMonth()]+", "+workDate.getYear()); 
	document.write("<td align=right style='cursor:hand' onclick='workDate.setMonth(workDate.getMonth()+1);mnameTD.innerText=monthName[workDate.getMonth()]+\", \"+workDate.getYear();innerTD.innerHTML=showcalendar(workDate)'>>");
	document.write("<tr>");
	document.write("<td id=innerTD colspan=3 style='border:1px outset silver;'>");
		innerTD.innerHTML=showcalendar(workDate);
	document.write("</table>");
	document.write("</div>");
}
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
//var iconArr;
//var photoArr;
//var txtArr;
var curPage;
function showGalleryDiv(){
	if(iconArr.length%12>0)	pageNum = iconArr.length/12+1;
	else pageNum = iconArr.length/12;
	document.write("<TABLE width=100% height=100% border=0 class=textStyle>");
	document.write("<tr><td id=photoTD>");
		photoTD.innerHTML=showPhotoPage(1);
	document.write("<tr height=20><td align=center>");
	for(i=1;i<=pageNum;i++){
		document.write(" <a href=# class=line onclick='curPage="+i+";photoTD.innerHTML=showPhotoPage(curPage);'>["+i+"]</a>");
	}
	document.write("</table>");
}
//-----------------------------------------------------------------------------------------------------------------
function showPhotoPage(page){
	var strHtml="";
	strHtml +="<TABLE width=100% height=100% border=0 cols=4 rows=3 class=textStyle>";
	i=(page-1)*12;
	for(r=1;r<=3;r++){
		strHtml +="<tr>";
		for(c=1;c<=4;c++){
			strHtml +="<td align=center>";
			if(iconArr[i]!=null)
				strHtml +="<a class=menu style='active:red;' href=javascript:showPicture('pic.php?img=./galery/img/"+photoArr[i]+
					"')><img border=0 src='./galery/icon/"+iconArr[i]+"'></img></a><br>"+txtArr[i];
			i++;
		}
	}
	strHtml +="</table>";
	return strHtml;
}

//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
//var iconNumArr;
//var photoNumArr;
var curNumPage;
function showNumGalleryDiv(){
	if(iconNumArr.length%4>0)	pageNum = iconNumArr.length/4+1;
	else pageNum = iconNumArr.length/4;
	document.write("<TABLE width=100% height=100% border=0 class=textStyle>");
	document.write("<tr><td id=photoTD>");
		photoTD.innerHTML=showNumPhotoPage(1);
	document.write("<tr height=20><td align=center>");
	for(i=1;i<=pageNum;i++){
		document.write(" <a href=# class=line onclick='curNumPage="+i+";photoTD.innerHTML=showNumPhotoPage(curNumPage);'>["+i+"]</a>");
	}
	document.write("</table>");
}
//-----------------------------------------------------------------------------------------------------------------
function showNumPhotoPage(page){
	var strHtml="";
	strHtml +="<TABLE width=100% height=100% border=0 cols=4 class=textStyle><tr>";
	i=(page-1)*4;
	for(c=1;c<=4;c++){
		strHtml +="<td align=center>";
		if(iconNumArr[i]!=null)
			strHtml +="<a class=menu style='active:red;' href=javascript:showPicture('../nums/img/"+photoNumArr[i]+
				"')><img border=0 src='../nums/icon/"+iconNumArr[i]+"'></img></a>";
		i++;
	}
	strHtml +="</table>";
	return strHtml;
}

//-----------------------------------------------------------------------------------------------------------------
function $(id){
    return document.getElementById(id)
}
