// Show popup window
function OpenWin(url)
{
	var newwindow = window.open(url, "DetailsWindow", "toolbar=no,status=yes,resizable=no,scrollbars=yes,location=no,menubar=no,width=470,height=400");
	newwindow.focus();
}

// Show popup window
function OpenWinBig(url)
{
	var newwindow = window.open(url, "DetailsWindow", "toolbar=no,status=yes,resizable=no,scrollbars=yes,location=no,menubar=no,width=530,height=400");
	newwindow.focus();
}


// Two functions, needed to select the city from popup box
function MM_openBrWindow(theURL,winName,features) { //v2.0
  mywin = window.open(theURL,winName,features);
  mywin.focus();
}

function FileCh(filename,target){
  target.value=filename;
  self.opener.focus();
  window.close();
}

function FileCh1(val1, target, val2, target1){
	target.value=val1;
	target1.value=val2;
	self.opener.focus();
	window.close();
}

// Function to show the progress window
function showProgress( show_wnd, panel_name )
{
	var obj;

	if(document.all)
	{
		obj = document.all[panel_name].style;
	}
	else if(document.getElementById)
	{
		obj = document.getElementById(panel_name).style;
	}
	else if(document.layers)
	{
		obj = document.layers[panel_name];
	}

	if( obj )
	{
		if( show_wnd )
		{
			obj.display = 'block';
			if (window.innerHeight)
			{
				obj.top = window.pageYOffset;
			}
			else if (document.documentElement && document.documentElement.scrollTop)
			{
				obj.top = document.documentElement.scrollTop;
			}
			else if (document.body)
			{
				obj.top = document.body.scrollTop;
			}
		}
		else
		{
			obj.display = 'none';
		}
	}
}

// Check if values selected in drop down menus are valid
function CheckDatesItem( day_name, month_name )
{
	var day_obj, month_obj;
	var monthMax = new Array(31, 29, 31, 30, 31, 30, 31, 31 ,30, 31, 30, 31);

	if( document.all )
	{
    	day_obj = document.all(day_name);
    	month_obj = document.all(month_name);
    }
    else if (document.getElementById)
    {
    	day_obj = document.getElementById(day_name);
    	month_obj = document.getElementById(month_name);
    }
    else if(document.layers)
    {
    	day_obj = document.layers[day_name];
    	month_obj = document.layers[month_name];
    }

    if( day_obj && month_obj )
    {
		var sel_year = month_obj.options[month_obj.selectedIndex].value.substring(0, 4);
		var sel_month = month_obj.options[month_obj.selectedIndex].value.substring(4, 6);
		var sel_day = day_obj.options[day_obj.selectedIndex].value;

		var month = parseInt( sel_month, 10 );
		var day = parseInt( sel_day, 10 );
		var year = parseInt( sel_year, 10 );

		if (day > monthMax[month-1])
		{
			return false;
		}

		// Now check if the date is in future but not in past
		var now_date = new Date();
		var sel_date = new Date(year, month-1, day, now_date.getHours(), now_date.getMonth(), now_date.getSeconds());

		if( now_date.getTime() > sel_date.getTime() )
		{
			return false;
		}
    }

    return true;
}

// Just for debug to see the properties of the object
function show_props(obj)
{
	var result = "";
	for (var i in obj)
	{
		result += "." + i + " = " + obj[i] + " | ";
	}
	return result;
}

// Not used now but for further implementations
function showProgress1(obj_name)
{
	var obj;

	if( document.all )
	{
    	obj = document.all(obj_name);
    }
    else if (document.getElementById)
    {
    	obj = document.getElementById(obj_name);
    }
    else if(document.layers)
    {
    	obj = document.layers[obj_name];
    }

    if( obj )
    {
		// MSIE - document.body.clientWidth, clientHeight
		// Netscape, Mozilla, Opera - innerWidth, innerHeight
		if(document.all)
		{
			iW = "document.body.clientWidth";
			iH = "document.body.clientHeight";
		}
		else
		{
			iW = "window.innerWidth";
			iH = "window.innerHeight";
		}
		// Ну а как загрузится документ:
		ClWidth = eval(iW);
		ClHeight = eval(iH);

		obj.style.visibility = "visible";

		if( document.all)
		{
			obj.style.pixelTop = Math.round(ClWidth / 2) - 100;
			obj.style.pixelLeft = Math.round(ClHeight / 2) - 100;
		}
		else
		{
			obj.top = Math.round(ClWidth / 2) - 100;
			obj.left = Math.round(ClHeight / 2) - 100;
		}
    }
}

function GetObject( obj_name )
{
    var obj = null;

	if( document.all )
	{
    	obj = document.all(obj_name);
    }
    else if (document.getElementById)
    {
    	obj = document.getElementById(obj_name);
    }
    else if(document.layers)
    {
    	obj = document.layers[obj_name];
    }
    else
    {
    	obj = null;
    }

    return obj;
}
