﻿function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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];}
}


//*** timepiece (begin) ************************************************************************************************************************
function variations_move_right(variation_total_count)
{
    variation_end++;           
    if (variation_end >= variation_total_count)         
        variation_end = variation_total_count - 1;           
    else            
        variation_begin++;           
                    
    reset_variations(variation_total_count);     
}

function variations_move_left(variation_total_count)
{       
    variation_begin--;
    if (variation_begin < 0)          
        variation_begin = 0;         
    else                       
        variation_end--;         
        
    reset_variations(variation_total_count);          
}

function reset_variations(variation_total_count)
{   
    //variations left arrow
    if (variation_begin > 0)       
        document.getElementById("img_variation_left").style.display = "inline";        
    else
        document.getElementById("img_variation_left").style.display = "none";    
        
    //variations
    for (i = 0; i < variation_begin; i++)
    {
        img = "img_variation_" + i;
        document.getElementById(img).style.display = "none";            
    }                
    for (i = variation_begin; i <= variation_end; i++)
    {
        img = "img_variation_" + i;
        document.getElementById(img).style.display = "inline";            
    }          
    for (i = (variation_end+1); i < variation_total_count; i++)
    {
        img = "img_variation_" + i;
        document.getElementById(img).style.display = "none";            
    }          
    
    //variations right arrow
    if (variation_end <= (variation_total_count - 2) )        
        document.getElementById("img_variation_right").style.display = "inline";
    else
        document.getElementById("img_variation_right").style.display = "none";
            
}

function mfgJump()
{
var mfglist = document.getElementById("selectMFG");
var index = mfglist.selectedIndex;
if(index > 0)
	window.location.href=mfglist.options[index].value;
}
function designerJump()
{
var designerlist = document.getElementById("selectDesigner");
var index = designerlist.selectedIndex;
if(index > 0)
	window.location.href=designerlist.options[index].value;
}
function SubCatJump(id)
{
var list = document.getElementById(id);
var index = list.selectedIndex;
if(index > 0)
	window.location.href=list.options[index].value;
}
//*** timepiece (end) **************************************************************************************************************************
 

//*** jewelry (begin) **************************************************************************************************************************
function priceJump()
 {
	var selectPrice = document.getElementById("selectPrice");
 	var index = selectPrice.selectedIndex;	 	                  
	if(index > 0)
		window.location = selectPrice.options[index].value;
 }
 function metalJump()
 {
	var selectMetal = document.getElementById("selectMetal");
 	var index = selectMetal.selectedIndex;	 	                  
	if(index > 0)
		window.location = selectMetal.options[index].value;
 }
 function stoneShapeJump()
 {
	var selectStoneShape = document.getElementById("selectStoneShape");
 	var index = selectStoneShape.selectedIndex;	 	                  
	if(index > 0)
		window.location = selectStoneShape.options[index].value;
 }
//*** jewelry (end)  ****************************************************************************************************************************
 
  
//*** My Account (begin)********************************************************************************************
function checkEmail(chkEmail,rbHTML,rbText)
{
    if (document.getElementById(chkEmail).checked)
    {
        document.getElementById(rbHTML).disabled = false;
        document.getElementById(rbText).disabled = false;
        if ((!document.getElementById(rbHTML).checked) && (!document.getElementById(rbText).checked))
            document.getElementById(rbHTML).checked = true;
    }
    else
    {
        document.getElementById(rbHTML).disabled = true;
        document.getElementById(rbText).disabled = true;
    }
}

function getDays(month, year) {
  // create array to hold number of days in each month
  var ar = new Array(12);
  ar[0] = 31; // January
  ar[1] = (year % 4 == 0) ? 29 : 28; // February
  ar[2] = 31; // March
  ar[3] = 30; // April
  ar[4] = 31; // May
  ar[5] = 30; // June
  ar[6] = 31; // July
  ar[7] = 31; // August
  ar[8] = 30; // September
  ar[9] = 31; // October
  ar[10] = 30; // November
  ar[11] = 31; // December

  // return number of days in the specified month (parameter)
  return ar[month-1];
}

function FillDayDropDown(controlId, month, year){
    //Clear drop down
    var obj = document.getElementById(controlId);
    for (var i=obj.options.length-1; i>=0; i--){
		obj.options[i] = null;
	}
	obj.selectedIndex = -1;	
	//Fill drop down
	for (var j=1; j<=getDays(month, year); j++)
    {
        obj.options[j-1] = new Option(j, j);

    }
}

function OpenWin(url, w, h){
    window.open(url,null,"height=" + h + ",width=" + w + ",status=yes,toolbar=no,menubar=no,location=no");
}
//*** My Account (end)********************************************************************************************


//****** Specials (begin)******************************************************************************************
function specialpriceJump()
 {
	var selectPrice = document.getElementById("selectPrice");
 	var index = selectPrice.selectedIndex;	 	                  
	if(index > 0)
		window.location = selectPrice.options[index].value;
 }
function specialbrandJump()
 {
	var selectBrand = document.getElementById("selectBrand");
 	var index = selectBrand.selectedIndex;	 	                  
	if(index > 0)
		window.location = selectBrand.options[index].value;
 }
//****** Specials (end)********************************************************************************************

function OpenWindow(url)
{
    var ParentwinW = 800, ParentwinH = 600;
    var ParentwinTop = 0, ParentwinLeft = 0;
    var winW = 800, winH = 600;
    var winTop = 0, winLeft = 0;
    
    if (parseInt(navigator.appVersion)>3) {
     if (navigator.appName=="Netscape") {
      ParentwinW = window.innerWidth;
      ParentwinH = window.innerHeight;
      ParentwinLeft = window.screenX;
      ParentwinTop = window.screenY;
      winW = ParentwinW * 70/100;
      winH = ParentwinH * 70/100;
      winTop = ParentwinTop + ((ParentwinH - winH) / 2) + 50;
      winLeft = ParentwinLeft + ((ParentwinW - winW) / 2) - 10;
     }
     if (navigator.appName.indexOf("Microsoft")!=-1) {
      ParentwinW = document.documentElement.clientWidth;
      ParentwinH = document.documentElement.clientHeight;
      ParentwinLeft = window.screenLeft;
      ParentwinTop = window.screenTop;
      winW = ParentwinW * 70/100;
      winH = ParentwinH * 70/100;
      winTop = ParentwinTop + ((ParentwinH - winH) / 2) - 100;
      winLeft = ParentwinLeft + ((ParentwinW - winW) / 2) - 10;
      
     }
    }
    window.open(url,'','left=' + winLeft + ', top=' + winTop + ',width=' + winW + ',height=' + winH + ',resizable=1, menubar=1, location=1,scrollbars=1');
}



//added by Q-mo
function expandVariation(divN, varCount)
{
 if(varCount>6)
 {
    var div = document.getElementById(divN);
    div.style.zIndex = "10";
    
    div.style.overflow= '';
    
   if(div.parentNode)
    div.style.height = 'auto';
   var spec = document.getElementById('divSpec');
    spec.style.display ='none';
  }  
}

function minimizeVariations(divN, varCount)
{  
    var div = document.getElementById(divN);
    if (varCount > 3)
        div.style.height = '140px';
    else
        div.style.height = '70px';
    div.style.zIndex = "0";
    div.style.overflow='hidden';

    var spec = document.getElementById('divSpec');
    spec.style.display ='block';
}