// Modified by Kitae Park, 08/13/2009, [Love21 Page]
// Modified by SangMin Shim, 08/26/2009, [FabulousFinds]
// Modified by SangMin Shim, 09/07/2009, [Item Search]
// Modified by SangMin Shim, 09/07/2009, [Form Validation]
function goCategoryList(Category)
{
   // Category : Product Category(ex:f21_top,81_top,tbt_top...)
   if (Category.toLowerCase() == "topseller")
      location.href = "/Product/BestSeller.aspx";
   else if (Category.toLowerCase() == "mdpick")
      location.href = "/Product/MDPick.aspx";
   else if (Category.toLowerCase() == "newarrivals")
      location.href = "/Product/NewArrivals.aspx";
   else if (Category.toLowerCase() == "sale")
      location.href = "/Product/Sale.aspx";
   else if ((Category.toLowerCase() == "shopbytrend") || (Category.toLowerCase().indexOf("sbtrend") != -1))
      location.href = "/ShopbyTrend/Default.aspx";
   else if (Category.toLowerCase() == "shopbyoutfit")
      location.href = "/ShopbyOutfit/Default.aspx";
   // Added by SangMin Shim, 08/26/2009, [FabulousFinds]
   else if (Category.toLowerCase() == "fab_finds")
      location.href = "/Product/FabulousFinds.aspx";
   else if (Category.toLowerCase() == "promo_drama")
      location.href = "/Product/PromoDrama.aspx";
   else
   {
      if (Category.toLowerCase().indexOf("81") != -1)
         location.href = "/Heritage1981/Products.aspx?Category=" + Category;
      else if (Category.toLowerCase().indexOf("tbt") != -1)
         location.href = "/Twelve/Products.aspx?Category=" + Category;
      // Add by 08/11/2009, Kitae Park Love21
      else if (Category.toLowerCase().indexOf("love21") != -1)
         location.href = "/Love21/Products.aspx?Category=" + Category;
      else
         location.href = "/Forever21/Products.aspx?Category=" + Category;
   }
}
function goProductDetail(ProductId, Category)
{
   if (Category.toLowerCase().indexOf("81") != -1)
      location.href = "/Heritage1981/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId;
   else if (Category.toLowerCase().indexOf("tbt") != -1)
      location.href = "/Twelve/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId;
   else
      location.href = "/Forever21/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId;
}
function goProductInfo(ProductId, Category, RowNum)
{
   if (Category.toLowerCase().indexOf("81") != -1)
      location.href = "/Heritage1981/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum;
   else if (Category.toLowerCase().indexOf("tbt") != -1)
   {
      if ((Category.toLowerCase() == "tbt_whatsnew") || (Category.toLowerCase() == "tbt_sale"))
         location.href = "/Twelve/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId;
      else
         location.href = "/Twelve/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum;
   }
   // Added by Kitae Park, 08/13/2009, [Love21 Page]
   else if (Category.toLowerCase().indexOf("love21") != -1)
   {      
      location.href = "/Love21/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum;
   }
   else
      location.href = "/Forever21/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum;
}
// Added by SangMin Shim, 09/07/2009, [Item Search]
function goProductInfo(ProductId, Category, RowNum, ColorCode)
{
   if (Category.toLowerCase().indexOf("81") != -1)
      location.href = "/Heritage1981/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum + "&ColorCode=" + ColorCode;
   else if (Category.toLowerCase().indexOf("tbt") != -1)
   {
      if ((Category.toLowerCase() == "tbt_whatsnew") || (Category.toLowerCase() == "tbt_sale"))
         location.href = "/Twelve/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&ColorCode=" + ColorCode;
      else
         location.href = "/Twelve/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum + "&ColorCode=" + ColorCode;
   }
   // Added by Kitae Park, 08/13/2009, [Love21 Page]
   else if (Category.toLowerCase().indexOf("love21") != -1)
   {      
      location.href = "/Love21/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum + "&ColorCode=" + ColorCode;
   }
   else
      location.href = "/Forever21/ProductView.aspx?Category=" + Category + "&ProductId=" + ProductId + "&RowNum=" + RowNum + "&ColorCode=" + ColorCode;
}
function goSearch(SearchType, SearchResult)
{
    var SearchText, SearchOption;
    if(SearchType == "R")
    {
       SearchText = document.getElementById("clSearch2");
       SearchOption = document.getElementById("clSearchOption2").value;
       if(SearchText.value == "")
       {
           alert("°Ë»öÇÒ ´Ü¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
           SearchText.focus();
           return false;
       }
       location.href="http://www.forever21.co.kr/Product/Search.aspx?SearchType="+SearchType+"&SearchText="+SearchText.value+"&SearchOption="+SearchOption+"&SearchResult="+SearchResult;
    }
    else
    {
       
       SearchText = document.getElementById("clSearch");
       SearchOption = document.getElementById("clSearchOption").value;
       if(SearchText.value == "")
       {
           alert("°Ë»öÇÒ ´Ü¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
           SearchText.focus();
           return;
       }
       location.href="http://www.forever21.co.kr/Product/Search.aspx?SearchType="+SearchType+"&SearchText="+SearchText.value+"&SearchOption="+SearchOption;
    }
    return false;
}
function browserType()
{
   var appname = navigator.appName;
   var useragent = navigator.userAgent;
   var browsertype; //1:IE, 2:FF, 3:SF
   if(useragent.toLowerCase().indexOf("firefox") != -1)
      browsertype = "2";
   else if(useragent.toLowerCase().indexOf("safari") != -1)
      browsertype = "3";
   else
      browsertype = "1";
   return browsertype;
}
var discount = 20;
function openQuickView(ProductID, Categroy)
{
   document.getElementById("t").src="/Control/QuickView.aspx?ProductID="+ProductID+"&Category="+Categroy;
   document.getElementById("dQuickView").style.display = "block";
   document.getElementById("dQuickView").style.top = "30%";

   var sTop = document.body.scrollTop;
   var sLeft = document.documentElement.scrollLeft;

   if (sTop == 0)
      sTop = document.documentElement.scrollTop;
   tmpTop = sTop + ((document.documentElement.scrollHeight - 350) / 3);
   tmpLeft = sLeft + ((document.documentElement.scrollWidth - 660) / 2);
   document.getElementById("dQuickView").style.position = "absolute";
   document.getElementById("dQuickView").style.left = tmpLeft;
   document.getElementById("dQuickView").style.top = tmpTop
   document.getElementById("t").style.height=490;
   document.getElementById("t").style.width=650;
}
// Added by SangMin Shim, 09/07/2009, [Item Search]
function openQuickView(ProductID, Categroy, ColorCode)
{
   document.getElementById("t").src="/Control/QuickView.aspx?ProductID="+ProductID+"&Category="+Categroy+"&ColorCode="+ColorCode;
   document.getElementById("dQuickView").style.display = "block";
   document.getElementById("dQuickView").style.top = "30%";

   var sTop = document.body.scrollTop;
   var sLeft = document.documentElement.scrollLeft;

   if (sTop == 0)
      sTop = document.documentElement.scrollTop;
   tmpTop = sTop + ((document.documentElement.scrollHeight - 350) / 3);
   tmpLeft = sLeft + ((document.documentElement.scrollWidth - 660) / 2);
   document.getElementById("dQuickView").style.position = "absolute";
   document.getElementById("dQuickView").style.left = tmpLeft;
   document.getElementById("dQuickView").style.top = tmpTop
   document.getElementById("t").style.height=490;
   document.getElementById("t").style.width=650;
}
function closeQuickView()
{
   document.getElementById("t").src="/Control/Blank.aspx";
   document.getElementById("dQuickView").style.display = "none";
}
function fQuickView(id, v)
{
   var browsertype = browserType();
   if(browsertype == "1")
   {
      var sQuick = eval(document.getElementById(id));
      sQuick.style.visibility = v;
   }
}
function fFAQ(id, v)
{
   var sFAQ = eval(document.getElementById(id));
   sFAQ.style.visibility = v;
}
function fLoginPress(e)
{
}
function fZipCode()
{
   var X = ((document.body.clientWidth) / 2) - (417 / 2);
   var Y = ((document.body.clientHeight) / 2) - (500 / 2) + 50;
   config = "toolbar=no,directories=no,menubar=no,titlebar=no,status=no,scrollbars=yes,width=417,height=500,left=" + X + ",top=" + Y;
   window.open("/common/ZipCode.aspx", "ZipCode", config);
   return false;
}
function fTracking(trackingnumber)
{
   var X = ((document.body.clientWidth) / 2) - (600 / 2);
   var Y = ((document.body.clientHeight) / 2) - (250 / 2) + 50;
   config = "toolbar=no,directories=no,menubar=no,titlebar=no,status=no,scrollbars=yes,width=600,height=250,left=" + X + ",top=" + Y;
   window.open("http://www.hydex.net/ehydex/jsp/home/distribution/tracking/tracingNView.jsp?param1=338284&param2=" + trackingnumber, "¹è¼ÛÁ¶È¸", config);
}

function fnLogout()
{
   if( confirm("·Î±×¾Æ¿ôÇÏ½Ã°Ú½À´Ï±î?"))
      location.href="/Member/Logout.aspx";
}
function fnQnAView(HiddenID)
{
   var div = eval("document.all."+HiddenID);
   if(div.style.display == "block")
      div.style.display = "none";
   else
      div.style.display = "block";
}

function fnQnAViewAll(HiddenID, num, maxnum)
{
   for(i=1; i<= maxnum; i++)
   {
      var div = eval("document.all."+HiddenID+i);
      
      if(i == num)
      {
         if(div.style.display == "block")
            div.style.display = "none";
         else
            div.style.display = "block";
      }
      else
      {
         div.style.display = "none";
      }
   }

}

function fnGetElementById(HiddenID, num, maxnum)
{

   for(i=1; i<= maxnum; i++)
   {
      var div = document.getElementById(HiddenID+i);
      
      if(i == num)
      {
         if(div.style.display == "block")
            div.style.display = "none";
         else
            div.style.display = "block";
      }
      else
      {
         div.style.display = "none";
      }      
   }
}

function show(div)
{
   if( div.style.display == 'none' )

      div.style.display = 'block';

   else

      div.style.display = 'none'; 
}


// ·Ñ¿À¹ö ÀÚ¹Ù½ºÅ©¸³Æ®
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];
         }
}
// JScript ÆÄÀÏ
function go_pd(ProudctID,CatalogName)
{
    if(ProudctID == "9000000001"){
        location.href= "../eCard/ListeCardItem.aspx?variantid="+CatalogName;
    }else{
        location.href = "/Product/ProductView.aspx?ProductID="+ProudctID+"&Catalog=Forever21Kor&Category="+CatalogName;
    }
}

