﻿// ...

function emailSub_dy()
{
    var pt = $F("pt");
    //alert(pt);
    if(pt == "" || isNaN(pt) || pt == "0")
    {
        $("mailSub_inform_1").innerHTML = "错误的机型！";
        return false;
    }
    var em1 = $F("em1");
    if(!isValidEmail(em1))
    {
        $("mailSub_inform_1").innerHTML = "错误的Email格式！";
        return false;
    }
    
    var myAjax = new Ajax.Request(
		"/action/SaveMailSubscibe.aspx",
		{
		method: "get",
		parameters: "action=1&pt=" + pt + "&em1=" + em1 + "&r=" + Math.random(),
		onComplete: emailSub_dy2
		});
}

function emailSub_dy2(oR)
{  
    var r = oR.responseText;
    if(r == "ok")
    {
        hiddenMailSubBox();
        msg2("订阅成功！", "");
    }
    else
    {
        $("mailSub_inform_1").innerHTML = r;
    }
}

function emailSub_td()
{
    var em0 = $F("em0");
    if(!isValidEmail(em0))
    {
        $("mailSub_inform_2").innerHTML = "错误的Email格式！";
        return false;
    }
    
    var myAjax = new Ajax.Request(
		"/action/SaveMailSubscibe.aspx",
		{
		method: "get",
		parameters: "action=0&em0=" + em0 + "&r=" + Math.random(),
		onComplete: emailSub_td2
		});
}

function emailSub_td2(oR)
{
    var r = oR.responseText;
    if(r == "ok")
    {
        hiddenMailSubBox();
        msg2("退订成功！", "");
        return false;
    }
    $("mailSub_inform_2").innerHTML = r;
}

function emailSubscibe()
{	
	var myAjax = new Ajax.Request(
		"/action/mailSubscibe.aspx",
		{
		method: "get",
		parameters: "r=" + Math.random(),
		onComplete: emailSubscibe2
		});

	return false;	
}

function emailSubscibe2(oR)
{
	overLay();
	var r = oR.responseText;
	
	chkAndCreate("div_emailSubscibe", "div");
	$("div_emailSubscibe").style.position = "absolute";
	$("div_emailSubscibe").style.zIndex = 9999;
	$("div_emailSubscibe").style.top = "150px";
	$("div_emailSubscibe").style.left = "50%";
	$("div_emailSubscibe").innerHTML = r;
}

function hiddenMailSubBox()
{
	overLay_close();
	$("mailSubBox").style.display = "none";
	return false;
}

function idx_res_title_selected(t)
{
	var i;
	for (i = 1; i <= 4; i ++)
	{
		document.getElementById("idx_res_title_" + i).className = "idx_res_title_unselected";
	}
	
	document.getElementById("idx_res_title_" + t).className = "idx_res_title_selected";
	
	var t2;
	switch(t)
	{
		case 1 : 
			t2 = 3;
			break;
		case 2 : 
			t2 = 5;
			break;
		case 3 : 
			t2 = 6;
			break;
		case 4 : 
			t2 = 4;
	}
	
	getPage("/action/ShowIndexParams.aspx", "resType=" + t2 + "&sorting=4", "idx_res_body");
	
	return false;	
}

function idx_sch_nocolor()
{
	$("idx_searchBox_class_0").className = "";
	$("idx_searchBox_class_1").className = "";
	$("idx_searchBox_class_2").className = "";
	$("idx_searchBox_class_9").className = "";
}

function idx_sch_clk(i)
{
	g_schType = i;
	$("resType").value = i;
	idx_sch_nocolor();
	$("idx_searchBox_class_" + i).className = "idx_searchBox_selected";
}

function idx_sch_on(i)
{
	if($("idx_searchBox_class_" + i).className != "idx_searchBox_selected")
	{
		$("idx_searchBox_class_" + i).className = "idx_searchBox_mouseon";
	}
}

