﻿var oldColor;
function SetNewColor(source) {
    oldColor = source.style.backgroundColor;
    source.style.backgroundColor = '#B0C4DE';
}
function SetOldColor(source) {
    source.style.backgroundColor = oldColor;
}
function sldMouseDown(e) {
    if (!e) { e = window.event }
    if (e.preventDefault) { e.preventDefault(); }
}
function getAbsLeft(o) {
    oLeft = o.offsetLeft
    while (o.offsetParent != null) {
        oParent = o.offsetParent
        oLeft += oParent.offsetLeft
        o = oParent
    }
    return oLeft;
}
function getAbsTop(o) {
    oTop = o.offsetTop
    while (o.offsetParent != null) {
        oParent = o.offsetParent
        oTop += oParent.offsetTop
        o = oParent
    }
    return oTop
}
function setLeft(o, oLeft) {
    o.style.left = oLeft + 'px';
}
function setTop(o, oTop) {
    o.style.top = oTop + "px";
}
function setPosition(o, oLeft, oTop) {
    setLeft(o, oLeft);
}
/* Pop Up Funtion */
function open_help(tid, nWidth, nHeight, v_Type) {
    try {
        if (isNaN(nWidth)) nWidth = 800;
        if (isNaN(nHeight)) nHeight = 500;
        var v_SKU = document.getElementById("hdn_SKU_Number").value;
        document.getElementById("frmWrap").innerHTML = "<iframe scrolling='auto' frameborder='0' id='main_ifrm' src='http:\\Platinum_Server:8001\Blank.html'></iframe>";
        var nTop = getAbsTop(top.document.getElementById("HolderContent"));
        var nLeft = getX(top.document.getElementById("HolderContent"));
        open_div("/PopUp_Help.aspx?Topic_Id=" + tid + "&Type=" + v_Type + "&SKU=" + v_SKU, nWidth, nHeight, nTop, nLeft);
        return;
    }catch (Error) {}
}
function open_div(osrc, owidth, oheight, nTop, nLeft) {
    try {
    top.document.getElementById('main_div').style.display = 'block';
    top.document.getElementById('main_div').style.width = owidth + "px";
    top.document.getElementById('main_div').style.height = oheight + "px";
    top.document.getElementById('main_ifrm').src = osrc;
    top.document.getElementById('main_ifrm').width = owidth + "px";
    top.document.getElementById('main_ifrm').height = oheight + "px";
    top.document.getElementById('main_div').style.visibility = 'visible';
    var v_Top = (nTop != undefined) ? nTop : top.document.body.scrollTop;
    top.document.getElementById('main_div').style.top = v_Top + "px";
    var TbLeft = getX(top.document.getElementById("HolderContent")) + top.document.getElementById('main_div').offsetWidth;
    var v_Left = (nLeft != undefined) ? nLeft : (TbLeft - top.document.getElementById('main_div').offsetWidth);
    top.document.getElementById('main_div').style.left = v_Left + "px";
    }catch (Error) {}
}
function open_Email_a_Friend(nWidth, nHeight) {
    try {
        if (isNaN(nWidth)) nWidth = 800;
        if (isNaN(nHeight)) nHeight = 500;
        var nTop = getAbsTop(top.document.getElementById("HolderContent"));
        var nLeft = getX(top.document.getElementById("HolderContent"));
        nLeft = nLeft + 200;
        top.document.getElementById('main_div_email').style.display = 'block';
        top.document.getElementById('main_div_email').style.width = nWidth + "px";
        top.document.getElementById('main_div_email').style.height = nHeight + "px";
        top.document.getElementById('main_div_email').style.visibility = 'visible';
        top.document.getElementById('dv_email_a_friend').width = nWidth + "px";
        top.document.getElementById('dv_email_a_friend').width = nHeight + "px";
        var v_Top = (nTop != undefined) ? nTop : top.document.body.scrollTop;
        top.document.getElementById('main_div_email').style.top = v_Top + "px";
        var TbLeft = getX(top.document.getElementById("HolderContent")) + top.document.getElementById('main_div_email').offsetWidth;
        var v_Left = (nLeft != undefined) ? nLeft : (TbLeft - top.document.getElementById('main_div_email').offsetWidth);
        top.document.getElementById('main_div_email').style.left = v_Left + "px";
    }catch (Error) {}
}
function fn_Add_To_Wish_List_Popup(nWidth, nHeight) {
try {
    if (isNaN(nWidth)) nWidth = 300;
    if (isNaN(nHeight)) nHeight = 230;
    var nTop = getAbsTop(top.document.getElementById("dv_Share_Product"));
    var nLeft = getX(top.document.getElementById("dv_Share_Product"));
    nLeft = nLeft - 310;
    nTop = nTop + 20;
    top.document.getElementById('tbl_wish_list').style.display = 'block';
    top.document.getElementById('tbl_wish_list').style.width = nWidth + "px";
    top.document.getElementById('tbl_wish_list').style.height = nHeight + "px";
    top.document.getElementById('tbl_wish_list').style.visibility = 'visible';
    var v_Top = (nTop != undefined) ? nTop : top.document.body.scrollTop;
    top.document.getElementById('tbl_wish_list').style.top = v_Top + "px";
    var TbLeft = getX(top.document.getElementById("dv_Share_Product")) + top.document.getElementById('tbl_wish_list').offsetWidth;
    var v_Left = (nLeft != undefined) ? nLeft : (TbLeft - top.document.getElementById('tbl_wish_list').offsetWidth);
    top.document.getElementById('tbl_wish_list').style.left = v_Left + "px";
    }catch (Error) {}
}
function close_win(v_type) {
    try {
    if (v_type == 0) {
        document.getElementById('main_div').style.visibility = 'hidden';
        document.getElementById('main_div_email').style.visibility = 'hidden';
    }
    else if (v_type == 1) {
        document.getElementById('main_div').style.visibility = 'hidden';
    }
    else if (v_type == 2) {
        document.getElementById('main_div_email').style.visibility = 'hidden';
    }
    else if (v_type == 3) {
        document.getElementById('tbl_wish_list').style.visibility = 'hidden';
    }
    }catch (Error) {}
}
function getX(obj) {
    return (obj.offsetParent == null ? obj.offsetLeft : obj.offsetLeft + getX(obj.offsetParent));
}
function getY(obj) {
    return (obj.offsetParent == null ? obj.offsetTop : obj.offsetTop + getY(obj.offsetParent));
}
function Validate_Email_Submit_Form() {
    try {
    //Sender Email Address
    if (document.getElementById("txt_your_email_address")) {
        if (document.getElementById("txt_your_email_address").value == "") {
            alert("Please enter your email address");
            document.getElementById("txt_your_email_address").focus();
            return false;
        }
        else if (document.getElementById("txt_your_email_address").value != "") {
            if (document.getElementById("txt_your_email_address").value.indexOf('@', 0) == -1 ||
			document.getElementById("txt_your_email_address").value.indexOf('.', 0) == -1) {
                alert("An email address must contain the '@' symbol and a '.'");
                document.getElementById("txt_your_email_address").select();
                document.getElementById("txt_your_email_address").focus();
                return false;
            }
        }
    }
    //Sender Name
    if (document.getElementById("txt_your_name")) {
        if (document.getElementById("txt_your_name").value == "") {
            alert("Please enter your name");
            document.getElementById("txt_your_name").focus();
            return false;
        }
    }

    //First Friend Email Address
    if (document.getElementById("txt_first_friend_email")) {
        if (document.getElementById("txt_first_friend_email").value != "") {
            if (document.getElementById("txt_first_friend_email").value.indexOf('@', 0) == -1 ||
			document.getElementById("txt_first_friend_email").value.indexOf('.', 0) == -1) {
                alert("An email address must contain the '@' symbol and a '.'");
                document.getElementById("txt_first_friend_email").select();
                document.getElementById("txt_first_friend_email").focus();
                return false;
            }
        }
    }
    //Second Friend Email Address
    if (document.getElementById("txt_second_friend_email")) {
        if (document.getElementById("txt_second_friend_email").value != "") {
            if (document.getElementById("txt_second_friend_email").value.indexOf('@', 0) == -1 ||
			document.getElementById("txt_second_friend_email").value.indexOf('.', 0) == -1) {
                alert("An email address must contain the '@' symbol and a '.'");
                document.getElementById("txt_second_friend_email").select();
                document.getElementById("txt_second_friend_email").focus();
                return false;
            }
        }
    }
    //Third Friend Email Address
    if (document.getElementById("txt_third_friend_email")) {
        if (document.getElementById("txt_third_friend_email").value != "") {
            if (document.getElementById("txt_third_friend_email").value.indexOf('@', 0) == -1 ||
			document.getElementById("txt_third_friend_email").value.indexOf('.', 0) == -1) {
                alert("An email address must contain the '@' symbol and a '.'");
                document.getElementById("txt_third_friend_email").select();
                document.getElementById("txt_third_friend_email").focus();
                return false;
            }
        }
    }
    //Fourth Friend Email Address
    if (document.getElementById("txt_fourth_friend_email")) {
        if (document.getElementById("txt_fourth_friend_email").value != "") {
            if (document.getElementById("txt_fourth_friend_email").value.indexOf('@', 0) == -1 ||
			document.getElementById("txt_fourth_friend_email").value.indexOf('.', 0) == -1) {
                alert("An email address must contain the '@' symbol and a '.'");
                document.getElementById("txt_fourth_friend_email").select();
                document.getElementById("txt_fourth_friend_email").focus();
                return false;
            }
        }
    }

    if (document.getElementById("txt_first_friend_email").value == "" && document.getElementById("txt_second_friend_email").value == "" && document.getElementById("txt_third_friend_email").value == "" && document.getElementById("txt_fourth_friend_email").value == "") {
        alert("At least enter your one friend email address.'");
        document.getElementById("txt_first_friend_email").focus();
        return false;
    }
    //Message
    if (document.getElementById("txt_email_a_friend_message")) {
        if (document.getElementById("txt_email_a_friend_message").value != "") {
            if (length(document.getElementById("txt_email_a_friend_message").value) > 500) {
                alert("Message text limit is 500 characters.");
                document.getElementById("txt_email_a_friend_message").select();
                document.getElementById("txt_email_a_friend_message").focus();
                return false;
            }
        }
    }

    return true;
   }catch (Error) {}
}
/* ######################### Product Image View Functions ######################### */
function fn_Product_Image_View(p_view) {
    try 
    {
    
        var v_view = p_view;
        var v_Main_Image = document.getElementById("img_Main");
        var v_Default_Image = document.getElementById("hdn_Default_View");
        //Main View Coding
        if (v_view == "0") {
            var v_main_image_view = document.getElementById("hdn_Main_View").value;
            if (v_main_image_view != "") {
                v_Main_Image.src = v_main_image_view;
                v_Default_Image.value = v_main_image_view;
            }
        }
        //View 1 Coding
        else if (v_view == "1") {
            var v_view1 = document.getElementById("hdn_View1").value;
            if (v_view1 != "") {
                v_Main_Image.src = v_view1;
                v_Default_Image.value = v_view1;
            }
        }
        //View 2 Coding
        else if (v_view == "2") {
            var v_view2 = document.getElementById("hdn_View2").value;
            if (v_view2 != "") {
                v_Main_Image.src = v_view2;
                v_Default_Image.value = v_view2;
            }
        }
        //View 3 Coding
        else if (v_view == "3") {
            var v_view3 = document.getElementById("hdn_View3").value;
            if (v_view3 != "") {
                v_Main_Image.src = v_view3;
                v_Default_Image.value = v_view3;
            }
        }
        //View 4 Coding
        else if (v_view == "4") {
            var v_view4 = document.getElementById("hdn_View4").value;
            if (v_view4 != "") {
                v_Main_Image.src = v_view4;
                v_Default_Image.value = v_view4;
            }
        }
        //View 5 Coding
        else if (v_view == "5") {
            var v_view5 = document.getElementById("hdn_View5").value;
            if (v_view5 != "") {
                v_Main_Image.src = v_view5;
                v_Default_Image.value = v_view5;
            }
       }
    }
    catch (Error) {}
}
function fn_Product_Image_View_MouseOver(p_view) {
    try 
    {
        var v_view = p_view;
        var v_Main_Image = document.getElementById("img_Main");
        //Main View Coding
        if (v_view == "0") {
            var v_main_image_view = document.getElementById("hdn_Main_View").value;
            if (v_main_image_view != "") {
                v_Main_Image.src = v_main_image_view;
            }
        }
        //View 1 Coding
        else if (v_view == "1") {
            var v_view1 = document.getElementById("hdn_View1").value;
            if (v_view1 != "") {
                v_Main_Image.src = v_view1;
            }
        }
        //View 2 Coding
        else if (v_view == "2") {
            var v_view2 = document.getElementById("hdn_View2").value;
            if (v_view2 != "") {
                v_Main_Image.src = v_view2;
            }
        }
        //View 3 Coding
        else if (v_view == "3") {
            var v_view3 = document.getElementById("hdn_View3").value;
            if (v_view3 != "") {
                v_Main_Image.src = v_view3;
            }
        }
        //View 4 Coding
        else if (v_view == "4") {
            var v_view4 = document.getElementById("hdn_View4").value;
            if (v_view4 != "") {
                v_Main_Image.src = v_view4;
            }
        }
        //View 5 Coding
        else if (v_view == "5") {
            var v_view5 = document.getElementById("hdn_View5").value;
            if (v_view5 != "") {
                v_Main_Image.src = v_view5;
            }
        }
    }
    catch (Error) {}
}
function fn_Product_Image_View_MouseOut(p_view) {
    try 
    {
        var v_view = p_view;
        var v_Main_Image = document.getElementById("img_Main");
        var v_Default_Image = document.getElementById("hdn_Default_View").value;
        v_Main_Image.src = v_Default_Image;
    }
    catch (Error) {}
}
function clearTextBox(textBoxID) {
    try {
    document.getElementById("hdn_Search_Term").value = document.getElementById(textBoxID).value;
    document.getElementById(textBoxID).value = "";
    }catch (Error) {}
}
function restoreTextBox(textBoxID) {
    try 
    {
        var v_Search_Terms = document.getElementById("hdn_Search_Term").value;
        if (v_Search_Terms != "") {
            if (document.getElementById(textBoxID).value == "") {
                document.getElementById(textBoxID).value = v_Search_Terms;
            }
        }
    }catch (Error) {}
}
function Test_CallBack() {
    alert("Hello 123");
}
function showPopup(p_width, p_height, v_type) {
    try 
    {
        var baseText;
        if (v_type == 1) {
            var popUp = document.getElementById("popupcontent_learn_search");
            popUp.style.top = "200px";
            popUp.style.left = "200px";
            popUp.style.width = p_width + "px";
            popUp.style.height = p_height + "px";
            baseText = "<br/><p class='fontmain'>You can adjust the left and right sliders <br/>to narrow your search by price range, <br/>carat weight, cut, color, and clarity. <br/>Click the <b>View results</b> button at any time <br/>to see the diamonds that match your search criteria.<br/>";
            popUp.innerHTML = baseText + "<br/><a href='javascript:hidePopup(1);'><img src='/Images/close.jpg' alt='Close' /></a>";
            popUp.style.visibility = "visible";
            fnLoad();
        }
        else if (v_type == 2) {
            var popUp = document.getElementById("popupcontent_conflict_free");
            popUp.style.top = "600px";
            popUp.style.left = "200px";
            popUp.style.width = p_width + "px";
            popUp.style.height = p_height + "px";
            baseText = "<br/><p class='fontmain'>At Diamond Manufacturers we deal directly with the DTC (The Diamond Trading Company), the world’s largest diamond miner. Thanks to our strong supply chain we are able to control the diamond quality from the mine to the end consumer. We only deal with our associated companies whom, like us, proudly adhere to and enforce the standards established by the Kimberley Process, an international system that polices the trade of diamonds to ensure they are from sources free of conflict. All Diamond Manufacturers diamonds are guaranteed to be conflict free. If one of our associates was ever found to be in violation of that process, we would immediately stop working with them. We will continue to support and promote any process that works towards maintaining the human rights and best working conditions in the diamond trade. Diamond Manufacturers is a global strong conflict-free supporter and has a zero-tolerance policy toward conflict diamonds.</br>";
            popUp.innerHTML = baseText + "<br/><a href='javascript:hidePopup(2);'><img src='/Images/close.jpg' alt='Close' /></a>";
            popUp.style.visibility = "visible";
        }
    }catch (Error) {}
}
function hidePopup(v_type) {
    try {
    if (v_type == 1) {
        var popUp = document.getElementById("popupcontent_learn_search");
        popUp.style.width = "0px";
        popUp.style.height = "0px";
        popUp.style.visibility = "hidden";
        fnLoad();
    }
    else if (v_type == 2) {
        var popUp = document.getElementById("popupcontent_conflict_free");
        popUp.style.width = "0px";
        popUp.style.height = "0px";
        popUp.style.visibility = "hidden";
    }
    }catch (Error) {}
}
/*Live Person Code */
function lpAddMonitorTag(src) {
    try {
    if (typeof (src) == 'undefined' || typeof (src) == 'object') {
        src = lpMTagConfig.lpMTagSrc ? lpMTagConfig.lpMTagSrc : '/hcp/html/mTag.js';
    }
    if (src.indexOf('http') != 0) {
        src = lpMTagConfig.lpProtocol + "://" + lpMTagConfig.lpServer + src + '?site=' + lpMTagConfig.lpNumber;
    }
    else {
        if (src.indexOf('site=') < 0) {
            if (src.indexOf('?') < 0) {
                src = src + '?';
            }
            else {
                src = src + '&amp;';
                src = src + 'site=' + lpMTagConfig.lpNumber;
            }
        }
    };
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('language', 'javascript');
    s.setAttribute('charset', 'iso-8859-1');
    s.setAttribute('src', src);
    document.getElementsByTagName('head').item(0).appendChild(s);
    }catch (Error) {}
} 