﻿var slideShowSpeed =5000; 
var crossFadeDuration = 3;
var istop=0;
var Pic = new Array(); 
var PicUrl = new Array(); 
var mota=new Array();
var PicCaption = new Array(); 
PicUrl[0] = '#';
PicUrl[1] = '#';
var m_intTimeOut;
var j = 0;
var m_intArrayLen ;
var cc_value;
var preLoad = new Array();
var link=""
function onclickhinh(c_value,vitri)
{
	//alert(vitri);
	cc_value=c_value;
	j=vitri;
	//if (document.all){
			//document.images.SlideShow.style.filter="blendTrans(duration=2)";
			//document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
			//document.images.SlideShow.filters.blendTrans.Apply(); 
		//	}
			document.images.SlideShow.src = preLoad[j].src;
			PageNav=PicUrl[j];
			var ichay =j;
			do{
				if(mota[ichay]=="")
				{
					ichay=ichay-1;	
				}else break;
			}while(ichay>=0);
			if(mota[ichay]==null)
				mota[ichay]="";
		
			if(j==0)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#ff9933'>"+mota[ichay]+"</font>";
			if(j==1)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#33cc33'>"+mota[ichay]+"</font>";
			if(j==2)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#ff0066'>"+mota[ichay]+"</font>";
			if(j==3)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#3333ff'>"+mota[ichay]+"</font>";
			//if (document.all){
			//document.images.SlideShow.filters.blendTrans.Play();
			//}
	
		//if(j==0){
			for(i=1 ;i<=Pic.length;i++){
			
				if(i==parseInt(j)+1)
				
			
				document.getElementById("td"+i).style.backgroundColor = "#ebeff9";
				
				
				else
				document.getElementById("td"+i).style.backgroundColor = "#ffffff";  
			}
	istop=1;
	clearTimeout(m_intTimeOut);
	document.getElementById('Stop').value='Play';
	
}

function initMang(hinh,tocdo,c_value,mota1,mota2,mota3,mota4,vitri,sohinh)
{


var sManghinh = hinh.split("|");
	cc_value=c_value;
	
	

	slideShowSpeed = tocdo;
	for(i=0;i<sohinh;i++)
	{
		Pic[i]="Slide/"+sManghinh[i];
	} 
	mota[0] =mota1;
	mota[1] = mota2;
	mota[2] = mota3;
	mota[3] = mota4;	

	m_intArrayLen = Pic.length;
		
	for (i = 0; i < m_intArrayLen; i++)
	{
	preLoad[i] = new Image();
	preLoad[i].src = Pic[i]
	
	}
	

	j=vitri;
	runSlideShow();
}

function runSlideShow(){
//try{
	if(j>=Pic.length){
				cc_value=parseInt(cc_value)+1;	
				m_intTimeOut = setTimeout('redirect()', slideShowSpeed);
		}
		if(istop==0){		
		
		//	if (document.all){
		//	document.images.SlideShow.style.filter="blendTrans(duration=2)";
		//	document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		//	document.images.SlideShow.filters.blendTrans.Apply(); 
		//	}else if(document.getElementById && !(document.all)) {
			//alert('gtfgg');
		//document.getElementById('Slideshow').style.MozOpacity = Math.round(0.6 ); 

//alert('gtfgg');
	//		}
			document.images.SlideShow.src = preLoad[j].src;
			PageNav=PicUrl[j];
			var ichay =j;
			do{
				if(mota[ichay]=="")
				{
					ichay=ichay-1;	
				}else break;
			}while(ichay>=0);
			if(mota[ichay]==null)
				mota[ichay]="";
		
			if(j==0)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#ff9933'>"+mota[ichay]+"</font>";
			if(j==1)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#33cc33'>"+mota[ichay]+"</font>";
			if(j==2)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#ff0066'>"+mota[ichay]+"</font>";
			if(j==3)	
			document.getElementById("mota").innerHTML ="<font face='Arial' size='4' color='#3333ff'>"+mota[ichay]+"</font>";
			//if (document.all){
		//document.images.SlideShow.filters.blendTrans.Play();
		//	}//else
			  //  true; 

	
			for(i=1 ;i<=Pic.length;i++){
			
				if(i==parseInt(j)+1)
				document.getElementById("td"+i).style.backgroundColor = "#eeeeee";
				else
				document.getElementById("td"+i).style.backgroundColor = "#ffffff";  
			}
		

			j = j + 1;
		
		
			m_intTimeOut = setTimeout('runSlideShow()', slideShowSpeed);
		}else
		{
		istop=1;
		m_intTimeOut = setTimeout('runSlideShow()', slideShowSpeed);
		
		}
//}catch(err)
//{
//	vitri=parseInt(vitri)+1;
//	m_intTimeOut = setTimeout('runSlideShow()', slideShowSpeed);
//}
		
}
	function redirect()
	{
	
		if(istop==0){	
		window.document.location.href="iSlide.aspx?"+link+"iVitri="+cc_value;
		}else
		{
			runSlideShow();
		}
	}