function go_pd1(ProudctID,CatalogName, RowNum)
{
    if(ProudctID == "9000000001"){
        location.href= "/eCard/ListeCardItem.aspx?variantid="+CatalogName;
    }else{
        location.href = "/Product/ProductView.aspx?ProductID="+ProudctID+"&Catalog=Forever21Kor&Category="+CatalogName+"&intRowNum="+RowNum;
    }
}

function go_pd2(ProudctID,CatalogName, RowNum)
{
    if(ProudctID == "9000000001"){
        location.href= "/eCard/ListeCardItem.aspx?variantid="+CatalogName;
    }else{
        location.href = "/Product/GiftProductView.aspx?ProductID="+ProudctID+"&Catalog=Forever21Kor&Category="+CatalogName+"&intRowNum="+RowNum;
    }
}
    function MoneyPay(pay){ 
       var idx=0; 
       arrRev = new Array(); 
       var lpay = ""; 
       pay = pay.toString(); 
       arr = pay.split(""); 
       for(i = arr.length; i > 0 ; i--){ 
           arrRev[idx] = arr[i-1]; 
           idx++; 
           if((idx ==3 || idx == 7 || idx == 11 || idx == 15 || idx == 19) && (i != 1)){ 
               arrRev[idx] = ","; 
               idx++; 
           } 
       } 
       for(i=arrRev.length; i>0; i--){ 
           lpay += arrRev[i-1]; 

       } 
       return lpay; 
    }
    
