﻿function searchPhoto()
{
    var focus=document.getElementById('select');
	var tag =focus.value;
	var type='0';
	var tagOrName='name';
	if (tag == "试试输入您感兴趣的文字")
	{
	    alert("请输入要查询的内容");
	    return;
	}
   location.href='../OriginalProduct/SearchProduct.aspx?tag='+encodeURIComponent(tag)+'&ctid='+type+'&tagOrName='+tagOrName; 	
}
   

//if(window.attachEvent){
//	window.attachEvent('onload',startAutoRun); 
//}
//else{
//	window.addEventListener('load',startAutoRun,false);
//}

var autoRun = null;
var imgIndex = 0;
//开始
function startAutoRun(){
	stopRun();
	var divNameObj = getObj('divProductName');
	divNameObj.innerHTML ='<a href=\'/OriginalProduct/ProductDetail.aspx?uid='+encodeURIComponent(strStutar[0].id)+'&zid='+strStutar[0].productId+'\'>'+strStutar[0].productName+'</a>';
	var divImgObj = getObj('divProduct');
	divImgObj.className = 'divPB'+strStutar[0].productFormatId;
	var imgObj = divImgObj.getElementsByTagName('img')[0];
	imgObj.src = strStutar[0].bigSrc;
	var aProduct = document.getElementById('aProduct');
	aProduct.href= '/OriginalProduct/ProductDetail.aspx?uid='+encodeURIComponent(strStutar[0].id)+'&zid='+strStutar[0].productId+'';
	
	//用户名 产品规格名
	var userNameObj = getObj('spanUserName');
	var strA = '<a style="float:left; color:#999; text-decoration:underline;" href="/MyPhookIndex/Index.aspx?uid='+encodeURIComponent(strStutar[0].id)+'">'+strStutar[0].userName+'</a>';
	userNameObj.innerHTML = strA;
	var formatName = getObj('spanProductFormatName');
	var strHTML = '<span style="color:#999;">规格：</span>&nbsp;&nbsp;'
	formatName.innerHTML = strHTML+ strStutar[0].productFormat;
	imgIndex++;
	
	autoRun = window.setInterval(StutarProduct,4000);
}
/*停止*/
function stopRun(){
	autoRun = null;
}

//strStutar  divPB   productName bigSrc productFormatId
function StutarProduct(){
	if (!strStutar) return;
		
	var divNameObj = getObj('divProductName');
	divNameObj.innerHTML ='<a href=\'/OriginalProduct/ProductDetail.aspx?uid='+encodeURIComponent(strStutar[imgIndex].id)+'&zid='+strStutar[0].productId+'\'>'+strStutar[imgIndex].productName+'</a>';
	var divImgObj = getObj('divProduct');
	//divImgObj.filters[0].apply();
	divImgObj.className = 'divPB'+strStutar[imgIndex].productFormatId;
	
	var imgObj = divImgObj.getElementsByTagName('img')[0];
	//imgObj.filters[0].apply();
	imgObj.src = strStutar[imgIndex].bigSrc;
	var aProduct = document.getElementById('aProduct');
	aProduct.href= '/OriginalProduct/ProductDetail.aspx?uid='+encodeURIComponent(strStutar[imgIndex].id)+'&zid='+strStutar[imgIndex].productId+'';
	//imgObj.filters[0].play();
	//divImgObj.filters[0].play();
	//用户名 产品规格名
	var userNameObj = getObj('spanUserName');
	var strA = '<a style="float:left; color:#999; text-decoration:underline;" href="/MyPhookIndex/Index.aspx?uid='+encodeURIComponent(strStutar[imgIndex].id)+'">'+strStutar[imgIndex].userName+'</a>';
	userNameObj.innerHTML = strA;
	var formatName = getObj('spanProductFormatName');
	var strHTML = '<span style="color:#999;">规格：</span>&nbsp;&nbsp;'
	formatName.innerHTML =  strHTML + strStutar[imgIndex].productFormat;
	
   imgIndex++;
	if (imgIndex > strStutar.length -1){
		imgIndex = 0;
   }
}

//获取对象
function getObj(id){
	var obj = document.getElementById(id);
	if (obj) return obj;
	return null;
}


function setCurrentHref(obj,index)
{
	var aList=obj.parentElement.getElementsByTagName('a');
	for(var i=0;i<aList.length;i++)
	{
		if(aList[i].id=="")
		{
		aList[i].className='';
		}
	}
	obj.className='aCurrent';
	for(var i=1;i<=3;i++)
	{
	  document.getElementById('productList'+i).style.display='none';
	}
	document.getElementById('productList'+index).style.display='block';
}

