
//        Product Image Popup
function zoom1(productId, imageType ){
	var myform = eval('document.ProductForm');
	
	if (imageType != "") {
		var imagepopup              = window.open("", "imagepopup", "width=490,height=400,scrollbars=yes,resizable=yes,top=0,left=0");
		myform.target               = "imagepopup";
		window.name                 = "image";
		myform.productId.value      = productId;
		myform.productImage.value   = imageType;
		myform.actType.value        = "image";
		myform.action               = "/md/product/prodcategorylist.do";
		myform.submit();
		imagepopup.focus();
	}
}

//        Product Image Popup
function zoom(productId, imageType ){
	var myform = eval('document.ProductForm');
	if (imageType != "") {
		var imagepopup              = window.open("/products/model/enlarge/"+productId+".jhtml", "imagepopup", "width=650,height=650,scrollbars=no,resizable=yes,top=0,left=0");
		myform.target               = "imagepopup";
		window.name                 = "image";
		myform.productId.value      = productId;
	 	myform.productImage.value   = imageType;
		imagepopup.focus();
	}
}


// Select a Category
function goAttribute() {
  var myform = eval('document.ProductForm');
  
  if (myform.attribute01.value == '') {
    alert("Empty!");
  } else {
    myform.actType.value  = "list";
  	myform.action         = "/md/product/prodcategorylist.do";
    myform.submit();
  }
}

// Select a Model
function goModel(categoryName1,categoryName2,categoryName3) {
     var myform = eval('document.ProductForm');
   

  if (myform.selectModel.value == '') {
    alert("Empty!");
  } else {
    //goModelDetail(myform.selectModel.value);
    location.href="/products/model/detail/"+categoryName1+"_"+categoryName2+"_"+categoryName3+"_"+replaceStr(myform.selectModel.value)+".jhtml"
  }
  
  
  
}

//by kjj 
function replaceStr (strSource) {
   var str=strSource;
   var cnt = strSource.length;
   var totStr = "";
   for(i=0;i<cnt;i++) {
      if(str.substring(i,i+1) != "-" && str.substring(i,i+1) != " "  && str.substring(i,i+1) != "/" && str.substring(i,i+1) != "&") {
        totStr = totStr+str.substring(i,i+1);  
      } 
   }
   return totStr.toLowerCase();
}

// Select a Model
function goModel1() {
  var myform = eval('document.ProductForm');

  if (myform.selectModel.value == '') {
    alert("Empty!");
  } else {
    goModelDetail(myform.selectModel.value);
    
  }
}

// Select a Model Detail
function goModelCommon(categoryName1,categoryName2,categoryName3,modelId) {
  var myform = eval('document.ProductForm');
  myform.selectModel.value = modelId;

  if (modelId== '') {
    alert("Empty!");
  } else {
    goModelDetail(categoryName1,categoryName2,categoryName3);
  }
}


// Product Detail
function goModelDetail( categoryName1,categoryName2,categoryName3 ){
  var myform = eval('document.ProductForm');

  //myform.actType.value    = "detail";
	//myform.productId.value  = productId;
	//myform.action           = "/md/product/prodcategorylist.do";
	location.href="/products/model/detail/"+categoryName1+"_"+categoryName2+"_"+categoryName3+"_"+replaceStr(myform.selectModel.value)+".jhtml" //by kjj
  //myform.submit();
}

// Product Detail Parent page Move
function goModelDetailParent( productId ){

  opener.location.href="/products/model/detail/"+replaceStr(productId.toLowerCase())+".jhtml";
  window.close();
}

// Select a Category Value Init
function goInit(att01) {
  if (att01 != "") {
    var myform = eval('document.ProductForm');
    myform.attribute01.value = att01;
  }
}


// Image Rolling
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function isDefined(property) {
	return typeof property != 'undefined';
}

// Features, Spec Display
function showThis(tabId) {
	var ie4 = (document.all) ? true : false;
	var ns4 = (document.layers) ? true : false;
	var ns6 = (document.getElementById && !document.all) ? true : false;
	if (ie4) {
		if (isDefined(document.all.feature)) {
			featuresMenu = eval("document.all.features.style");
			featuresContents = eval("document.all.feature.style");
		} else {
			featuresMenu = null;
			featuresContents = null;
		}
		if (isDefined(document.all.spec1)) {
			specMenu = eval("document.all.specs.style");
			specContents = eval("document.all.spec1.style");
		} else {
			specMenu = null;
			specContents = null;
		}
		if (isDefined(document.all.accessari)) {
			accessoryMenu = eval("document.all.accessaries.style");
			accessoryContents = eval("document.all.accessari.style");
		} else {
			accessoryMenu = null;
			accessoryContents = null;
		}
	}
	else if(ns4){
		featuresMenu	= eval("document.layers('features')");
		specMenu 		= eval("document.layers('specs')");
		accessoryMenu = eval("document.layers('accessaries')");
	
		featuresContents 	= eval("document.layers('feature')");
		specContents 		= eval("document.layers('spec1')");
		accessoryContents = eval("document.layers('accessari')");
	}
	else if (ns6) {
		
		featuresMenu	= eval("document.getElementById('features').style");
		specMenu 		= eval("document.getElementById('specs').style");
		accessoryMenu = eval("document.getElementById('accessaries').style");
	
		featuresContents 	= eval("document.getElementById('feature').style");
		specContents 		= eval("document.getElementById('spec1').style");
		accessoryContents = eval("document.getElementById('accessari').style");
	}
	if ( tabId == "features" ){
		if (featuresContents != null) {
			featuresMenu.display = "";
			featuresContents.display = "";
		}
		if (specContents != null) {
			specMenu.display = "none";
			specContents.display = "none";
		}
		if (accessoryContents != null) {
			accessoryMenu.display = "none";
			accessoryContents.display = "none";
		}
	}else if ( tabId == "specs" ) {
	
		if (featuresContents != null) {
			featuresMenu.display = "none";
			featuresContents.display = "none";
		}
		if (specContents != null) {
			specMenu.display = "";
			specContents.display = "";
		}
		if (accessoryContents != null) {
			accessoryMenu.display = "none";
			accessoryContents.display = "none";
		}
	}else if ( tabId == "accessaries" ) {
		
		if (featuresContents != null) {
			featuresMenu.display = "none";
			featuresContents.display = "none";
		}
		if (specContents != null) {
			specMenu.display = "none";
			specContents.display = "none";
		}
		if (accessoryContents != null) {
			accessoryMenu.display = "";
			accessoryContents.display = "";
		}
	}
	return false
}

