﻿
$(document).ready( 
    function(){
        $("#sltPrice").bind("change",AutoSerch);
        $("#sltCarat").bind("change",AutoSerch);
        $("#sltMaterial").bind("change",AutoSerch);
    }
)

function AutoSerch(){
    var param="price=";
    param+=$("#sltPrice").val();
    param+="&carat="+$("#sltCarat").val();
    param+="&material="+$("#sltMaterial").val();
    param+="&order="+$("#SortField").val();
    if($("#sltPrice").val()=="9")
    {
      document.location=" http://www.doido.com/program/guoqing/";
    }
	else if($("#sltCarat").val()=="12")
	{
      document.location=" http://www.doido.com/program/guoqing/";
    }
    else 
    {   
     document.location=p+".html?"+param;
    }
}

/*function AutoSerch(){
    var param="price=";
    param+=$("#sltPrice").val();
    param+="&carat="+$("#sltCarat").val();
    param+="&material="+$("#sltMaterial").val();
    param+="&order="+$("#SortField").val();    
    document.location=p+".html?"+param;
}*/

function DoSort(type){
    var order=$("#SortField").val();
    //order by price
    if(type==1){
        if(order=="1" || order=="2"){
            $("#SortField").val(order=="1"?"2":"1");
        }
        else
        {
           $("#SortField").val("1");   
        }
    }
    //order by carat
    if(type==2){
        if(order=="3" || order=="4"){
            $("#SortField").val(order=="3"?"4":"3");
        }
        else
        {
            $("#SortField").val("3");
        }
    }
    
    //order by hits
    if(type==3){
        if(order=="5" || order!="6"){
            $("#SortField").val(order=="5"?"6":"5");
        }
        else
        {
            $("#SortField").val("5");
        }
    }
        
    AutoSerch();
}

//Get QueryString By Js
function QueryString(fieldName)
{  
  var urlString = document.location.search;
  if(urlString != null)
  {
       var typeQu = fieldName+"=";
       var urlEnd = urlString.indexOf(typeQu);
       if(urlEnd != -1)
       {
            var paramsUrl = urlString.substring(urlEnd+typeQu.length);
            var isEnd =  paramsUrl.indexOf('&');
            if(isEnd != -1)
            {
                 return paramsUrl.substring(0, isEnd);
            }
            else
            {
                return paramsUrl;
            }
       }
       else 
       {
            return null;
       }
  }
 else
 {
    return null;
 }
 
 } 
 
 function AddFavorite(pid,type){
 
    // $.blockUI({message : '<div class="newtip">正在添加到收藏夹...</div>'});
     $.post('../Ajax/Product.aspx','action=add-favorite&pid='+pid+'&type='+type,ShowSuccess);
 }
 
 function ShowSuccess(data){
    if(data=="-1"){
        alert("你还不能收藏，请先登陆或注册!");
//        $.blockUI( {message : '<div class="newtip">你还不能收藏，请先登陆或注册!</div>' } ); 
//        setTimeout(function(){$.unblockUI()},1000);
    }
    else if(data=="1"){
        alert("已成功添加到收藏夹!");
//        $.blockUI( {message : '<div class="newtip">已成功添加到收藏夹!</div>' } ); 
//        setTimeout(function(){$.unblockUI()},200);
    }  
    else
    {
        alert("你已收藏此产品!");
//        $.blockUI( {message : '<div class="newtip">你已收藏此产品!</div>' } ); 
//        setTimeout(function(){$.unblockUI()},200);
    }
}
//delete CarList Product
function DeleteCarListProByProID(PreProID)
{
    location.href='/ShoppingFlow/CarList.aspx?acction=delete&PreID='+PreProID ;
}
// delete CarList CoverallProduct Or TwinsProduct
function  DeleteCoverallProduct(Guid)
{
    location.href='/ShoppingFlow/CarList.aspx?acction=Coveralldelete&GuID='+Guid ;
}
//Details Pages
function DetailsDeleteCarListProByProID(PreProID)
{
    location.href='/ShoppingFlow/ShoppingDetalisList.aspx?acction=delete&PreID='+PreProID;
}
//Details Pages
function  DetailsDeleteCoverallProduct(Guid)
{
    location.href='/ShoppingFlow/ShoppingDetalisList.aspx?acction=Coveralldelete&GuID='+Guid ;
}
