var crossFadeDuration = 3
var placeholderdelay = 5000
var waitdelay  = 500
var Pic = new Array()
var urlLink = new Array()

// Create Product Arrays
urlLink = ['11072', '11166', '11019', '11036', '11177', '11065', '11170', '11171', '11070', '11078', '11160', '11042', '11019', '11056', '11161', '11211', '11175', '11127', '11431', '11045', '11126', '11048', '11386', '11190', '11029', '11024']
Pic = 	  ['-44317-thumb-a.jpg', '-44407-thumb-d.jpg', '-44089-thumb-b.jpg', '-44238-thumb-a.jpg', '-44418-thumb-d.jpg', '-44311-thumb-b.jpg', '-44411-thumb-a.jpg', '-44412-thumb-d.jpg', '-44315-thumb-a.jpg', '-44322-thumb-d.jpg', '-44401-thumb-a.jpg', '-44300-thumb-a.jpg', '-44289-thumb-a.jpg', '-44073-thumb-a.jpg', '-44402-thumb-a.jpg', '-44449-thumb-a.jpg', '-44416-thumb-a.jpg', '-44369-thumb-a.jpg', '-44660-thumb-a.jpg', '-44109-thumb-a.jpg', '-44368-thumb-a.jpg', '-44303-thumb-a.jpg', '-44616-thumb-a.jpg', '-44148-thumb-a.jpg','-44111-thumb-a.jpg', '-44072-thumb-a.jpg']

function additional()
{
   return false;
}

function tracking(pageName, catalogName)
{
	return true;
//    if (__IT && __IT.page)
//        __IT.page(pageName, catalogName);
//    if (urchinTracker && pageName)
//        urchinTracker("/" + catalogName + "/" + pageName);
//    else if (urchinTracker)
//        urchinTracker("/" + catalogName);
}