function ghihtml()
{
	
	document.write('<tr><td><img src="" alt="" height ="50" width="50"  ></td></tr>');
	document.write('<tr><td><img src="" alt="" height ="50" width="50"  ></td></tr>');
	document.write('<tr><td><img src="" alt="" height ="50" width="50"  ></td></tr>');
	document.write('<tr><td><img src="" alt="" height ="50" width="50"  ></td></tr>');
}
function onclickbutton()
{
	
	if(document.getElementById('Stop').value=='Stop' )
	{
			document.getElementById('Stop').value='Play';
			stop();
	}else
	{
		document.getElementById('Stop').value='Stop';
			play();
	}
 

}
function stop()
{
	//if(document.getElementById("stop").innerHTML=="Stop" )	
	istop=1;
	clearTimeout(m_intTimeOut);
}
function play()
{

	//if(document.getElementById("stop").innerHTML=="Stop" )	
	istop=0;	
	m_intTimeOut = setTimeout('runSlideShow()', 2000);
	
}
function pre(vitri)
{
//alert(cc_value);
	if(parseInt(vitri)-1>0)
	vitri=parseInt(vitri)-1;
	window.document.location.href="iSlide.aspx?"+link+"iVitri="+vitri;
}
function next(vitri)
{
//alert(cc_value);
	//if(parseInt(vitri)-1>0)
	vitri=parseInt(vitri)+1;
	window.document.location.href="iSlide.aspx?"+link+"iVitri="+vitri;
}
//-------------------------------------------------------------------
			
			var slideShowSpeeddefault =4000; 
			var m_intTimeOutdefault;
			var k = 0;
			//var m_intArrayLen=0;
			//var Pic = new Array(); 
			var sManghinhdefault=new Array();
			var sMangmota=new Array();
			var sMangID=new Array();
			var istopdefault=0;
function mouseover()
{
	istopdefault=1;
	clearTimeout(m_intTimeOutdefault);
	
}
function mouseout()
{
	istopdefault=0;
	m_intTimeOutdefault = setTimeout('runSlideShowdefault()', slideShowSpeeddefault);
	
}
function initMangdefault(hinh,mota,id)
			{
				//alert(mota);
				sManghinhdefault = hinh.split("|");
			//	alert(sManghinh[0]);
				sMangmota = mota.split("|");
				//alert(sMangmota[0]);
				sMangID = id.split("|");
				//for(i=0;i<sohinh;i++)
				//{
				//	Pic[i]=sManghinh[i];
			//	} 
			//	m_intArrayLen = sohinh;
				//alert(Pic[0]);
				runSlideShowdefault();
			}

function runSlideShowdefault(){
//try{
//alert(m_intArrayLen);
	
	if(sManghinhdefault.length!=1){
	//alert(k);	
		if(k>=sManghinhdefault.length){
			k=0;
			//clearTimeout(m_intTimeOut);	
			//alert(k);		
			//m_intTimeOut=0;
		}
		else
		{
			var schitiet=sMangmota[k].split("^");
			document.getElementById("cellhinh").innerHTML ="<a href='Slide.aspx?pos="+sMangID[k]+"'><img src='"+sManghinhdefault[k]+"' alt='' border='0'></a>";
			document.getElementById("cellchitiet").innerHTML ="<a style='TEXT-DECORATION: none' href='Slide.aspx?pos="+sMangID[k]+"'><font face='Arial' size='2' color='#000080'><b>"+schitiet[0]+"</b></font></a> <br> <font face='Arial' size='2' color='#000080'>Giá: </font><font face='Arial' size='2' color='#ff0000'><b>"+schitiet[1]+"</b></font><br><font face='Arial' size='2' color='#000000'>Liên hệ: <b>"+schitiet[2]+"</b></font></br><a href='uupdateslide.aspx' style='text-decoration: none'><img border='0' src='giaodien/New_icons_22.gif'><font face='Arial' size='2' color='#000080'><b> Đăng sản phẩm của bạn tại đây</b></font><a>";			
			k++;
					

		}
		if(istopdefault==0){
		m_intTimeOutdefault = setTimeout('runSlideShowdefault()', slideShowSpeeddefault);
		}		
	}
	else
	{
		var schitiet=sMangmota[k].split("^");
		document.getElementById("cellhinh").innerHTML ="<a href=''><img src='"+sManghinhdefault[k]+"' alt='' border='0'></a>";
		document.getElementById("cellchitiet").innerHTML ="<a style='TEXT-DECORATION: none' href='Slide.aspx?pos="+sMangID[k]+"'><font face='Arial' size='2' color='#000080'><b>"+schitiet[0]+"</b></font></a> <br> <font face='Arial' size='2' color='#000080'>Giá: </font><font face='Arial' size='2' color='#ff0000'><b>"+schitiet[1]+"</b></font><br><font face='Arial' size='2' color='#000000'>Liên hệ: <b>"+schitiet[2]+"</b></font></br><a href='uupdateslide.aspx' style='text-decoration: none'><img border='0' src='giaodien/New_icons_22.gif'><font face='Arial' size='2' color='#000080'><b> Đăng sản phẩm của bạn tại đây</b></font><a>";
	}	
}