﻿// JScript File
function recaltotal(qt,remoteadd,cartid,price,ExtPrice)
{
var TotExtPrice; 

flag="1";
var qty=qt.value;

TotExtPrice = qty * ExtPrice;

if(qty<=0)
{alert("Quantity can't be less then one.");
//qt.focus();
qt.value='1';
qty=1;
}
var total
//alert(cartid);
var result;
var response;
response=ShoppingCart_Default.UpdateQuantity(qty,cartid,remoteadd);
result=response.value;
var arr = result.split('|');

result=parseFloat(arr[0]).toFixed(2);
var gt=parseFloat(arr[1]).toFixed(2);


//eval(document.getElementById("tot" + cartid)).innerHTML='$'+result;
eval(document.getElementById("tot" + cartid)).innerHTML='$'+parseFloat(TotExtPrice).toFixed(2);
document.getElementById("lbl"+cartid).innerHTML="<strong>" + parseFloat(TotExtPrice).toFixed(2) + "</strong>";
//document.getElementById("divsubtotal").innerHTML='$'+gt;
document.getElementById("divMerchandise").innerHTML='$'+gt;
document.getElementById("divTotal").innerHTML='$'+gt;



}

//------------------------Wish List Quantity updation----------------------------

function recaltotalwishlist(qt,remoteadd,wishid,price,ExtPrice)
{
var TotExtPrice; 
//alert(qt + "," + remoteadd + "," + wishid + "," + price + "," + ExtPrice);
flag="1";
var qty=qt.value;

TotExtPrice = qty * ExtPrice;

if(qty<=0)
{alert("Quantity can't be less then one.");
//qt.focus();
qt.value='1';
qty=1;
}
var total
//alert(cartid);
var result;
var response;
response=WishList_Detail.UpdateQuantity(qty,wishid,remoteadd);
result=response.value;
var arr = result.split('|');

result=parseFloat(arr[0]).toFixed(2);
var gt=parseFloat(arr[1]).toFixed(2);

//alert(parseFloat(arr[0]).toFixed(2) + "," + parseFloat(arr[1]).toFixed(2));
//eval(document.getElementById("tot" + wishid)).innerHTML='$'+result;
eval(document.getElementById("tot" + wishid)).innerHTML='$'+parseFloat(TotExtPrice).toFixed(2);
document.getElementById("lbl"+wishid).innerHTML="<strong>" + parseFloat(TotExtPrice).toFixed(2) + "</strong>";
//document.getElementById("divsubtotal").innerHTML='$'+gt;
//document.getElementById("divMerchandise").innerHTML='$'+gt;
//document.getElementById("divTotal").innerHTML='$'+gt;



}

function OrderReview(remoteadd,SessionID)
{
    var result;
    var zip=document.getElementById("txtshippingzip").value;
    var Discountcode = document.getElementById("txtDiscountCode").value;
    var response=ShoppingCart_checkout.OrderReviewHtml(remoteadd,SessionID,zip,Discountcode);
    result=response.value;
    
    var output='';
    var disper=0;
    output=result.toString();
    disper=output.toString().substring(output.toString().indexOf('*')+1)
    output=output.toString().substring(0,output.toString().indexOf('*'))
    
    if (disper==100)
   {
       //document.getElementById("ctl00_ContentPlaceHolder3_divCreditCard").innerHTML='';
     document.getElementById("divCreditCard").style.display="none";
   }
   else
   {
   document.getElementById("divCreditCard").style.display="block";
   }
   
    if(result != null){document.getElementById("litTotalSummary").innerHTML = output.toString()}
    return false;
}

function setvalues(val,url)
{
    var val;
    
    //alert(val);
    //alert(url);
    var response = products_details.getvalus(val,url);
    var result = response.value;
    //alert(result);
    window.location.href=result;
   
}


