var Tout;

function showActiveMenu(id)
{
	if(document.getElementById(id))
		document.getElementById(id).style.display = "block"; 
}



function show(id, num, prefix)
{
	prefix = 'subm';//prefix ? prefix : 'subm';
	
	for(i = 0; i < num; i++)
	{
		if(document.getElementById(prefix + i))
		{
			document.getElementById(prefix + i).style.display = "none";
		}
	}
	//for(var i in document.getElementById(prefix))
	//	alert(i);
 	if(Tout != "") clearTimeout(Tout); 
 	//alert(id);
   	document.getElementById(prefix + id + '').style.display = "block";
}

function hide(id, prefix)
{
	prefix = 'subm';//prefix ? prefix : 'subm';
 	if(Tout != "") 
 		clearTimeout(Tout); 
   	Tout = setTimeout("document.getElementById('" + prefix + id + "').style.display='none'", 50);
}

function expand(id)
{
   element = document.getElementById(id);
   element.style.display =(element.style.display=="block") ? "none" : "block";
}


//****************************************************************//

function Toggle(id1,id2,obj,color)
{

	setTimeout(function(){ChangeColor(obj,color);} ,0);
	document.getElementById(id1).style.display ="none";
	document.getElementById(id2).style.display ="block";
}

function ChangeColor(obj,color)
{
	obj.style.backgroundColor ="#"+color;
}

function linkMouseOver(obj)
{
	obj.style.backgroundColor ="#A33905";
	obj.style.color  = "#fff";

}

function linkMouseOut(obj)
{
	obj.style.backgroundColor="#fff";
	obj.style.color="#000";

}

function lang(lang)
{
	var current=window.location.href;
	var new_loc;
	if(/lang=/.test(current))
		new_loc=current.replace(/lang=\w*/,"lang="+lang);
	else if(/\?/.test(current))
		new_loc=current+"&lang="+lang;
	else
		new_loc=current+"?lang="+lang;
	window.location.replace(new_loc);
}


var send = function(link)
{
   var dataToSend =document.getElementById('calendar_y').value+"."+document.getElementById('calendar_m').value;
   var ajax = new httpAjaxRequest();
   if(ajax)
   {
		ajax.prepareHash({date:dataToSend});
       	ajax.open("GET", "ajax.php");
       	ajax.send();
       	ajax.getData();
       	ajax.onreadystatechange = function()
	     {
	         data = ajax.getResult();
	         document.getElementById("calendar_div").innerHTML =data.calendar;
	     }
	}
	else
		window.location =link + document.getElementById('calendar_y').value+"."+document.getElementById('calendar_m').value;
}



function showPic(pic,width,height)
{
	sDesrc = "width=" + width + ", height=" + height +
	         ", status=no, toolbar=no, menubar=no, scrollbars=no";
	win=window.open("Gallery", "", sDesrc);
	win.document.write("<html><style>body{padding:0px;margin:0px;}</style><body>");
	win.document.write("<img src='"+pic+"' width='"+width+"' height='"+height+"'><br>");
	win.document.write("</body></html>");
	win.document.close();
}

function field_check(names, fieldlabels)
{
	var fields = new Array();
	var k = 0;
	for (i=0; i<names.length; i++)
	{
		if (document.form1.elements[names[i]].value == "")
		{
			fields[k] = fieldlabels[i];
			k++;
		}
	}
	if (fields.length>0)
	{
		var result = "The field(s) '" + fields.join(", ") + "' should be is filled";
		alert(result);
		return false;
	}
	return true;
}

function createElement(ElemType,newID,parentID)
{
	var newElem = document.createElement(ElemType);
	newElem.setAttribute("id", newID); // <=> newElem.id = newID;
	newElem.setAttribute("style", "width:100%; height:200px; border:1px Solid red;");
	document.getElementById(parentID).appendChild(newElem);
}

function printDivContent(elmID)
{
	createElement("iframe","iframe"+elmID,"tmp");
	document.getElementById("iframe"+elmID).contentWindow.document.body.innerHTML = document.getElementById(elmID).innerHTML;
	document.getElementById("iframe"+elmID).contentWindow.print();
}
