﻿function setiFrame(objValue)
{
	document.getElementById("HotTypeFlag").value = objValue;
	document.getElementById("HotTypeInfo").submit();
	return true;
}

function SpecOrderOnSubmit() {
	var obj = document.getElementById('soemail');
	
	if(trim(obj.value) == "" || trim(obj.value)=="E-mail address..."){
		alert("Please enter an email address before subscription.");
		AlertInfoAdd("Please enter an email address before subscription.",0,0);
		obj.focus();
		obj.select();
		return false;
	}else if (!isEmail(obj.value)) {
		alert("Please enter a valid email address.");
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}

function changeUrl(PageUrl, PageName, PageID)
{
	var PageSize = document.getElementById('PageSize').value;
	var Sortby	= document.getElementById('Sortby').value;
	location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/";
}

function changePageSize(PageSize, PageUrl, PageName, PageID, SpecialTypeC,OtherUrl)
{
	var Sortby	= document.getElementById('Sortby').value;
	if(OtherUrl){}else{OtherUrl = ''}
	if(SpecialTypeC != null && SpecialTypeC != "")
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/" + OtherUrl + SpecialTypeC;
	}
	else
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/" + OtherUrl;
	}
}

function changeSortby(Sortby, PageUrl, PageName, PageID,SpecialTypeC,OtherUrl)
{
	//var PageID = 1;
	var PageSize	= document.getElementById('PageSize').value;
	if(OtherUrl){}else{OtherUrl = ''}
	if(SpecialTypeC != null && SpecialTypeC != "")
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/" + OtherUrl + SpecialTypeC;
	}
	else
	{
		location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+PageID+"/" + OtherUrl;
	}
}

function goPage(id, PageUrl, PageName)
{
	var PageSize = document.getElementById('PageSize').value;
	var Sortby	= document.getElementById('Sortby').value;
	location.href = PageUrl + "/" + PageName + "-"+PageSize+Sortby+id+"/";
}
/*function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}*/
function searchSubmit(){
	var subkeyword = $("SubKeyword").value;
	var minp = $("MinPrice").value;
	var maxp = $("MaxPrice").value;
	var pn = /^(-|\+)?\d+(\.\d+)?$/;
	if(trim(minp) == "" && trim(maxp) != ""){
 		if(!pn.test(maxp)){						
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}else if(trim(maxp) < 0){												
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) == ""){
		if(!pn.test(minp)){
			$("MinPrice").value = "";
			$("MinPrice").focus();
			return false;
		}
	}else if(trim(minp) != "" && trim(maxp) != ""){
		if(!pn.test(minp)){						
			$("MinPrice").value = "";
			$("MinPrice").focus();
			if(!pn.test(maxp)){						
				$("MaxPrice").value = "";
				$("MinPrice").focus();
				return false;
			}
			return false;
		}else if(trim(minp) < 0){
			if(!pn.test(maxp)){						
				$("MaxPrice").value = "";
				$("MaxPrice").focus();
				return false;
			}else if(trim(maxp) < 0){												
				$("MaxPrice").value = "";
				$("MaxPrice").focus();
				return false;
			}
		}
		if(!pn.test(maxp)){						
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}else if(trim(maxp) < 0){												
			$("MaxPrice").value = "";
			$("MaxPrice").focus();
			return false;
		}
	}
	if(minp != "" || maxp != "" || trim(subkeyword) != "" || $("videos").checked || $("discount").checked){
		dinoSearchEngne.saveViewSubmitCookie(minp,maxp,subkeyword,$("videos").checked,$("discount").checked);
		return true;
	}else{
		return false;	
	}
}
function getSortName(sortId){
	switch(sortId){
		case 1: return 'Price';
		case 4: return 'Release Date';
		case 5: return 'Hot match';
		case 6: return 'Reviews';
		case 7: return 'Diggs';
		case 8: return 'Videos';
	}
}
function SaveCookieCheck(currCount,currSort,pageCount,currPageNum,searchType,proTypeID,productTypeName,ProductCount){
	if(searchSubmit()){
		SetCookie("searchType",1);
		SetCookie("searchProType","productTypeID="+proTypeID+"&productTypeName="+productTypeName);
		SetCookie("searchViewData","PageShowCount=" + currCount +"&PageSort="+ currSort +"&PageSortName=" + getSortName(currSort) +"&PageCount="+ pageCount +"&PageNum="+ currPageNum +"+&PageProductCount="+ ProductCount);
	}
}
function setViewSearchCookie(minp,maxp,subkeyword,videos,discount){
	var strDate = "";
	var priceRange = "";
	if(trim(minp)!="" && trim(maxp)!=""){
		if(minp < maxp)
	 		priceRange = minp +"-"+ maxp;
		else
			priceRange = maxp +"-"+ minp;
	}
	if(videos)
		videos = 1;
	else
		videos = 0;;
	if(discount)
		discount = 1;
	else
		discount = 0;
	strDate = "pricRange=" + priceRange
			+ "&PageView=" + $("ShowType").value
			+ "&IsDiscount=" + discount
			+ "&IsVideos=" + videos;
	SetCookie("searchViewData1",strDate);			
	SetCookie("keywords",trim(subkeyword));
	SetCookie("currUrl",document.location);
		
}
function setDiv(sourceDivID,targetDivID){
	document.getElementById(targetDivID).style.display="";
	document.getElementById(targetDivID).innerHTML = document.getElementById(sourceDivID).innerHTML;		
	document.getElementById(sourceDivID).innerHTML="";
}