function ShowTabDivNew(TdId)
 {
    //alert(document.getElementById(TdId));
    var TdId;      
   
    var response = products_details.SetTabNavigation(TdId);
    var result = response.value;
    
    var arrstr='';
    var msg="There are no rating data for this product.";
    
    if(TdId =="tdCustomerReviews")
    {
       msg = "There are currently no reviews for this product.";
    }
    
    if(TdId =="tdDescription")
    {
       msg = "There are no description for this product.";
    }
    
    if(result != null)
    {
    arrstr = result.split("¤");
    if(arrstr[0] != null)
    {
        document.getElementById("ctl00_ctlSlipGrips_divTabNaviagtion").innerHTML="";
        document.getElementById("ctl00_ctlSlipGrips_divTabNaviagtion").innerHTML = arrstr[0].toString();
    }
    if(arrstr[1] != null)
    {
       document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML="";
       
       if(arrstr[1].toString() != "")   
       {
         document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = arrstr[1].toString();   
       }
       else
       {
         document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = msg.toString();
       }
    }
    if(arrstr[2] != null)
    {
        //alert(arrstr[2].toString());
        //document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML="";
        //document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML = arrstr[2].toString();
        //document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML = "Coming Soon";
    }
    }
    return false;
    //document.getElementById("tdCustomerReviews").innerHTML ="";
        
 }



function ShowTabDiv(TdId)
 {
    //alert(document.getElementById(TdId));
    var TdId;      
    var response = products_details.SetTabNavigation(TdId);
    var result = response.value;
    var arrstr='';
    var msg="There is no technology data for this product.";
    
    if(TdId =="tdCustomerReviews")
    {
       msg = "There are currently no reviews for this product.";
    }
    
    if(TdId =="tdDescription")
    {
       msg = "There are no description for this product.";
    }
    
    if(result != null)
    {
    arrstr = result.split("¤");
    if(arrstr[0] != null)
    {
        document.getElementById("ctl00_ctlSlipGrips_divTabNaviagtion").innerHTML="";
        document.getElementById("ctl00_ctlSlipGrips_divTabNaviagtion").innerHTML = arrstr[0].toString();
    }
    if(arrstr[1] != null)
    {
       document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML="";
       
       if(arrstr[1].toString() != "")   
       {
         document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = arrstr[1].toString();   
       }
       else
       {
         document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = msg.toString();
       }
    }
    if(arrstr[2] != null)
    {
        //alert(arrstr[2].toString());
        document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML="";
        document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML = arrstr[2].toString();
        //document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML = "Coming Soon";
    }
    }
    return false;
    //document.getElementById("tdCustomerReviews").innerHTML ="";
        
 }

function DisPreviewsOrderBy(OrderByVal,glflag)
{
    var OrderByVal;
    var Page;
    var glflag;
    var ProductId;
    ProductId = document.getElementById("ctl00_ctlSlipGrips_hiddenProductid").value;
    //alert(parseInt(ProductId));
    //alert(OrderByVal);
    document.getElementById("HidOrderBy").value = OrderByVal.toString();
    //alert("1"+document.getElementById("ctl00_ctlSlipGrips_HidPage").value);
    if(document.getElementById("ctl00_ctlSlipGrips_HidPage").value != null)
    {
       Page = parseInt(document.getElementById("ctl00_ctlSlipGrips_HidPage").value.toString()); 
    }
    else
    {
        Page = 1;
    }
    
    if (glflag == "D")
    {
        Page = 1;
    }
    
    
    
    var response = products_details.DisplyProductsReviews(Page,"P",OrderByVal);
    var result = response.value;
    //alert(result.toString());
    if (result != null)
    {
        document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = "";
        document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = result.toString();
    }
}

