// JavaScript Document
// 异步调用
var xmlHttp = createXmlHttpRequest();


function createXmlHttpRequest() 
{ 
	var xmlhttp = null; 
	try 
	{ 
		xmlhttp = XMLHttpRequest(); 
	} 
	catch(e1) 
	{ 
		try 
		{ 
			xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); 
		} 
		catch(e2) 
		{ 
			try 
			{ 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			catch(e3) 
			{ 
				xmlhttp = false; 
				alert("创建失败!"); 
			} 
		} 
	}

	return xmlhttp; 
}
var thistype = "";
var page = 1;
var thistypeId = 0;
// 图片分类ID  表示图片所属哪种  2：具体类别
function change_key(img_type,typeId) 
{
	thistype = img_type;
	
	if(changeTheBgImg(typeId)){
		if(typeId){
				
			
		if(confirm('更换操作将晴空界面，你确定这样操作吗？')){
		this.thistypeId = typeId;
			switch(typeId){
			case 1:	
				//清除所有
						removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/woshibg.jpg)';
					
				break;
				case 2:
						removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/ktbg.jpg)';
					break;
				case 3:
				removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/shufangbg.jpg)';
					break;
				case 4:
					removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/qsnbg.jpg)';
				break;
				case 5:
					removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/ctbg.jpg)';
				break;
				case 6:
					removeAllele();
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/wsj.jpg)';
				break;
				default:
						//更换背景图
						$('idContainer').style.backgroundImage = 'url(images/diy/woshibg.jpg)';
					break;
			}
		}
		}
	}
	// 判断参数
if(img_type !== ''){
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) 
		{
			
			xmlHttp.open("get","searchdiy_img.asp?key1="+img_type+"&page="+page ,true); 
			xmlHttp.onreadystatechange = handSearchRequest; 
			xmlHttp.send(null); 
		}
	}else{
			alert('操作失败,请选择风格');
			return;
		}
}
//移除所有元素
function removeAllele(){
		var arrList = $A($('idContainer').descendants());
					arrList.each(function(doc){
										  		doc.remove();
										  }); 
	}
//接受编号，更改背景
function changeTheBgImg(typeId){
		if(thistypeId != typeId ){
				return true;
			}
			return false;
	}
// 接受返回值 处理请求
function handSearchRequest() 
{ 
	if (xmlHttp.readyState == 4)  // 完全返回
	{ 
		//var div = document.getElementById("search_suggest"); 
		//div.innerHTML = ""; 
		//var str = xmlHttp.responseText.split("|");
		//alert(xmlHttp.responseText);
		$('backImg').innerHTML = xmlHttp.responseText;
		/*for (var i=0; i<str.length; i ) 
		{ 
			var suggest = ’<div onmouseover="javascript：suggestOver(this);" ’; 
			suggest = ’onmouseout="javascript：suggestOut(this);" ’; 
			suggest = ’onclick="javascript：setSearch(this.innerHTML);" ’; 
			suggest = ’class="suggest_link">’ str[i] ’</div>’; 
			div.innerHTML = suggest; 
		} */
	} 
}
function fenye(page){
	this.page = page;
	//change_key(thistype);
		//thistype = img_type;
	// 判断参数
	if(thistype !== ''){
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) 
			{
				
				xmlHttp.open("get","searchdiy_img.asp?key1="+thistype+"&page="+page ,true); 
				xmlHttp.onreadystatechange = handSearchRequest; 
				xmlHttp.send(null); 
			}
		}else{
			alert('操作失败,请选择风格');
			return;
		}
}

function openDiv(pid){
	
		if(pid !== ''){
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) 
		{
			xmlHttp.open("get","showshangpList.asp?p="+pid,true); 
			xmlHttp.onreadystatechange = getResultset; 
			xmlHttp.send(null); 
		}
	}else{
		alert('目前没有配套商品');
			return;
		}
	}
function getResultset(){
	if (xmlHttp.readyState == 4)  // 完全返回
	{ 
		$('productDiv').style.left = "150px";
		$('productDiv').style.top = "370px";
		//alert( event.clientX);
		$('productDiv').innerHTML =  xmlHttp.responseText;
		
		$('productDiv').style.display = '';
		
	}
}
function closeDiv(){
		$('productDiv').style.display = 'none';
	}
function sendtochengshi(){
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) 
		{
			xmlHttp.open("get","chengshiOptions.asp",true); 
			xmlHttp.onreadystatechange = function(){
				if(xmlHttp.readyState == 4){
						$('chengshiList').innerHTML = xmlHttp.responseText;
					}
				}; 
			xmlHttp.send(null); 
		}
	}
//文字显示