function clickShopfor(img_path){
	var sf = document.getElementById("shop_for_hid");
	var sfl = document.getElementById("shopforlink");
	if(sf.style.display == "none"){
		sf.style.display = "";
		sfl.innerHTML='Less<img align="absmiddle" border="0" src="'+img_path+'listdown.gif"/>';
	}else{
		sf.style.display = "none";
		sfl.innerHTML='More<img align="absmiddle" border="0" src="'+img_path+'listup.gif"/>';
	}
}
function checkholidaycateimg(rowid){
	document.getElementById("holidaycate"+rowid).className="holiday_main_content_tt_normal";
	document.getElementById("holidaycate"+rowid).innerHTML=document.getElementById("catename"+rowid).value;
}

var checkimgid = 1;
var settimeoutobj = "";
var isStopCheck = 1;
var isIE = !-[1,];
var ieopacity=1;
function checkimgad(mid){
	for(var i=1;i<=3;i++){
		if(document.getElementById("holiday_image_mg"+i)){
			document.getElementById("holiday_image_mg"+i).style.display="none";
			if(isIE){
				document.getElementById("holiday_image_mg"+i).filters.alpha.opacity=0;
			}else{
				document.getElementById("holiday_image_mg"+i).style.opacity=0;
			}
			document.getElementById("gui_li"+i).className="sprite s_bt_show_3";
		}
	}
	document.getElementById("holiday_ad_this").value = mid;
	document.getElementById("holiday_image_mg"+mid).style.display="";
	document.getElementById("gui_li"+mid).className="sprite s_bt_show_4";
	//document.getElementById("holiday_nav_bottom").style.bottom=0;
	checkimgid = mid;
	updateOpacity();
}
function updateOpacity(){
	if(isIE){
		document.getElementById("holiday_image_mg"+checkimgid).filters.alpha.opacity = ieopacity;
		ieopacity = ieopacity+4;
		if(ieopacity<100){
			window.setTimeout(updateOpacity,100);
		}else{
			ieopacity = 1;
			return true;
		}
	}else{
		document.getElementById("holiday_image_mg"+checkimgid).style.opacity = parseFloat(parseFloat(document.getElementById("holiday_image_mg"+checkimgid).style.opacity)+0.05);
		if(document.getElementById("holiday_image_mg"+checkimgid).style.opacity <1){
			window.setTimeout(updateOpacity,100);
		}else{
			return true;	
		}
	}
}
function stopcheckimgnext(){
	if(settimeoutobj){
		window.clearTimeout(settimeoutobj);
	}
	isStopCheck = 1;
}
function startcheckimgnext(){
	checkimgnext();
}

