function showhideQuickHelp(){
	if (document.getElementById('imgShowQuickHelp').style.display == "") {
		document.getElementById('imgShowQuickHelp').style.display = "none";
		document.getElementById('imgHideQuickHelp').style.display = "";
		document.getElementById('helpwnd').style.height = "250";
	} else {
		document.getElementById('imgShowQuickHelp').style.display = "";
		document.getElementById('imgHideQuickHelp').style.display = "none";
		document.getElementById('helpwnd').style.height = "10";		
	}
}
function menuaction(id){
	if (document.getElementById(id).style.display == "") 
		document.getElementById(id).style.display = "none";
	else
		document.getElementById(id).style.display = "";
}
function confirmmsg(msg){
	if (window.confirm(msg))
		return true
	else
		return false
}
function valtestint(ev){
    if (((ev.keyCode<48) || (ev.keyCode>57))&&(ev.keyCode!=46))
        event.returnValue=false;
}
function  rndstring(lng){
		var possible ='0123456789abcdefghijklmnopqrestuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		str="";
		for (i=0;i<lng;i++)
			str+=possible.charAt(Math.random()*64);	
		return str
}	
void function showwindow(url,width,height){
	window.open(url,"","width="+width+",height="+height);
}
function showpass(id,obj){	
	var str = navigator.userAgent;
	
		
	var newpos = getPos(obj);

	 var xmlhttp =  new XMLHttpRequest(); 
     xmlhttp.open('POST', 'ajax/ajaxaction.php', true); 
             
            // The callback function 
     xmlhttp.onreadystatechange = function() { 
      if (xmlhttp.readyState == 4) { 
          if (xmlhttp.status == 200) { 			
			if (!xmlhttp.responseXML.getElementsByTagName('error')[0]){				
           	 		var msg = xmlhttp.responseXML.getElementsByTagName('password')[0].firstChild.data; 
			}else{				
			  	var msg = xmlhttp.responseXML.getElementsByTagName('error')[0].firstChild.data; 
			}
			document.all["passwdf"].innerHTML=msg;	
			document.all["mypass"].style.visibility="visible";
			document.all['mypass'].style.left=230+document.all['m'+id].offsetLeft;
			document.all['mypass'].style.top=newpos.top+20 + "px";
			//pos+document.all['m'+id].offsetTop;		
          } 
       } 
     }              
            // Send the POST request 		
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
            xmlhttp.send('mailbox_id=' + id+'&action=mailpass'); 
	return false;	
}
function hidpass(){
	document.all["mypass"].style.visibility="hidden";
}
function CallAjax(xmlhttp,param){    

    xmlhttp.open('POST', 'ajax/ajaxaction.php', true); 
             
            // The callback function 
     
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
    xmlhttp.send(param);
    return xmlhttp;	 
	
}
function doajax(param,preload){		
	var xmlhttp =  new XMLHttpRequest(); 
	if (!preload)
		preload="defaultloading(1)";	

	  xmlhttp.onreadystatechange = function() { 
	  if (xmlhttp.readyState == 4){ 
        	if (xmlhttp.status == 200) {
				var result=xmlhttp.responseXML;
				var topmsg='';
				if (result.getElementsByTagName('error')[0]){	
					topmsg+='<p>Следующие поля были незаполнены или заполнены не верно:<br>'
					var err="";
					for (i=0;i<result.getElementsByTagName('error').length;i++)
						err+=result.getElementsByTagName('error')[i].firstChild.data+'<br>'; 
					topmsg+=err+"</p>";
					var img='error.gif';
				}
				if (result.getElementsByTagName('addinfo')[0]){
					topmsg+='<p>'+result.getElementsByTagName('addinfo')[0].firstChild.data+'</p>'; 
					var img='ok.gif';
				}			
				document.all["msg"].innerHTML='';	
				defaultloading(0);
				if (topmsg)	
					showinfomsg(img,topmsg);
					//document.all["msg"].innerHTML='<table width=100%  border=0 cellspacing=4 cellpadding=0 style="border-width: 1px;	 border-color: Red; border-style: solid;"><tr><td width=25 ><img src=im/'+img+' width=23 height=22></td><td>'+topmsg+'</td></tr></table><br>';
				if (result.getElementsByTagName('updatemain')[0])
					document.all["mainreg"].innerHTML = result.getElementsByTagName('msg')[0].firstChild.data; 			
				if (result.getElementsByTagName('jscript')[0]){	
					eval(result.getElementsByTagName('jscript')[0].firstChild.data);
				}
			}
	}else{		
		eval(preload);
	}
	}
	CallAjax(xmlhttp,param);		
}