function Init()
{
//    var aryImages = ["Jason-Kennedy-wb.jpg", "Roland-Smith-c.jpg", "11072-44317-thumb-a.jpg", "Andre-St-Pierre-b.jpg", "Craig-Light-a.jpg", "Greg-Liskey-a.jpg", "Lynn-Sicade-d.jpg", "Kevin-Richards-c.jpg", "11009-44282-thumb-a.jpg", "11038-44298-thumb-a.jpg", "11113-44355-thumb-a.jpg", "Chris-Brion-d.jpg", "John-Bzdel2-wd.jpg", "11081-44325-thumb-b.jpg", "11217-44454-thumb-b.jpg"];
	var aryImages = ["44300", "44289", "44073", "44402", "44449", "44416", "44369", "44660", "44109", "44368", "44303", "44616", "44148", "44111", "44072"];
//    var aryURLs   = ["11223-44460", "11004-44280", "11229-44467", "11016-44286", "11001-44277", "11078-44322", "11073-44318", "11081-44325", "11036-44238", "11072-44317", "11124-44366", "11183-44424", "11188-44429", "11017-44287", "11013-44283"];
//	var aryURLs   = ["11223", "11004", "11072", "11016", "11001", "11078", "11073", "11081", "11009", "11038", "11113", "11183", "11188", "11081", "11217"];
	var aryURLs   = ["11042", "11019", "11056", "11161", "11211", "11175", "11127", "11431", "11045", "11126", "11048", "11386", "11190", "11029", "11024"];
	var aryLink = ["/catalogviewer.html?category=engagement", "/catalogviewer.html?category=solitaires", "/catalogviewer.html?category=threestone", "/catalogviewer.html?category=engagement-invisible", "/catalogviewer.html?category=engagement-multiple"]
    
    function MenuAppend(aryAction)
    {
	var aryRet = new Array();
	var i;
	for(i = 0; i < aryAction.length; i++)
//	    aryRet[i] = g_strAffiliateURL + "catalogviewer.html?category=" + aryAction[i];
	    aryRet[i] = "catalogviewer.html?category=" + aryAction[i];
	return aryRet;
    }

	if (GetElement("menulink1"))
	{
		GetElement("menulink1").href	= aryLink[0];
		GetElement("menulink1").id		= "exclude";
		GetElement("menulink2").href	= aryLink[1];
		GetElement("menulink2").id		= "exclude";
		GetElement("menulink3").href	= aryLink[2];
		GetElement("menulink3").id		= "exclude";
		GetElement("menulink4").href	= aryLink[3];
		GetElement("menulink4").id		= "exclude";
		GetElement("menulink5").href	= aryLink[4];
		GetElement("menulink5").id		= "exclude";
	}

//    tracking(DOCUMENTNAME, DOCUMENTGROUP);

    anchorIterate();
	runSlideShow();
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function to_currency(val,currency)
{
    val = "" + Math.round(100 * val);
    var is_negative=(val < 0) ? true : false;
    if(is_negative)
	val=val.substring(1);
    while (val.length <= 2)
	val= "0" + val;
    var dec_point = val.length - 2;
    var first_part = val.substring(0,dec_point);
    var second_part = val.substring(dec_point);
    var result = first_part + "." + second_part;
    var sign = is_negative ? "-" : "";
    if(!currency)
	currency="";
    if(result == 0.00)
	result = 'Call';
    else
	result = sign + currency + result;
    return result;
}

function popup(imageName)
{
    newWindow = window.open('','newWindow','width=800,height=600,left=0,top=0,resizable=1,scrollbars=1');
    newWindow.document.open();
    newWindow.location.href = imageName;
}

function priceUpdate()
{
    var pricingOrderForm = document.forms[1];
    
    var firstMetalType  = pricingOrderForm.elements[0].options[pricingOrderForm.elements[0].selectedIndex].value;
    var secondMetalType = pricingOrderForm.elements[1].options[pricingOrderForm.elements[1].selectedIndex].value;
    var ringSizeValue   = pricingOrderForm.elements[2].options[pricingOrderForm.elements[2].selectedIndex].value;
    pricingOrderForm.elements[5].value = pricingOrderForm.elements[0].options[pricingOrderForm.elements[0].selectedIndex].text;
    pricingOrderForm.elements[6].value = pricingOrderForm.elements[1].options[pricingOrderForm.elements[1].selectedIndex].text;
    pricingOrderForm.elements[7].value = pricingOrderForm.elements[2].options[pricingOrderForm.elements[2].selectedIndex].text;
    
    var rawCurrentPrice = priceArrayVal[firstMetalType][secondMetalType][ringSizeValue];
    
    pricingOrderForm.elements[3].value = to_currency((rawCurrentPrice * 2.5),"$");
    pricingOrderForm.elements[4].value = to_currency(rawCurrentPrice,"$");
    
    pricingOrderForm.item1.value = pricingOrderForm.skuCode.value + "\|" + pricingOrderForm.itemName.value + "\|" + to_currency(rawCurrentPrice,"");

    pageTracker._linkByPost()(pricingOrderForm);

}

function anchorIterate()
{
    for (var i = 0; i < document.links.length; i++)
    {
        if (document.location.hostname != document.links[i].hostname && document.links[i].href.indexOf('javascript:') != 0 && document.links[i].id != "exclude" && document.links[i].className != "wishlist_com_wl_lnk_prev_wish")
        {
            document.links[i].href = "javascript:pageTracker._link('" + document.links[i].href + "');";
        }
    }
}

function addCookieToCart(thisPage)
{
    var formLength = document.forms[1].elements.length;
    var a='-', b='-', c='-', z='-', v='-', k;
    var dc=_ubd.cookie;	
    if (dc)
    {
        a=_uGC(dc,'__utma='+_udh,';');
        b=_uGC(dc,'__utmb='+_udh,';');
        c=_uGC(dc,'__utmc='+_udh,';');
        z=_uGC(dc,'__utmz='+_udh,';');
        v=_uGC(dc,'__utmv='+_udh,';');
        thisPage += '?__utma=' + escape(a) + '&__utmb=' + escape(b) + '&__utmc=' + escape(c) + '&__utmz=' + escape(z) + '&__utmv=' + escape(v);
    }
    for(var i = 0; i < formLength; i++)
        if (document.forms[1].elements[i].name == 'option2|Link')
            document.forms[1].elements[i].value = "<a href='http://www.uniteddiamonds.com/classic_pages/" + thisPage + "' target='New'>United Diamonds</a>";
}

var t
var LinkValue = null;
var j = 0
var selc1 = 11;
var selc2 = 2;
var selc3 = 13;
var selc4 = 14;
var p = Pic.length
var preLoad = new Array()
for (z = 0; z < p; z++){
    preLoad[z] = new Image()
    preLoad[z].src = "/thumb/" + urlLink[z] + Pic[z]
	}

function SetImage(oUrl)
{
LinkValue = "/catalogviewer.html?product=" + urlLink[j];
oUrl.href = "javascript:pageTracker._link('" + LinkValue + "');"
}

function runSlideShow()
{
	    j = Math.round(Math.random() * 25);
    while(j == selc1 || j == selc2 || j == selc3 || j == selc4)
	    j = Math.round(Math.random() * 25);

    if (document.all){
      document.images.img1.style.filter='blendTrans(duration=2)'
      document.images.img1.style.filter='blendTrans(duration=crossFadeDuration)'
      document.images.img1.filters.blendTrans.Apply()      
    }
    document.images.img1.src = preLoad[j].src
    SetImage(GetElement("link1"));

    if (document.all){
      document.images.img1.filters.blendTrans.Play()
    }
    t = setTimeout('runSlideShow2()', waitdelay)
	selc1 = j;
}

function runSlideShow2()
{
	    j = Math.round(Math.random() * 25);
    while(j == selc1 || j == selc2 || j == selc3 || j == selc4)
	    j = Math.round(Math.random() * 25);

    if (document.all){
      document.images.img2.style.filter='blendTrans(duration=2)'
      document.images.img2.style.filter='blendTrans(duration=crossFadeDuration)'
      document.images.img2.filters.blendTrans.Apply()      
    }
    document.images.img2.src = preLoad[j].src
    SetImage(GetElement("link2"));
    if (document.all){
      document.images.img2.filters.blendTrans.Play()
    }
	t = setTimeout('runSlideShow3()', waitdelay)
	selc2 = j;
}

function runSlideShow3()
{
	    j = Math.round(Math.random() * 25);
    while(j == selc1 || j == selc2 || j == selc3 || j == selc4)
	    j = Math.round(Math.random() * 25);

    if (document.all){
      document.images.img3.style.filter='blendTrans(duration=2)'
      document.images.img3.style.filter='blendTrans(duration=crossFadeDuration)'
      document.images.img3.filters.blendTrans.Apply()      
    }
    document.images.img3.src = preLoad[j].src
    SetImage(GetElement("link3"));
    if (document.all){
      document.images.img3.filters.blendTrans.Play()
    }
    t = setTimeout('runSlideShow4()', waitdelay)
	selc3 = j;
}

function runSlideShow4()
{
	    j = Math.round(Math.random() * 25);
    while(j == selc1 || j == selc2 || j == selc3 || j == selc4)
	    j = Math.round(Math.random() * 25);

    if (document.all){
      document.images.img4.style.filter='blendTrans(duration=2)'
      document.images.img4.style.filter='blendTrans(duration=crossFadeDuration)'
      document.images.img4.filters.blendTrans.Apply()      
    }
    document.images.img4.src = preLoad[j].src
    SetImage(GetElement("link4"));
    if (document.all){
      document.images.img4.filters.blendTrans.Play()
    }
    t = setTimeout('runSlideShow()', placeholderdelay)
	selc4 = j;
	if (placeholderdelay == 5000){
		placeholderdelay = 2000;
		waitdelay  = 2000;
	}
}