
// Top Navigation animate menu

var menuSlider=function(){
	var m,e,g,s,q,i; e=[]; q=15; i=8;
	return{
		init:function(j,k){
			m=document.getElementById(j); e=m.getElementsByTagName('li');
			var i,l,w,p; i=0; l=e.length;
			for(i;i<l;i++){
				var c,v; c=e[i]; v=c.value; if(v==1){s=c; w=c.offsetWidth; p=c.offsetLeft}
				c.onmouseover=function(){menuSlider.mo(this)}; c.onmouseout=function(){menuSlider.mo(s)};
			}
			g=document.getElementById(k); g.style.width=w+'px'; g.style.left=p+'px';
		},
		mo:function(d){
			clearInterval(m.tm);
			var el,ew; el=parseInt(d.offsetLeft); ew=parseInt(d.offsetWidth);
			m.tm=setInterval(function(){menuSlider.mv(el,ew)},i);
		},
		mv:function(el,ew){
			var l,w; l=parseInt(g.offsetLeft); w=parseInt(g.offsetWidth);
			if(l!=el||w!=ew){
				if(l!=el){var ld,lr,li; ld=(l>el)?-1:1; lr=Math.abs(el-l); li=(lr<q)?ld*lr:ld*q; g.style.left=(l+li)+'px'}
				if(w!=ew){var wd,wr,wi; wd=(w>ew)?-1:1; wr=Math.abs(ew-w); wi=(wr<q)?wd*wr:wd*q; g.style.width=(w+wi)+'px'}
			}else{clearInterval(m.tm)}
}};}();


// Top Search drop down menu

var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();



// Main Search Tab Script

function test(firstdiv_id)
{
		document.getElementById("mtab_img1").src="images/auto_tab.gif";
		document.getElementById("mtab_img2").src="images/jobs_tab.gif";
		document.getElementById("mtab_img3").src="images/merchandise_tab.gif";
		document.getElementById("mtab_img4").src="images/personal_tab.gif";
		document.getElementById("mtab_img5").src="images/realestate_tab.gif";
		document.getElementById("mtab_img6").src="images/services_tab.gif";
	if(firstdiv_id=="msearch_a")
	{
		document.getElementById("mtab_img1").src="images/auto_tab_hov.gif";
					
	}
	else if(firstdiv_id=="msearch_b")
	{		
		document.getElementById("mtab_img2").src="images/jobs_tab_hov.gif";
			
	}
	else if(firstdiv_id=="msearch_c")
	{		
		document.getElementById("mtab_img3").src="images/merchandise_tab_hov.gif";
			
	}
	else if(firstdiv_id=="msearch_d")
	{		
		document.getElementById("mtab_img4").src="images/personal_tab_hov.gif";
			
	}
	else if(firstdiv_id=="msearch_e")
	{		
		document.getElementById("mtab_img5").src="images/realestate_tab_hov.gif";		
		
	}
	else if(firstdiv_id=="msearch_f")
	{
		document.getElementById("mtab_img6").src="images/services_tab_hov.gif";	
	}


	
  	if(document.getElementById(firstdiv_id).style.display=="none")
	{
		var arr=["msearch_a","msearch_b","msearch_c","msearch_d","msearch_e","msearch_f"];
		var i;

		for(i=0;i<arr.length;i++)
		{

		document.getElementById(arr[i]).style.display="none";		
		}
		
		fadein(firstdiv_id);
	}
}

function fadein(rr)
{
	$("#"+rr).fadeIn(500);
	document.getElementById(rr).style.display="block";
	
}


// Featured Ads Slide Scripts


// Change location Script

var flagnew=0;
function changelocation()
{
	
		if(flagnew==0)
		{
	   	$("#slidedown_demo").slideDown("slow");
		  document.getElementById("menu").style.visibility="hidden";
		 flagnew=1;
		 }
		 else
		 {
	     	$("#slidedown_demo").slideUp("slow");
			 flagnew=0;
			 settime1();
		 }
}
		  
function cancel()
{
		 		$("#slidedown_demo").slideUp("slow");
	settime1();	  
		  	
}
function settime1()
{
	
	time1=setTimeout(menuhide,400);
}

function menuhide()
{
	   document.getElementById("menu").style.visibility="visible";
flagnew=0;
}

// Search Photoview portion

  function next1(id1,labelid)
{
 var t_im=document.getElementById(id1);
   var t1=document.getElementById(labelid);
   var im_arr=t_im.getElementsByTagName('img');
  t1.innerHTML++;
  if(t1.innerHTML>"8")
  {
  	t1.innerHTML="8";
  }
  else
  {
  
	 for(var pvt=0;pvt<im_arr.length-1;pvt++)
	 {
	 	if(im_arr[pvt].style.display=="block")
		{	
			im_arr[pvt++].style.display="none";
		 	im_arr[pvt].style.display="block";
		}
	 
	 }
  }
}
function prev1(id1,labelid)
{
	 var t_im=document.getElementById(id1);
     var t1=document.getElementById(labelid);
	 var im_arr=t_im.getElementsByTagName('img');

  		t1.innerHTML--;
	  if(t1.innerHTML<"1")
	  {
  			t1.innerHTML="1";
	  }
	  else
	  {
  
		for(var pvt=im_arr.length-1;pvt>0;pvt--)
		{
			if(im_arr[pvt].style.display=="block")
			{	
				im_arr[pvt--].style.display="none";
		 		im_arr[pvt].style.display="block";
			}
	 	}
	}
}



// Details Slide show portion

function imagechange(id1)
{
	document.getElementById("MainPic").src=id1.src;
	document.getElementById("cenpic").href=id1.src;
//alert(id1.src);

}


// Details Page Report and comments view scripts

function change(value_change){
	if(value_change==0){
	
		if(document.getElementById('reports_div').style.display=="none"){
			document.getElementById('comments_div').style.display="none";
			document.getElementById('reports_div').style.display="block";		
			
		}
		else	
			document.getElementById('reports_div').style.display="none";	

	}
	
	else{
		if(document.getElementById('comments_div').style.display=="none"){
	document.getElementById('reports_div').style.display="none";
				document.getElementById('comments_div').style.display="block";
			
		}
		else
			document.getElementById('comments_div').style.display="none";
	}

}



// Details Page Tab Script

function dtab(seconddiv_id)
{
		document.getElementById("dettab_img1").src="../images/similarads_tab.gif";
		document.getElementById("dettab_img2").src="../images/sellersad_tab.gif";
	if(seconddiv_id=="detpart_a")
	{
		document.getElementById("dettab_img1").src="../images/similarads_tab_hov.gif";
					
	}
	else if(seconddiv_id=="detpart_b")
	{		
		document.getElementById("dettab_img2").src="../images/sellersad_tab_hov.gif";
			
	}


	
  	if(document.getElementById(seconddiv_id).style.display=="none")
	{
		var arr=["detpart_a","detpart_b"];
		var i;

		for(i=0;i<arr.length;i++)
		{

		document.getElemtestentById(arr[i]).style.display="none";		
		}
		
		detfadein(seconddiv_id);
	}
}

function detfadein(rr1)
{
	Effect.Fade(rr1, { duration: .5, from: 0.5, to: 1 });
	document.getElementById(rr1).style.display="block";
	
}