function idx_sch_out(i)
{
	if($("idx_searchBox_class_" + i).className != "idx_searchBox_selected")
	{
		$("idx_searchBox_class_" + i).className = "";
	}
}
function selectPhoneType()
{
	var s1 = $("slcTM");
	var v = s1.options[s1.selectedIndex].value;
	
	if(v != 0)
	{
		var u;
		u = "/shop/useforall.aspx";
		var p = "action=showphonetype&trademark=" + v;
		var myAjax = new Ajax.Request(
			u,
			{
			method: 'get',
			parameters: p,
			onComplete: selectPhoneType2
			});
	}
	else
	{
		var s2 = $("slcPT");
		var i;
		var l = s2.options.length;
		//alert(l);
		for(i = 0; i < l; i ++)
		{
			s2.options.remove(i);
		}
		s2.options.add(new Option("所有机型","0"));
	}
	
	return false;
}

var g_selectPhoneType = 0;
function selectPhoneType2(originalRequest)
{
	var rsp = originalRequest.responseText;
	var a = rsp.split(",");
	//alert(rsp);
	
	var s2 = $("slcPT");
	var i;
	var l = s2.options.length;
	//alert(l);
	while(s2.options.length > 0)
	{
		s2.options.remove(0);
	}
	s2.options.add(new Option("所有机型","0"));
	
	var j = a.length;
	for(i = 0; i < j; i += 2)
	{
		s2.options.add(new Option(a[i + 1], a[i]));
	}
	
	if(g_selectPhoneType == 1)
	{
		var phid = getQuery("phid");
		var s2 = $("slcPT");
		
		var i;
		var l = s2.options.length;
		for(i = 0; i < l; i ++)
		{
			if(phid == s2.options[i].value)
			{
				s2.options[i].selected = true;
			}
		}
	}
	
	return false;
}

function idx_info() {
	$("idx_info_body").innerHTML = $("idx_info_splifeNews").innerHTML;
	var ob = $("idx_info");
	var i;
	for(i = 1; i < 4; i ++) {
		if($("idx_info_title_" + i)) {
			$("idx_info_title_" + i).onclick = function() {
				var i;
				for(i = 1; i < 4; i ++) {
					if($("idx_info_title_" + i)) {
						$("idx_info_title_" + i).className = "unselected";
					}
					this.className = "selected";
				}
				//alert(this.id);
				var tid = this.id;
				if(!tid || tid.length < 2) return false;
				tid2 = tid.substring(tid.length - 1, tid.length);
				switch(tid2) {
					case "1" : $("idx_info_body").innerHTML = $("idx_info_zd").innerHTML;
								break;
					case "2" : $("idx_info_body").innerHTML = $("idx_info_comment").innerHTML;
								break;
					case "3" : $("idx_info_body").innerHTML = $("idx_info_splifeNews").innerHTML;
								break;
				}
			}
		}
	}
}

function idx_news_scroll3() {
	var ob = $("idx_news");
	var ob2 = ob.getElementsByTagName("ul")[0];
	var oDiv = $("idx_news2");
	try {
	  slideLine(oDiv, 3000, 30, 40);
	} catch (e) {}
}

function slideLine(ul, delay, speed, lh) {
	var slideBox = (typeof ul == "string")?document.getElementById(ul):ul;
	var delay = delay||2000, speed=speed||30, lh = lh||20;
	var tid = null, pause = false;
	var start = function () {
		tid = setInterval(slide, speed);
	}
	var slide = function () {
		if (pause) return;
		var i;
		slideBox.scrollTop += 1;	
		if (slideBox.scrollTop % lh == 0) {
			clearInterval(tid);
			for (i = 0; i < 4; i ++) {
				slideBox.appendChild(slideBox.getElementsByTagName("li")[0]);
			}
			setTimeout(start, delay);
			slideBox.scrollTop = 0;
		}
	}
	slideBox.onmouseover = function () {pause = true;}
	slideBox.onmouseout = function () {pause = false;}
	setTimeout(start, delay);
}


addLoadEvent(idx_info);
addLoadEvent(idx_news_scroll3);