function fnPress(e,type)
{
    var SearchText, SearchOption, SearchMode, reCheck;
    var hdsMode, hdsText, hdsOption;
   
    if(e.keyCode ==13){
        if(type == "top"){
            SearchText = document.getElementById("ctl00_SearchText");
            SearchOption = document.getElementById("ctl00_SearchOption").value;
            SearchMode = "all";
            reCheck = false;
        }else{
           SearchText = document.forms[0].SearchText;
            SearchOption = document.forms[0].SearchOption.value;
            SearchMode = document.forms[0].SearchMode.value;
        }
        if(SearchText.value == ""){
            alert("°Ë»öÇÒ ´Ü¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
            SearchText.focus();
            return false;
        }
         location.href="../Product/Search.aspx?SearchText="+SearchText.value+"&SearchOption="+SearchOption+"&SearchMode="+SearchMode;
    
        
        return false;
    }
}

function CheckNumber(val)
{

    
    for(i=0;i<val.length;i++)
    {
        if(val.charCodeAt(i) <= 47 || val.charCodeAt(i) >= 58)
            return false;                    
    }
    
    return true;
}
function fn_findid()
{
   window.open("FindID.aspx","FindID","width=400,height=300");
   return false;
}
function fn_findpw()
{
   window.open("FindPW.aspx","FindID","width=400,height=300");
   return false;
}

function fn_PopSubscribe()
{
    window.open("../member/unsubscribe.aspx","","width=450,height=180");
}


var agent = navigator.userAgent;
var ie;
if(agent.toLowerCase().indexOf("firefox") != -1)
   ie = false;
else if(agent.toLowerCase().indexOf("safari") != -1)
   ie = false;
else
   ie = true;
   
function OnlyString(e)
{
     if(ie){
           if(event.keyCode >=48 && event.keyCode <=57) //0~9
                return false;
           else if(event.keyCode == 59 || event.keyCode == 47) // ;,/
                return false;
           else if(event.keyCode == 8 || event.keyCode == 45 || event.keyCode == 40 || event.keyCode == 41 || event.keyCode == 32)          //backspace,-,(,),sp
                return true;
           else
                return true;
     }else{
           if(e.which >=48 && e.which <=57) //0~9
                return false;
           else if(e.which == 59 || e.which == 47) // ;,/
                return false;
           else if(e.which == 8 || e.which == 45 || e.which == 40 || e.which == 41 || e.which == 32)       //backspace,-,(,),sp
                return true;
           else
                return true;
     }
}

function OnlyAlphabet(e)
{
     if(ie){
           if(event.keyCode >=65 && event.keyCode <=90) //A~Z
                return true;
           else if(event.keyCode >=97 && event.keyCode <=122) //a~z
                return true;
           else if(event.keyCode ==32 || event.keyCode == 8 || event.keyCode == 46) //space,backspace,del
                return true;
           else
                return false;
     }else{
           if(e.which >=65 && e.which <=90) //A~Z
                return true;
           else if(e.which >= 97 && e.which <= 122) //a~z
                return true;
           else if(e.which == 32 || event.which == 8 || event.which == 46)    //space,backspace,del
                return true;
           else
                return false;
     }
}

function OnlyStringNumber(e)
{
     if(ie){
           if(event.keyCode >=48 && event.keyCode <=57) //0~9
                return true;
           else if(event.keyCode == 8 || event.keyCode == 45 || event.keyCode == 40 || event.keyCode == 41 || event.keyCode == 32 ||  event.keyCode == 13)             //backspace,-,(,),sp,enter
                return true;
           else if(event.keyCode >=65 && event.keyCode <=90 || event.keyCode >=97 && event.keyCode <=122)  //a~z,A~Z
                return true;
           else
                return false;
     }else{
           if(e.which >=48 && e.which <=57) //0~9
                return true;
           else if(e.which == 8 || e.which == 45 || e.which == 40 || e.which == 41 || e.which == 32 ||  e.which == 13)       //backspace,-,(,),sp,enter
                return true;
           else if(e.which >=65 && e.which <=90 || e.which >=97 && e.which <=122)  //a~z,A~Z
                return true;
           else
                return false;
     }
}

function OnlyNumber(e)
{       
     if(ie){
           if(event.keyCode >=48 && event.keyCode <=57) //0~9
                return true;
           else if(event.keyCode == 8 || event.keyCode == 45 || event.keyCode == 40 || event.keyCode == 41 || event.keyCode == 32)          //backspace,-,(,),sp
                return true;
           else
                return false;
     }else{
           if(e.which >=48 && e.which <=57) //0~9
                return true;
           else if(e.which == 8 || e.which == 45 || e.which == 40 || e.which == 41 || e.which == 32)       //backspace,-,(,),sp
                return true;
           else
                return false;
     }
}