function checkimgnext(){
	if(isStopCheck==0){
		var nextimgindex = parseInt(document.getElementById("holiday_ad_this").value)+1;
		if(document.getElementById("holiday_image_mg"+nextimgindex)){
			checkimgad(nextimgindex);
		}else{
			checkimgad(1);
		}
	}else{
		isStopCheck=0;	
	}
	settimeoutobj = window.setTimeout(checkimgnext,7000);
}
function checkimgad_move(mid){
	for(var i=1;i<=3;i++){
		if(document.getElementById("holiday_image_mg"+i)){
			document.getElementById("holiday_image_mg"+i).style.display="none";
			if(isIE){
				document.getElementById("holiday_image_mg"+i).filters.alpha.opacity = 0;
			}else{
				document.getElementById("holiday_image_mg"+i).style.opacity=0;
			}
			document.getElementById("gui_li"+i).className="sprite s_bt_show_3";
		}
	}
	document.getElementById("holiday_ad_this").value = mid;
	document.getElementById("holiday_image_mg"+mid).style.display="";
	if(isIE){
		document.getElementById("holiday_image_mg"+mid).filters.alpha.opacity = 100;
	}else{
		document.getElementById("holiday_image_mg"+mid).style.opacity=1;
	}
	document.getElementById("gui_li"+mid).className="sprite s_bt_show_4";
	//document.getElementById("holiday_nav_bottom").style.bottom=0;
	checkimgid = mid;
}

function onMouseOverGuideImg(node){
	//node.parentNode.childNodes[1].style.backgroundImage="url('../images/on_jt.gif')";
	//node.parentNode.childNodes[1].style.backgroundColor="transparent";
	//node.parentNode.childNodes[1].style.backgroundRepeat="no-repeat";
	//node.parentNode.childNodes[1].style.backgroundAttachment="scroll";
	//node.parentNode.childNodes[1].style.backgroundPosition="center top";
	//node.parentNode.childNodes[1].className="right1_Opinions_gt";
    for(var i=0;i<node.parentNode.childNodes.length;i++){
		if(node.parentNode.childNodes[i].className=="right1_Opinions_txt"){
			node.parentNode.childNodes[i].className="right1_Opinions_gt";
		}
	}
	//node.parentNode.children(1).className="right1_Opinions_gt";
}

function onMouseOutGuideImg(node){
	for(var i=0;i<node.parentNode.childNodes.length;i++){
		if(node.parentNode.childNodes[i].className=="right1_Opinions_gt"){
			node.parentNode.childNodes[i].className="right1_Opinions_txt";
		}
	}
	//node.parentElement.children(1).className="right1_Opinions_txt";
}

function GetAllElementNode(node,className,element){
	//如果节点是element
	if(node.nodeType==1){
		//节点的className不为空
		if(node.className!=""){
			//根据空格返回分组，一个节点可以引用多个css伪类
			var classNames=node.className.split(" ");
			//遍历所有的类名是否符合
			for(var h=0;h<classNames.length;h++){
				if(classNames[h]==className){
					element
				}	
			}
		}
	}
	//此节点含有子节点
	if(node.childNodes.length!=0){
		//递归调用所有的子节点
		for(var i=0;node.childNodes.length;i++){
			GetAllElementNode(node.childNodes[i],className,elements);	
		}
	}
}

function autolistBanner(){
	if(document.getElementById("div_listBanner")){
		var bannerobj = document.getElementById("div_listBanner");
		var bannermainobj = document.getElementById("div_listBanner_main");
		var tpwidth = bannermainobj.clientWidth;
		var mleft = parseInt((1680-tpwidth)/2);
		bannerobj.style.left = "-"+mleft+"px";
	}
}