function DisPreviewsOrderByPaging(page)
{
    var OrderByVal;
    var page;
    
    //alert(parseInt(page));
    
    //alert(document.getElementById("HidOrderBy").value.toString());
    
    if(document.getElementById("HidOrderBy").value.toString() != "")
    {
        OrderByVal = document.getElementById("HidOrderBy").value.toString();
    }
    else
    {
        OrderByVal = "order by createdate desc";
    }
    
    //alert(OrderByVal);
    
    document.getElementById("ctl00_ctlSlipGrips_HidPage").value = parseInt(page);
    
    DisPreviewsOrderBy(OrderByVal,"I")
    /*
    alert(document.getElementById("ctl00_ctlSlipGrips_HidPage").value)
    
    var response = products_details.DisplyProductsReviewsPaging("P",OrderByVal);
    var result = response.value;
    //alert(result.toString());
    if (result != null)
    {
        document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = "";
        document.getElementById("ctl00_ctlSlipGrips_SpnshowContent").innerHTML = result.toString();
    }*/
}

function SetPageCounter(Id)
{
    var Id;
    //alert(Id.toString());
    var hidPrev = document.getElementById("ctl00_ctlSlipGrips_hidPrev");
    var hidNext = document.getElementById("ctl00_ctlSlipGrips_hidNext");
    var hidMax  = document.getElementById("ctl00_ctlSlipGrips_hidMax");
    var CurrPage='';
    //alert(hidPrev.value + ',' + hidNext.value + ',' + CurrPage);
    if(Id == "Prevanch")
    {
        if(hidPrev.value == "1")
        {
           hidPrev.value = parseInt(hidMax.value); 
           hidNext.value = parseInt("1");
           CurrPage = parseInt(hidPrev.value);
        }
        else
        {
           hidPrev.value = parseInt(hidPrev.value) - 1; 
           hidNext.value = parseInt(hidPrev.value) + 1;
           CurrPage = parseInt(hidPrev.value);
        }
    }
    else
    {
        if(hidNext.value == hidMax.value)
        {
           hidNext.value = "1";
           hidPrev.value = parseInt(hidMax.value); 
           CurrPage = parseInt(hidNext.value);
        }
        else
        {
           hidNext.value = parseInt(hidNext.value) + 1; 
           hidPrev.value = parseInt(hidNext.value) - 1;
           CurrPage = parseInt(hidNext.value);
        }
    }
    if(CurrPage =="")
    {
       CurrPage="0"; 
    }
    if(hidPrev.value == "0")
       {
        hidPrev.value = parseInt(hidMax.value); 
       }
    if(parseInt(hidNext.value) == parseInt(hidMax.value) + 1)
       {
        hidNext.value = parseInt("1");
       }
              
    //alert(hidPrev.value + ',' + hidNext.value + ',' + CurrPage);
    var response = products_details.DisplySlidesProducts(CurrPage);
    var result = response.value;
    var arrstr='';
    
    if(result != null)
    {
        arrstr = result.split("¤");
        if(arrstr[0] != null)
        {
            document.getElementById("ctl00_ctlSlipGrips_SpnPrevious").innerHTML="";
            document.getElementById("ctl00_ctlSlipGrips_SpnPrevious").innerHTML = arrstr[0].toString();
        }
        if(arrstr[1] != null)
        {
           document.getElementById("ctl00_ctlSlipGrips_SpnProductsSlides").innerHTML="";
           
           if(arrstr[1].toString() != "")   
           {
             document.getElementById("ctl00_ctlSlipGrips_SpnProductsSlides").innerHTML = arrstr[1].toString();   
           }
           else
           {
             document.getElementById("ctl00_ctlSlipGrips_SpnProductsSlides").innerHTML ="Coming Soon";
           }
        }
        if(arrstr[2] != null)
        {
            document.getElementById("ctl00_ctlSlipGrips_SpnNext").innerHTML="";
            document.getElementById("ctl00_ctlSlipGrips_SpnNext").innerHTML = arrstr[2].toString();
            //document.getElementById("ctl00_ctlSlipGrips_SpnRandomApparels").innerHTML = "Coming Soon";
        }
    }
    return false;
}