// Review Writer page Move
function goReview() {
  var myform = eval('document.ProductForm');

  myform.actType.value    = "review";
	myform.action           = "/md/product/prodcategorylist.do";
  myform.submit();
}

// Review List Page Move
function goReviewList(){
  var myform = eval('document.ProductForm');

  myform.actType.value    = "reviewlist";
	myform.action           = "/md/product/prodcategorylist.do";
  myform.submit();
}

// Review Register
function goRegister() {
  var myform = eval('document.ProductForm');

  if (myform.reviewSubject.value.length == 0) {
    alert("插入主题!");
    myform.reviewSubject.focus();
  } else if (myform.reviewContent.value.length == 0) {
    alert("插入内容!");
    myform.reviewContent.focus();
  } else {
    myform.actType.value = "reviewregister";
    myform.action        = "/md/product/prodcategorylist.do";
    myform.submit();
  }
}

/*
// Product Compare
function goCompare(){
   alert("goCompare begin ");
  var myform = eval('document.ProductForm');

  myform.actType.value    = "comp";
  alert("actType.value : "+ myform.actType.value);
  myform.action           = "/md/product/prodcategorylist.do";
  myform.submit();
}
*/


/*
// Product Compare Detail Popup
function goCompareDetail() {
  var myform = eval("document.ProductForm");

  var masterCatId       = new Array;
	var cnt               = 0;
  for (var inx=0; inx < myform.compare.length -1; inx++) {
    if (myform.compare[inx].checked == true) {
      masterCatId[cnt]  = myform.masterCatId[inx].value;
      cnt++;
    }
  }
  
	if (cnt < 2 || cnt > 3 ){
		alert("对不起，您必须选择2-3个型号!");
		return;
	}
	if ((cnt == 2 && (masterCatId[0] != masterCatId[1])) || (cnt == 3 && (masterCatId[0] != masterCatId[1] || masterCatId[1] != masterCatId[2]))) {
		alert("对不起，您必须选择同类型号");
		return;
  }
  
	var comppopup         = window.open("", "comparepopup", "scrollbars=yes,resizable=yes,width=669,height=570,top=0,left=0");
	myform.target         = "comparepopup";
	window.name           = "compare";
  myform.actType.value  = "compdetail";
	myform.action         = "/md/product/prodcategorylist.do";
	myform.submit();
	myform.target         = "_self";
	comppopup.focus();

}
*/

// Attach File Download
// 2007.10.04 Sung Hun Kwon
function filedown(filePath, fileName) {
//	location.href="/filedown.do?filepath="+filePath+"&filename="+fileName;
	location.href="/DownloadJsp.jsp?filePath="+filePath+"&fileName="+fileName;
}

// Order, Cart Move
function goOrder(category_id, product_id, cmd_action) {
  var myform = eval("document.ProductForm");
  
//  myform.cmd_action.value   = cmd_action;
//  myform.category_id.value  = category_id;
//  myform.product_id.value   = product_id;
//  myform.quantity.value     = myform.productCnt.value;
//
//  myform.method             = "post";
//  myform.action             = "/order/mycartaction.do";
//  myform.submit();

  if (myform.listPrice.value != "0" && myform.listPrice.value != "0.0") {
    location.href="/order/mycartaction.do?cmd_action=" + cmd_action + "&category_id=" + category_id + "&product_id=" + product_id + "&quantity=" + myform.productCnt.value;
  } else {
  	alert("这是非卖品!!!");
  }
}

// WishList
function goWishList(productId) {
  var myform = eval("document.ProductForm");
  
  if (myform.listPrice.value != "0" && myform.listPrice.value != "0.0") {
	location.href="/user/front/userwishlist.do?action=wishlistregister" + "&productId=" + productId;
  } else {
  	alert("这是非卖品!!!");
  }

}


// Paging
function callPage(currPage1) {
  var myform = eval("document.ProductForm");
    currPage=""+currPage1+"";
	var str = currPage.split(",");
	sUrl = str[0];
	page1 = str[1];
	var str1 = sUrl.split("_");
	if ( str1.length ==2 ) {
	    var goUrl = "/products/category/list/"+sUrl+"__"+page1+".jhtml";    //2 step
	} else if (str1.length ==3 ) {
	    var goUrl = "/products/category/list/"+sUrl+"_"+page1+".jhtml";     //3 step
	} else if (str1.length ==4 ) {
	    var goUrl = "/products/category/list/"+sUrl+page1+".jhtml";     //3 step
	}
	//alert(goUrl);
	location.href=goUrl;
}
//thumbnail 20080516 Yuri Kim
function changeImg(src) {

		var obj = MM_findObj('Image15', document);



		obj.src = src;

	}
