// ----- Popup & show hide Control ---------------------------------------------------------


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
var xmlHttp,xmlHttp1;
function show_TextHome(s)
		{
			//alert('linkmoredetail'+s+" hhhh");
			//document.getElementById(txtSecondBlock).style.display = "inline";
			if(s==14)
			{
				if(document.getElementById('mchide'))
					document.getElementById('mchide').style.display = "none";
			}
			if(document.getElementById('t'+s))	
				document.getElementById('t'+s).style.display = "inline";
			if(document.getElementById('linkmoredetail'+s))
				document.getElementById('linkmoredetail'+s).style.display = "none";
			if(document.getElementById('linkhidedetail'+s))
				document.getElementById('linkhidedetail'+s).style.display = "inline";
		}
		function show_TextHome1(s)
		{
			if(s==14)
			{
				
					document.getElementById('mchide').style.display = "inline";
			}
					document.getElementById('t'+s).style.display = "none";
			document.getElementById('linkmoredetail'+s).style.display = "inline";
			document.getElementById('linkhidedetail'+s).style.display = "none";
		}
		
	function show_NarrowResultBlock_nhood()
	{		/* this function is for popular categories page in which Narrow Your Result By Neighborhood  */
			document.getElementById('nhood').style.display = "inline";
			document.getElementById('divNarrowHidden_nhood').style.display = "none";
			document.getElementById('divNarrowShown_nhood').style.display = "inline";
	}	
	function hide_NarrowResultBlock_nhood()
	{	/* this function is for popular categories page in which Narrow Your Result By Neighborhood  */
		
			document.getElementById('nhood').style.display = "none";
			document.getElementById('divNarrowHidden_nhood').style.display = "inline";
			document.getElementById('divNarrowShown_nhood').style.display = "none";
	}
	function show_NarrowResultBlock()
	{		
			document.getElementById('popularcat').style.display = "inline";
			document.getElementById('divNarrowHidden').style.display = "none";
			document.getElementById('divNarrowShown').style.display = "inline";
	}
	function hide_NarrowResultBlock()
	{	
			document.getElementById('popularcat').style.display = "none";
			document.getElementById('divNarrowHidden').style.display = "inline";
			document.getElementById('divNarrowShown').style.display = "none";
	}
	function show_Text(s)
		{
			var displayusername,txtSecondBlock,filename;
		//	alert('showtext'+s);
			displayusername=document.getElementsByName("displayusername")[0].value;
			if(displayusername==0)
			{
			show_TextHome(s);
			}
			else
			{
			filename=document.getElementsByName("filename")[0].value;
			//alert(displayusername);
//			for(i=1;i<=s;i++)
			//{
			
			txtSecondBlock="t"+s;
			//alert('linkmoredetail'+s);
			document.getElementById(txtSecondBlock).style.display = "inline";
			document.getElementById('linkmoredetail'+s).style.display = "none";
			document.getElementById('linkhidedetail'+s).style.display = "inline";
			//}
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 	
			var url="../fileadmin/storetab.php";
			url=url+"?tabid="+s+"&tabname=tab&displayusername="+displayusername+"&content=insert&filename="+filename;
			URL=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			}
		}
	function show_Text1(a)
		{
			var displayusername,filename;
			displayusername=document.getElementsByName("displayusername")[0].value;
			filename=document.getElementsByName("filename")[0].value;
			if(displayusername==0)
			{
			show_TextHome1(a);
			}
			else
			{
			//for(i=1;i<=a;i++)
			//{
			document.getElementById('t'+a).style.display = "none";
			document.getElementById('linkmoredetail'+a).style.display = "inline";
			document.getElementById('linkhidedetail'+a).style.display = "none";
			//}
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 	
			var url="../fileadmin/storetab.php";
			url=url+"?tabid="+a+"&tabname=tab&displayusername="+displayusername+"&content=delete&filename="+filename;
			URL=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=stateChanged;

			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			}
		}
		
		function show_Tab(s)
		{
			var displayusername,filename;
			displayusername=document.getElementsByName("displayusername")[0].value;
			filename=document.getElementsByName("filename")[0].value;
		//	alert(s);
		//	alert(filename);
			var j=1;
			for(i=1;i<=s;i++)
			{
			document.getElementById('tab'+s).style.display = "inline";
			document.getElementById('shodetail'+s).style.display = "none";
			document.getElementById('hidedetail'+s).style.display = "inline";
			//alert('tab'+document.getElementById('tab'+s).style.display);
			}
			while(j<=3)
			{
				if(j!=s)
				{
					hide_tab(j);
				}
				else
				{
					xmlHttp=GetXmlHttpObject()
					if (xmlHttp==null)
					{
						alert ("Browser does not support HTTP Request")
						return
					} 	
					var url="../fileadmin/storetab.php";
					url=url+"?tabid="+s+"&tabname=tabtext&displayusername="+displayusername+"&content=insert&filename="+filename;
					URL=url+"&sid="+Math.random();
					xmlHttp.onreadystatechange=stateChanged;
					xmlHttp.open("GET",url,true);
					xmlHttp.send(null);
				}
				j++;
			}
		}
	function hide_tab(a)
		{
		var displayusername,filename;
			displayusername=document.getElementsByName("displayusername")[0].value;
			filename=document.getElementsByName("filename")[0].value;
			for(i=1;i<=a;i++)
			
			{
			document.getElementById('tab'+a).style.display = "none";
			document.getElementById('shodetail'+a).style.display = "inline";
			document.getElementById('hidedetail'+a).style.display = "none";
			xmlHttp=GetXmlHttpObject()
					if (xmlHttp==null)
					{
						alert ("Browser does not support HTTP Request")
						return
					} 	
					var url="../fileadmin/storetab.php";
					url=url+"?tabid="+a+"&tabname=tabtext&displayusername="+displayusername+"&content=delete&filename="+filename;
					URL=url+"&sid="+Math.random();
					xmlHttp.onreadystatechange=stateChanged;
					xmlHttp.open("GET",url,true);
					xmlHttp.send(null);
			}
		}
		function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("divCustomerInfo").innerHTML=xmlHttp.responseText 
	} 
} 
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{    
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{    
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
return objXMLHttp
}



/*function at_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}*/

// ----- Show Aux -----

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}

