/*
function BlockJavaScriptErrors() {return true;}
window.onerror = BlockJavaScriptErrors;
*/

isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isOpera=isOpera5=window.opera && isDOM //Opera 5+
isOpera6=isOpera && window.print //Opera 6+
isOpera7=isOpera && document.readyState //Opera 7+
isMSIE=document.all && document.all.item && !isOpera //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE //MSIE 5+
isNetscape4=document.layers //Netscape 4.*
isMozilla=isDOM && navigator.appName=="Netscape" //Mozilla или Netscape 6.*


 function c_(iid, act)
 {
   if(act==1){
     document.getElementById('c_'+iid).style.display = '';
     document.getElementById('t_'+iid).style.display = 'none';
   }else{
    if(document.getElementById('h_'+iid).value=="0")
	 {
     document.getElementById('c_'+iid).style.display = 'none';
     document.getElementById('t_'+iid).style.display = '';
	 }
   }
 }
 
 function c_h(iid)
 {
  if(document.getElementById('h_'+iid).value=="0"){
    document.getElementById('h_'+iid).value = "1";
  }else{
    document.getElementById('h_'+iid).value = "0";
  }
 }
 
  function big_img(val)
  {
	 var old_img_s = document.getElementById('im_big').src.split("/");
	 var new_img_s = document.getElementById(val).style.backgroundImage;
	 new_img_s = new_img_s.substr(4, (new_img_s.length-5)).split("/");
	 
	 //alert(new_img_s+" - "+old_img_s);
	 
	 var old_img = "";
	 var new_img = "";
	 
	 for(i=0;i<=old_img_s.length-1;i++){
	   if(old_img_s[i]=="500"){old_img_s[i] = "100";}
	   old_img += old_img_s[i];
	   if(i!=old_img_s.length-1){old_img += "/";}
	 }
	 
	 for(i=0;i<=new_img_s.length-1;i++){
	   if(new_img_s[i]=="100"){new_img_s[i] = "500";}
	   new_img += new_img_s[i];
	   if(i!=new_img_s.length-1){new_img += "/";}
	 }
	 
	 if(isOpera){
	   new_img = new_img.substr(1, (new_img.length-2))
	   document.getElementById(val).style.backgroundImage = "url("+old_img+")";
	   document.getElementById('im_big').src = new_img;
	 }else{
	   document.getElementById(val).style.backgroundImage = "url('"+old_img+"')";
	   document.getElementById('im_big').src = new_img;
	 }
  }

  function big_img_w(val)
  {
	 var old_img_s = document.getElementById('im_big').src.split("/");
	 var new_img_s = document.getElementById(val).style.backgroundImage;
	 new_img_s = new_img_s.substr(4, (new_img_s.length-5)).split("/");
	 
	 //alert(new_img_s+" - "+old_img_s);
	 
	 var old_img = "";
	 var new_img = "";
	 
	 for(i=0;i<=old_img_s.length-1;i++){
	   if(old_img_s[i]=="500"){old_img_s[i] = "100";}
	   old_img += old_img_s[i];
	   if(i!=old_img_s.length-1){old_img += "/";}
	 }
	 
	 for(i=0;i<=new_img_s.length-1;i++){
	   if(new_img_s[i]=="100"){new_img_s[i] = "500";}
	   new_img += new_img_s[i];
	   if(i!=new_img_s.length-1){new_img += "/";}
	 }
	 
	 if(isOpera){
	   new_img = new_img.substr(1, (new_img.length-2))
	   document.getElementById('im_big').src = new_img;
	 }else{
	   document.getElementById('im_big').src = new_img;
	 }
  }
  

  
  function show_c(val)
  {
	for(i=1;i<=s_months;i++){
	  m = document.getElementById('m_'+i).style.display;
	  if(m!="none"){last_showed = i;}
	  document.getElementById('m_'+i).style.display = "none";
	}
	
	if(val=="forward"){
	    var start_showing = parseInt(last_showed) - parseInt(months_on_page) + 1;
	  }else{
	    var start_showing = parseInt(last_showed) - parseInt(months_on_page) - 1;
	  }
	  
	  if((parseInt(start_showing) + parseInt(months_on_page)) > parseInt(s_months)){
	    start_showing = parseInt(s_months) - parseInt(months_on_page);
	  }
	  var stop_showing = parseInt(start_showing) + parseInt(months_on_page)
	  
	  for(i=start_showing+1;i<=stop_showing;i++){
	    document.getElementById('m_'+i).style.display = "";
	  }
	
	
	if(start_showing==(parseInt(s_months) - parseInt(months_on_page))){
	  document.getElementById('c_forward').style.visibility = "hidden";
	}else{
	  document.getElementById('c_forward').style.visibility = "visible";
	}
	
	if(start_showing==0){
	  document.getElementById('c_back').style.visibility = "hidden";
	}else{
	  document.getElementById('c_back').style.visibility = "visible";
	}
	
  }

function ShowPic(imageName,imageWidth,imageHeight,alt) {
	var bgcolor="#FFFFFF";
	var adj=10;
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;
	var hugMargin = 0;

	var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	 } 
	var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	if (scrHeight<100){scrHeight=100;}
	if (scrWidth<100){scrWidth=100;}

	posTop =  ((h-(scrHeight/lift)-adj)/2);
	posLeft = ((w-(scrWidth)-adj)/2);
 	
	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("about:blank","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+'><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Click screen to close">'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
	}
	
	
	function check_cal(){
	 var return_value = "false";
	  inputs = document.getElementsByTagName('input');
	  for(i=0;i<inputs.length;i++){
		if(inputs[i].type=="checkbox"){
		  if(inputs[i].checked){
		    return_value = "true";
			break;
		  }
		}
	  }
	  
	  if(return_value=="true"){return true;}else{return false;}
	}
	
