var slideMenu1=function(){
	var sp1,st1,t1,m1,sa1,l1,w1,sw1,ot1;
	return{
		build:function(topnav,sw1,mt1,s1,sl1,h1){
			sp1=s1; st1=sw1; t1=mt1;
			m1=document.getElementById(topnav);
			sa1=m1.getElementsByTagName('li');
			l1=sa1.length; w1=m1.offsetWidth; sw1=w1/l1;
			ot1=Math.floor((w1-st1)/(l1-1)); var i=0;
			for(i;i<l1;i++){s1=sa1[i]; s1.style.width=sw1+'px'; this.timer(s1)}
			if(sl1!=null){m1.timer=setInterval(function(){slideMenu1.slide(sa1[sl1-1])},t1)}
		},
		timer:function(s1){s1.onclick=function(){clearInterval(m1.timer);m1.timer=setInterval(function(){slideMenu1.slide(s1)},t1)}},
		slide:function(s1){
			var cw1=parseInt(s1.style.width,'10');
			if(cw1<st1){
				var owt1=0; var i=0;
				for(i;i<l1;i++){
					if(sa1[i]!=s1){
						var o1,ow1; var oi1=0; o1=sa1[i]; ow1=parseInt(o1.style.width,'10');
						if(ow1>ot1){oi1=Math.floor((ow1-ot1)/sp1); oi1=(oi1>0)?oi1:1; o1.style.width=(ow1-oi1)+'px'}
						owt1=owt1+(ow1-oi1)}}
				s1.style.width=(w1-owt1)+'px';
			}else{clearInterval(m1.timer)}
		}
	};
}();

var slideMenu2=function(){
	var sp2,st2,t2,m2,sa2,l2,w2,sw2,ot2;
	return{
		build:function(preview_slider,sw2,mt2,s2,sl2,h2){
			sp2=s2; st2=sw2; t2=mt2;
			m2=document.getElementById(preview_slider);
			sa2=m2.getElementsByTagName('li');
			l2=sa2.length; w2=m2.offsetWidth; sw2=(w2/l2);
			ot2=Math.floor((w2-st2)/(l2-1)+6); var i=0;
			for(i;i<l2;i++){s2=sa2[i]; s2.style.width=sw2+'px'; this.timer(s2)}
			if(sl2!=null){m2.timer=setInterval(function(){slideMenu2.slide(sa2[sl2-1])},t2)}
		},
		timer:function(s2){s2.onclick=function(){clearInterval(m2.timer);m2.timer=setInterval(function(){slideMenu2.slide(s2)},t2)}},
		slide:function(s2){
			var cw2=parseInt(s2.style.width,'10');
			if(cw2<st2){
				var owt2=0; var i=0;
				for(i;i<l2;i++){
					if(sa2[i]!=s2){
						
						var o2,ow2; var oi2=0; o2=sa2[i]; ow2=parseInt(o2.style.width,'10');
						if(ow2>ot2){oi2=Math.floor((ow2-ot2)/sp2); oi2=(oi2>0)?oi2:1; o2.style.width=(ow2-oi2)+'px'}
						owt2=owt2+(ow2-oi2)}}
				var except_li = l2-1;
				extra_space = except_li * 6; // to nutalize the margin padding
				s2.style.width=(w2-owt2)+extra_space+'px'; // total output value
				
				//s2.style.width=(w2-owt2)+'px'; // origional code.
			}else{clearInterval(m2.timer)}
		}
	};
}();