// ----- Hide -----

function at_hide()
{
  
  var c = document.getElementById(this["at_child"]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'",0);
}

// ----- Click -----

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible")
       at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";

  return false;
}

// ----- Attach -----

// PARAMETERS:
// parent   - id of visible html element
// child    - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
//            "hover" = you should place the mouse over the parent to show
//                      the child
// position - "x" = the child is displayed to the right of the parent
//            "y" = the child is displayed below the parent
// cursor   - Omit to use default cursor or check any CSS manual for possible
//            values of this field

function at_attach(parent, child, showtype, position, cursor)
{
	
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  //alert(p);
  //alert(c);
  if(p != null || c != null)
  {
		  p["at_parent"]     = p.id;
		  c["at_parent"]     = p.id;
		  p["at_child"]      = c.id;
		  c["at_child"]      = c.id;
		  p["at_position"]   = position;
		  c["at_position"]   = position;
		
		  c.style.position   = "absolute";
		  c.style.visibility = "hidden";
		
	  if (cursor != undefined) p.style.cursor = cursor;
	
	  switch (showtype)
	  {
	    case "click":
	      p.onclick     = at_click;
	      p.onmouseout  = at_hide;
	      c.onmouseover = at_show;
	      c.onmouseout  = at_hide;
	      break;
	    case "hover":
	      p.onmouseover = at_show;
	      p.onmouseout  = at_hide;
	      c.onmouseover = at_show;
	      c.onmouseout  = at_hide;
	      break;
	  }
  }
}

