function chit()	{
	var f=document;
	f.headform.action='login.php';
	if (document.all) {
		f.headform.email.value=f.all['name'].value;
		f.headform.upass.value=f.all['pass'].value;
		f.headform.submit();
	}else {
		f.headform.email.value=f.getElementById('name').value;
		f.headform.upass.value=f.getElementById('pass').value;
		f.headform.submit();
	} 

}

function initsearch()	{
	var f=document;
		f.headform.action='search.php';

	if (document.all) {
		f.headform.city_id.value=document.all['cicobox'].value;
		f.headform.searchw.value=document.all['search'].value;
		f.headform.submit();
	}else {
		f.headform.city_id.value=f.getElementById('cicobox').value;
		f.headform.searchw.value=f.getElementById('search').value;
		f.headform.submit();
	} 


	/**/
}
 function ValidateAsEmail (emailStr) {
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {			return false		}
		var user=matchArray[1]
		var domain=matchArray[2]


		if (user.match(userPat)==null) {			return false		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {		  for (var i=1;i<=4;i++) {				if (IPArray[i]>255) {				return false				}			}			return true		}

		var domainArray=domain.match(domainPat)
		if (domainArray==null) {			return false		}

		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 ||		domArr[domArr.length-1].length>5) {		   return false		}

		if (len<2) {	   return false	}	

	return true;
		
}

function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function xstooltip_show(tooltipId, parentId, posX, posY)
{
    it = document.getElementById(tooltipId);
	pit = document.getElementById(parentId);
    
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth;
        it.style.height = it.offsetHeight;
        
        img = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;
        
     //   it.style.top = y;
      //  it.style.left = x;
    }
    
    it.style.visibility = 'visible'; 
}

function xstooltip_hide(id)
{
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}



function show_hide(divName) {
	if (document.getElementById) {
		obj=document.getElementById(divName)
	} else if (document.all) {
		obj=document.all[divName]
	}

	if (obj) {
		if (obj.style.display == "none") {
			obj.style.display = '';
			obj.focus();
		}
		else {
			obj.style.display = 'none';
		}
	}
}


function select_city()
{
		var x=document.getElementById("cicobox")
		var x2=document.getElementById("cibox")
		x2.value='   '+x.options[x.selectedIndex].text
		show_hide('cicobox');
}


function lostfocus() {
	if (document.getElementById) {
		obj=document.getElementById('cicobox')
	} else if (document.all) {
		obj=document.all['cicobox']
	}

	if (obj) {
			obj.style.display = 'none';
	}
}

function popWin1(x, wi, he, wi2, he2) {   w = screen.width;     h = screen.height;    sx = w/2-wi2;    sy = h/2-he2;   window.open(x,'','status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,width='+wi+',height='+he+',top='+sy+',left='+sx+',screenX='+sx+',screenY='+sy+'');		}


function WinOpen(url,name,width,height,top,left,scroll,status){
	if(!status) status = 0;
	if(!scroll) scroll = 'yes';
	if(!name) name = 'mywin';
	if(!width) width = '430';
	if(!height) height = '335';
	if(!top) top = (screen.height/2) - (height/2);
	if(!left) left = (screen.width/2) - (width/2);

	properties='history=no,toolbar=0,location=0,directories=0,scrollbars='+scroll+',status='+status+',menubar=0,width='+width+',height='+height+',top='+top+',left='+left+'';

	window.open(url,name,properties) ;
}

function chita() {
  if (window.event && window.event.keyCode == 13)
    chit();
  else
    return true;
  }

function initsearcha() {
  if (window.event && window.event.keyCode == 13)
    initsearch();
  else
    return true;
  }


  function show_hide_prop(divName) {
	if (document.getElementById) {
		obj=document.getElementById(divName)
	} else if (document.all) {
		obj=document.all[divName]
	}

	if (obj) {
		if (obj.style.display == "none") {
			obj.style.display = '';
		}
		else {
			obj.style.display = 'none';
		}
	}
}