function doback(url){
	window.location.href=url;
}
function getdata(obj){	
	obj=obj.elements;
	elemcount=obj.length;
	url="";
	for (i=0;i<elemcount;i++){				
		switch (obj[i].type){	
			case "checkbox":
				if (obj[i].checked){						
						url+="&"+obj[i].name+"="+obj[i].value;
				}
			break;
			case "radio":				
				if (obj[i].checked){
					url+="&"+obj[i].name+"="+obj[i].value;			
				}
			break;	
			case "select-multiple":
				for (var j=0;j<obj[i].length;j++)
					if (obj[i].options[j].selected)
						url+="&"+obj[i].name+"="+obj[i].options[j].value;
			break;
			default:
				url+="&"+obj[i].name+"="+obj[i].value;	
		}
	}	
	return url;	
}
function dosubmit(url,obj,preload){
	doajax(url+getdata(obj),preload);
	return false;
}
function showinfomsg(img,msg){
		document.all["msg"].innerHTML='<div class=blTable><table width=100%  border=0 cellspacing=4 cellpadding=0 style="border-width: 1px;	 border-color: Red; border-style: solid;"><tr><td width=25 ><img src=images/'+img+' width=23 height=22></td><td>'+msg+'</td></tr></table></div><br>';
}

function defaultloading(flag){
	//document.all["msg"].innerHTML='loading...';	
	var width=151;
	var height=44;
	var layer=document.getElementById('loadinglayer'); 
	if (flag){
		layer.style.width=width;
		layer.style.height=height;
		layer.style.left=document.body.clientWidth/2-width/2 + "px";
		layer.style.top=document.body.scrollTop+document.body.clientHeight/2-height/2 + "px";
		layer.style.display="";
		
	}else{
		layer.style.display="none";
	}
}

function delconfirm(msg){
		if (confirm(msg))
			return true;
		else
			return false;
}
function delrowfunc(id,tablname,ajaxaction){
	tabl=document.getElementById(tablname);
	tabl.deleteRow(id);
	doajax(ajaxaction);
}
function confirmdelrows(obj,msg,command,tablename,method){
	if (!confirmmsg(msg))
		return false;
	if (method==1)
		dosubmit(command,obj);
	else
		delrowfunc(getrowindex(obj),tablename,command);	
	return false;	

}
function getrowindex(obj){
	
	obj=obj.parentNode;	
	return obj.parentNode.rowIndex;
}

function getPos(obj) {	
        var curleft = 0;
        var curtop = 0;
        if(obj.offsetParent) {
          while(obj.offsetParent) {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
          }
	 }
        if(obj.x) {
          curleft += obj.x;
        }
        if(obj.y) {
          curtop += obj.y;
        }

        return {left: curleft, top: curtop};
 }

 function mytips(obj, tipid,action) {
	if (action){
		if((typeof(tipsarr)!='undefined')&&(tipsarr[tipid])){
			var tip = document.getElementById("tip");
			var tipstd=document.getElementById("tipstd");
			tipstd.innerHTML=tipsarr[tipid];
			tip.style.display = "";
			tip.style.position = "absolute";
			var pos = getPos(obj);
			tip.style.left = pos.left + "px";
			tip.style.top = (pos.top+20) + "px";
		}
	}else{
		var tip = document.getElementById("tip");
	       tip.style.display = "none";
	}
 }
function PrintAllProperty(obj)
{
    var result = "All Properties: \n";
    var j=0;
    for ( var i in obj )
    {           
	result+=i + "=" + obj[i]+"\r\n";
	if (j==25){
		alert(result);
		j=0;
		result="";
	}
	j++;
    }
    alert(result);
    

}
function oferta(){
	window.open("http://freehost.com.ua/oferta.htm","","location=no,navigation=no,width=800,height=600,scrollbars=yes");
	return false
}
