// bookmark.js
function bookmarksite(title, url){
    if (document.all)
        window.external.AddFavorite(url, title);
    else
        if (window.sidebar)
            window.sidebar.addPanel(title, url, "")
        else
            alert("Please press CTRL+D to bookmark this site");
}
// Eof bookmark.js

// Tracking.js
ovtacParamFound = 0;
query = window.location.search.substring(1);
parameters = query.split('&');
for(var i=0;i < parameters.length;i++){
paramPair = parameters[i].split('=');
lwParam = new String(paramPair[0].toLowerCase());
if((lwParam.substr(0,5) == 'ovcrn') || (lwParam.substr(0,5) == 'ovchn') || (lwParam.substr(0,2) == 'sr') || (lwParam.substr(0,10) == 'session_sr')){
     ovtacParamFound = 1;
 }
}
if(ovtacParamFound == 1){
       var az_p=location.protocol=='https:'?'https:':'http:';
    var az_r=Math.floor(Math.random()*999999);
    document.write ("<" + "script language='JavaScript' ");
    document.write ("type='text/javascript' src='"+az_p);
    document.write ("//s1.srtk.net/www/delivery/lp.php");
    document.write ("?trackerid=111&bannerid=51&source={derive}&loc=" + escape(window.location) + "&referer=" + escape(document.referrer) + "&r=" + az_r + "'" + "><" + "/script>");
                
     
}

var ysm_accountid  = "14MQ8SSAL0PPR71D7LA0RGF2BH0";
document.write("<SCR" + "IPT language='JavaScript' type='text/javascript' " 
+ "SRC=//" + "srv1.wa.marketingsolutions.yahoo.com" + "/script/ScriptServlet" + "?aid=" + ysm_accountid 
+ "></SCR" + "IPT>");
// Eof Tracking.js


// MyAccount globalScript.js
//**********************************************************
//**************** UTILITY FUNCTIONS ***********************
//**********************************************************
function isBlank(item) {
    item = String(item).toLowerCase();
    if(item == "undefined" || item == "" || item == "null") return true;
    else return false;
}
function getCurrentDomainName() {
    var url = String(location);
    var domainName = extractDomain(url);
    return domainName;
}
function extractDomain(url) {
    var url = url.replace("http://", "");
    var slashIndex = url.indexOf("/");
    if(slashIndex == -1) slashIndex = url.length;
    var url = url.substring(0, slashIndex);
    var urlSectionArray = url.split('.');
    var urlSectionArrayLength = urlSectionArray.length;
    var domainName = "";
    for(var i=urlSectionArrayLength - 2;i<urlSectionArrayLength; i++) {
        domainName += "." + urlSectionArray[i];
    }
    return domainName;
}
function pdGetCookie(cookieName) {
    var allCookies = document.cookie;
    var cookieStart = allCookies.indexOf(cookieName)
    if(cookieStart == -1) return "";
    cookieStart = cookieStart + cookieName.length + 1;
    var cookieEnd = allCookies.indexOf(";", cookieStart);
    if(cookieEnd == -1) cookieEnd = allCookies.length;
    var cookieValue = unescape(allCookies.substring(cookieStart, cookieEnd));
    return cookieValue;
}
function pdSetCookie(cookieName, cookieValue, cookieDomain, cookiePath, expirationDate) {
    if(isBlank(cookieDomain)) cookieDomain = getCurrentDomainName();
    if(isBlank(cookiePath)) cookiePath = "/";
    var cookieString = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";domain=" + cookieDomain + ";path=" + cookiePath;
    if(!isBlank(expirationDate)) {
        cookieString += ";expires=" + expirationDate.toGMTString();
    }
    document.cookie = cookieString;
    return true;
}
function popIt(width, height, scrollbars){ 
    if(!width) width = "640";
    if(!height) height = "480";
    if(!scrollbars) scrollbars = 1;
    var windowString = 'width=' + width + ',height=' + height + ',resizable=1,status=0,toolbar=no,scrollbars=' + scrollbars + ',scrolling=auto';
    var popItWindow = window.open('',"popIt", windowString);
    return false;
}
function encodeOptions(input) {
    input = String(input).replace(/&/g, "!!amp!!");
    input = String(input).replace(/=/g, "!!eq!!");
    return input;
}


//**********************************************************
//****** COPY BILLING FROM SHIPPING ON REGISTRY FORM *******
//**********************************************************
function copyBillingInfo(form) {
    if (form.copy.checked) {
        //**********************************************************
        //********* SET SHIPPING FIELDS AS VARIABLES ***************
        //**********************************************************
        var billFirstName = form.billFirstName.value;
        var billLastName = form.billLastName.value;
        var billAddress1 = form.billAddress1.value;
        var billAddress2 = form.billAddress2.value;
        var billCity = form.billCity.value;
        var billState = form.billState.value;
        var billZip = form.billZip.value;
        var billCountry = form.billCountry.value;
        var billPhone = form.billPhone.value;
                
        //***********************
        //*** OPTIONAL FIELDS ***
        //***********************
        try {var billCompany = form.billCompany.value;} catch(e) {}
        try {var billFax = form.billFax.value;} catch(e) {}
        try {var businessInfoBillingEmail = form.businessInfoBillingEmail.value;} catch(e) {}    //*** CB ONLY

        //**********************************************************
        //****** POPULATE SHIPPING FIELDS WITH BILLING DATA ********
        //**********************************************************
        form.shipFirstName.value = billFirstName;
        form.shipLastName.value = billLastName;
        form.shipAddress1.value = billAddress1;
        form.shipAddress2.value = billAddress2;
        form.shipCity.value = billCity;
        form.shipState.value = billState;
        form.shipZip.value = billZip;
        form.shipCountry.value = billCountry;
        form.shipPhone.value = billPhone;
        
        //***********************
        //*** OPTIONAL FIELDS ***
        //***********************
        try {form.shipCompany.value = billCompany;} catch(e) {}
        try {form.shipFax.value = billFax;} catch(e) {}
        try {form.businessInfoShippingEmail.value = businessInfoBillingEmail;} catch(e) {}    //*** CB ONLY

    } else {

        //**********************************************************
        //******************* RESET BILLING DATA *******************
        //**********************************************************
        try {form.shipCompany.value = "";} catch(e) {}
        form.shipFirstName.value = "";
        form.shipLastName.value = "";
        form.shipAddress1.value = "";
        form.shipAddress2.value = "";
        form.shipCity.value = "";
        form.shipState.value = "";       
        form.shipZip.value = "";
        form.shipCountry.value = "US";
        form.shipPhone.value = "";
        
        //***********************
        //*** OPTIONAL FIELDS ***
        //***********************
        try {form.shipCompany.value = "";} catch(e) {}
        try {form.shipFax.value = "";} catch(e) {}
        try {form.businessInfoShippingEmail.value = "";} catch(e) {}    //*** CB ONLY
    
    }
}

var pdMyAccountCopyBillingInfo = copyBillingInfo;    //*** FIX FOR REGISTRY OVERRIDING FUNCTION

/*    "getElementsByClassName"
    Developed by Robert Nyman, http://www.robertnyman.com
    Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/
var getElementsByClassName = function (className, tag, elm){
    if (document.getElementsByClassName) {
        getElementsByClassName = function (className, tag, elm) {
            elm = elm || document;
            var elements = elm.getElementsByClassName(className),
                nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
                returnElements = [],
                current;
            for(var i=0, il=elements.length; i<il; i+=1){
                current = elements[i];
                if(!nodeName || nodeName.test(current.nodeName)) {
                    returnElements.push(current);
                }
            }
            return returnElements;
        };
    }
    else if (document.evaluate) {
        getElementsByClassName = function (className, tag, elm) {
            tag = tag || "*";
            elm = elm || document;
            var classes = className.split(" "),
                classesToCheck = "",
                xhtmlNamespace = "http://www.w3.org/1999/xhtml",
                namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
                returnElements = [],
                elements,
                node;
            for(var j=0, jl=classes.length; j<jl; j+=1){
                classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
            }
            try    {
                elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
            }
            catch (e) {
                elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
            }
            while ((node = elements.iterateNext())) {
                returnElements.push(node);
            }
            return returnElements;
        };
    }
    else {
        getElementsByClassName = function (className, tag, elm) {
            tag = tag || "*";
            elm = elm || document;
            var classes = className.split(" "),
                classesToCheck = [],
                elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
                current,
                returnElements = [],
                match;
            for(var k=0, kl=classes.length; k<kl; k+=1){
                classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
            }
            for(var l=0, ll=elements.length; l<ll; l+=1){
                current = elements[l];
                match = false;
                for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
                    match = classesToCheck[m].test(current.className);
                    if (!match) {
                        break;
                    }
                }
                if (match) {
                    returnElements.push(current);
                }
            }
            return returnElements;
        };
    }
    return getElementsByClassName(className, tag, elm);
};
function pdHideFromWholesale() {
    var hideList = getElementsByClassName("pdHideFromWholesale");
    for(var i=0;i<hideList.length;i++) {
        hideList[i].className = "pdHide";    
    }
    return false;
}
function pdShowForWholesale() {
    var showList = getElementsByClassName("pdShowForWholesale");
    for(var i=0;i<showList.length;i++) {
        showList[i].className = "pdShow";
        showList[i].style.display = "block";
    }
    return false;
}
function pdPreventDefaultAction(evt) { 
    if (evt) { 
        if (typeof evt.preventDefault!= 'undefined') evt.preventDefault(); // W3C 
        else evt.returnValue = false; // IE 
    }
    return false;    //*** FALLBACK
}
function getUrl(method, url, data) {
    var cacheBuster = (new Date()).getTime();
    if(url.indexOf("?") > -1) url += "&cb=" + cacheBuster;
    else url += "?cb=" + cacheBuster;
    try {
        var xmlhttp = new XMLHttpRequest();
    } catch(e) {
        var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");    //*** IE 6
    }    
    xmlhttp.open(method, url, false);
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlhttp.send(data);
    var responseText = String(xmlhttp.responseText);
    xmlhttp = null;
    return responseText;
}
// Eof Myaccount globalScript.js

// Myaccount itemTabs.js
//********************************************
//******** ITEM DATA TAB FUNCTIONS ***********
//********************************************
//**** SET TO "graphic" FOR GRAPHIC TAB LINKS ******//
var pdItemTabVersion = "graphic";
function pdItemDataTabs(){
    var wrapper = document.getElementById("pdItemDataTabs");
    if(wrapper){
        tabs = wrapper.getElementsByTagName("DIV");
        for(i=0;i<tabs.length;i++){
            var s = tabs[i].id;
            var subs = s.substring(0,3)
            if(subs == "tab"){
                //***************************************************
                //******* SET INITIAL STYLE FOR DEFAULT TAB *********
                //***************************************************

                //******* TURN ON A DEFAULT TAB *********
                if(tabs[i].id == pdActiveItemDataTab){
                    tabs[i].className = "pdItemTabLinkOn";
                    //****** SET TABLE CELL STYLE FOR GRAPHIC TAB EFFECT ***********//
                    if(pdItemTabVersion == "graphic"){document.getElementById(tabs[i].id).parentNode.className = "pdItemLinkCellOn";}
                }else{
                    tabs[i].className = "pdItemTabLinkOff";
                    //****** SET TABLE CELL STYLE FOR GRAPHIC TAB EFFECT ***********//
                    if(pdItemTabVersion == "graphic"){document.getElementById(tabs[i].id).parentNode.className = "pdItemLinkCellOff";}
                }
                
                //******* TURN OFF TAB IF THERE IS NO CONTENT *********
                if(isBlank(document.getElementById(s + "Content").innerHTML)){
                    tabs[i].className = "pdItemTabDisable";
                }

                if(tabs[i].id != "tabBlank"){
                    //******* MOUSEOVER EVENT ********//
                    tabs[i].onmouseover=function(){
                        this.className = "pdItemTabLinkOn";
                        if(pdItemTabVersion == "graphic"){this.parentNode.className = "pdItemLinkCellOn";}
                    }
                    //******* MOUSEOUT EVENT ********//
                    tabs[i].onmouseout=function(){
                        if(pdActiveItemDataTab != this.id){
                            this.className = "pdItemTabLinkOff";
                            if(pdItemTabVersion == "graphic"){this.parentNode.className = "pdItemLinkCellOff";}
                        }
                    }
                    //******* ONCLICK EVENT ********//
                    tabs[i].onclick=function(){
                        pdActiveItemDataTab = this.id;
                        //** RESET CONTENT DIVS AND TAB IMGS
                        resetItemDataTabs();
                        //** SET ON CLASSNAME
                        if(this.className != "pdItemTabDisable"){
                            this.className = "pdItemTabLinkOn";
                            if(pdItemTabVersion == "graphic"){this.parentNode.className = "pdItemLinkCellOn";}
                        }
                        //** SET ON CONTENT
                        var elem = this.id;
                        document.getElementById(elem + "Content").style.display = "block";
                    }
                if(tabs[i].id != pdActiveItemDataTab){
                    document.getElementById(tabs[i].id + "Content").style.display = "none";
                }
                }
            }
        }
    }
}
function resetItemDataTabs(){
    var itemDataTabs = document.getElementById("pdItemDataTabs");
    var tabs = itemDataTabs.getElementsByTagName("DIV");
    for(i=0;i<tabs.length;i++){
        var s = tabs[i].id;
        var subs = s.substring(0,3)
        if(subs == "tab"){
            if(tabs[i].className != "pdItemTabDisable"){
                tabs[i].className = "pdItemTabLinkOff";
                if(pdItemTabVersion == "graphic"){document.getElementById(tabs[i].id).parentNode.className = "pdItemLinkCellOff";}
            }
            if(tabs[i].id != "tabBlank"){
                document.getElementById(s + "Content").style.display = "none";
            }
        }
    }
}
function isBlank(item) {
    item = String(item).toLowerCase();
    if(item == "undefined" || item == "" || item == "null") return true;
    else return false;
}

function openPopup()
{
    countStars = 5;
    var gpath="http://site.accessorygeeks.com/reviews/";
    var addr = gpath + "stars-popup.php?stars=" + countStars + "&theid=" + gid + "&thename=" + escape(gname);
    var popUpWin=0;
    if(popUpWin){
        if(!popUpWin.closed)
            popUpWin.close();
    }
    popUpWin = open(addr,'reviewwin','scrollbars=no,resizable=no,top=0,left=0,width=600,height=300');
    popUpWin.focus();
}
// Eof Myaccount itemTabs.js

// MyAccount reviewsClientScript.js
var prClientDomain = "http://site.accessorygeeks.com/pd_myAccount/";
var prClientName = "Accessory Geeks";
var prClientSkin = "accessorygeeks";
var prDebug = false;

/*******************************************/
/*********** UTITLITY FUNCTIONS ************/
/*******************************************/
function prIsBlank(val){
    if(val==null){return true;} 
    for(var i=0;i<val.length;i++) {
        if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
    }
    return true;
}
function prIsValidEmail(str) {
   return (str.indexOf(".")) && (str.indexOf("@") > 0);
}
function prGetRadioValue(radioset){
    var val;
    for (var i=0; i<radioset.length; i++){
        if (radioset[i].checked){
            val = radioset[i].value;
        }
    }
    return val;
}

/*******************************************/
/******** REVIEW FORM FUNCTIONS ************/
/*******************************************/
function validate_pdReviewForm(thisform) {
    var message = "";
    //****** TEST FOR REQUIRED FORM VALUES ******
    with(thisform){
        var isRecommendedRadio = prGetRadioValue(isRecommended);
        
        if(prIsBlank(name.value)){message += "Please enter your name. \r\n";} 
        if(prIsBlank(email.value)){message += "Please enter your email address. \r\n";} 
        if(prIsBlank(location.value)){message += "Please enter your location. \r\n";}
        if(prIsBlank(rating.value)){message += "Please rate this item. \r\n";} 
        //if(prIsBlank(reviewTitle.value)){message += "Please title your review. \r\n";} 
        //if(prIsBlank(reviewText.value)){message += "Please enter your review. \r\n";} 
        //if(prIsBlank(isRecommended)){message += "Please choose yes or no for \"would you recommend this item\". \r\n";}

        if(!prIsBlank(email.value)){
            if(!prIsValidEmail(email.value)){
                message += "Please enter a correctly formatted email address. \r\n";
            }
        }
    }
    //****** TEST FOR HTML IN REVIEW, PROS AND CONS ******
    var reviewText = document.prForm.reviewBody.value;
    var prosText = document.prForm.reviewPros.value;
    var consText = document.prForm.reviewCons.value;
    if(reviewText.match("<") || reviewText.match(">")){
        message += "Please remove the HTML from your review. \r\n";
    }
    if(prosText.match("<") || prosText.match(">")){
        message += "Please remove the HTML from the \"Pros\" field. \r\n";
    }
    if(consText.match("<") || consText.match(">")){
        message += "Please remove the HTML from the \"Cons\" field. \r\n";
    }

    //****** SHOW MESSAGE IF VALIDATION FAILS ******
    if(!prIsBlank(message)){
        alert(message);
        return false;
    }else{
        return true;
    }
}
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

//*********************************************************************//
//******************** DHTML WINDOW DISPLAY ***************************//
//*********************************************************************//
function prDisplayLayerWin(elem){
    prShowFadeOverlay();
    prCenterLayerWin(elem);
    prShowLayerWin(elem);
    prPopulateReviewProductName();
    prGetUserInfo();
}
function prShowLayerWin(elem){
    var displayWindow = document.getElementById(elem);
    displayWindow.className = "prShowLayerWin";
}
function prHideLayerWin(elem){
    var displayWindow = document.getElementById(elem);
    var reviewForm = document.getElementById('prFormWrapper');
    var messageDisplay = document.getElementById('prFormMessage');
    displayWindow.className = "prHideLayerWin";
    messageDisplay.className = "prHide";
    reviewForm.className = "prShow";
    prHideFadeOverlay();
}
function prCenterLayerWin(elem) {
    var browserHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
    var scrollHeight = window.document.body.scrollHeight;
    var scrollWidth = window.document.body.scrollWidth;
    var scrollPositionX = 0;
    var scrollPositionY = 0;
    try {
        scrollPositionX = pageXOffset;
        scrollPositionY = pageYOffset;
    } catch(e) {
        scrollPositionX = document.body.scrollLeft;
        scrollPositionY = document.body.scrollTop;
    }

    var displayWindow = document.getElementById(elem);
    var displayWindowWidth = 730;
    var displayWindowHeight = displayWindow.scrollHeight;

    var styleTop = scrollPositionY + 90;
    var styleLeft = Math.round((scrollWidth - scrollPositionX)/2 - (displayWindowWidth/2) - 10);
    displayWindow.style.top = styleTop + "px";
    displayWindow.style.left = styleLeft + "px";
    return false;
}
function prShowFadeOverlay() {
    //************************************************************
    //***** DEFINE ELEMENTS FOR FADE AND CONTENT DISPLAY *********
    //************************************************************
    var fadeBg = document.getElementById('prFadeWrapper');
    fadeBg.className = "prFadeWrapperOn";
    //************************************************************
    //***** FIND AND SET USER WINDOW HEIGHT/WIDTH ****************
    //************************************************************
    var height;
    var winHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
    var scrollHeight = window.document.body.scrollHeight;
    var winWidth = window.document.body.scrollWidth;
    if(winHeight > scrollHeight){
        height = winHeight;
    }else{
        height = scrollHeight;
    }
    //************************************************************
    //*********** DISPLAY FADE BG AND CONTENT DIV ****************
    //************************************************************
    fadeBg.style.height = height + 'px';
    fadeBg.style.width = winWidth + 'px';
    return false;
}
function prHideFadeOverlay() {
    document.getElementById("prFadeWrapper").className = "prFadeWrapperOff";
    return false;
}

function ieHideSelect(state){
    var selectTags = document.getElementsByTagName("SELECT");
    for(var i=0; i<selectTags.length; i++){
        if(state){
            if(selectTags[i].className != "prSelect"){
                selectTags[i].style.display = "none";
            }
        }else{
            selectTags[i].style.display = "block";
        }
    }
}
//********************************************************//
//**************** REVIEW IMAGE DISPLAY ******************//
//********************************************************//
function prDisplayReviewImg(elem){
    prShowFadeOverlay();
    prCenterLayerWin(elem);
    prShowLayerWin(elem);
}
function prHideReviewImg(elem){
    var displayWindow = document.getElementById(elem);
    displayWindow.className = "prHideLayerWin";
    prHideFadeOverlay();
}
//*********************************************************************//
//***************** END DHTML WINDOW DISPLAY **************************//
//*********************************************************************//

//********************************************************//
//**************** POPULATE REVIEW DATA ******************//
//********************************************************//
function prPopulateUserInfo(){
    var userInfo = getUserInfoForReviews();
    document.prForm.name.value = userInfo.firstName;
    document.prForm.email.value = userInfo.email;
    document.prForm.location.value = userInfo.location;
    document.prForm.uid.value = userInfo.uid;
}
function prGetUserInfo() {
    var userInfoUrl = prClientDomain + "services/getCurrentUserInfoAndPopulateReviewFields.php";
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = userInfoUrl;
    document.getElementsByTagName("head")[0].appendChild(script);
}
function prPopulateReviewProductName(){
    var productName = document.prForm.productName.value;
    document.getElementById("productNameDisplay").innerHTML = productName;
}
//********************************************************//
//************** END POPULATE REVIEW DATA ****************//
//********************************************************//

function prRatingStars(){
    if(prDebug){alert("prRatingStars");}
    
    var prRatingStars = document.getElementById('prRatingStars');
    if(prRatingStars){
        var starLinks = prRatingStars.getElementsByTagName("IMG");
        for(var i=0;i<starLinks.length;i++){
            starLinks[i].className = "dptLinkOff"; 
            //******* MOUSEOVER EVENT ********//
            starLinks[i].onmouseover=function(){
                var pos = this.title - 0;
                for(var i=0;i<pos;i++){
                    starLinks[i].src = prClientDomain + "mod_productReviews/skins/" + prClientSkin + "/images/starOn.gif";
                }
            }
            //******* MOUSEOUT EVENT ********//
            starLinks[i].onmouseout=function(){
                var pos = this.title - 0;
                var rating = document.prForm.rating.value;
                for(var i=0;i<pos;i++){
                    if(i > rating - 1){
                        starLinks[i].src = prClientDomain + "mod_productReviews/skins/" + prClientSkin + "/images/starOff.gif";
                    }
                }
            }
            //******* ONCLICK EVENT ********//
            starLinks[i].onclick=function(){
                var pos = this.title - 0;
                document.prForm.rating.value = pos;
                for(var i=0;i<5;i++){
                    if(i + 1 <= pos){
                        starLinks[i].src = prClientDomain + "mod_productReviews/skins/" + prClientSkin + "/images/starOn.gif";
                    }else{
                        starLinks[i].src = prClientDomain + "mod_productReviews/skins/" + prClientSkin + "/images/starOff.gif";
                    }
                }
            }
        }
    }
}
function prMessage(state){
    if(prDebug){alert("prMessage");}

    var reviewForm = document.getElementById('prFormWrapper');
    var messageDisplay = document.getElementById('prFormMessage');
    var messageText = document.getElementById('prMessageText');

    var reviewExists = getQueryVariable("reviewExists");
    var name = getQueryVariable("name");
    var review = getQueryVariable("reviewSubmit");
    var image = getQueryVariable("imageSubmit");
    var winHeight = window.document.body.scrollHeight;
    var winWidth = window.document.body.scrollWidth - 10;
    
	if (messageText) { 
    messageText.innerHTML = '';
    }
    if(state == 'off'){
        ieHideSelect(false);
        fadeBg.style.display = "none";
        wrapper.style.display = "none";
        messageDisplay.style.display = "none";
        reviewForm.style.display = "block";
    }else if(review || image || reviewExists){
        //************ SET  MESSAGE TEXT *************
        if(review == 'true' && image == 'false'){
            messageText.innerHTML += '<b>Thank you for your time ' + unescape(name) +'! </b><br><br>';
            messageText.innerHTML += 'We appreciate your involvement in helping  ' + prClientName + '  create the ultimate online shopping experience.';
            messageText.innerHTML += '<br><br>Please note that while we received your review, the images did not meet our requirements and were not posted with the review.  Please feel free to try again with a smaller image size.';
            messageText.innerHTML += '<br><br><a href="#" onClick="prHideLayerWin(\'pr\')"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butContinueShopping.gif" border="0" vspace="20"></a>';
            
        }else if(review == 'false'){
            messageText.innerHTML += '<b>Thank you for your time ' + unescape(name) +' !</b><br><br>';
            messageText.innerHTML += 'We appreciate your involvement in helping  ' + prClientName + '  create the ultimate online shopping experience.';
            messageText.innerHTML += "<br><br>&raquo; There was an error submitting your review, please try again."
            messageText.innerHTML += '<br><br><a href="#" onClick="prHideLayerWin(\'pr\')"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butContinueShopping.gif" border="0" vspace="20"></a>';
        }else if(reviewExists == 'true'){
            messageText.innerHTML += '<b>Thank you for your time ' + unescape(name) +' !</b><br><br>';
            messageText.innerHTML += "&raquo; You have already submitted a review for this item.  You  may only submit one rating or review for each item."
            messageText.innerHTML += '<br><br><br><br><a href="#" onClick="prHideLayerWin(\'pr\')"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butContinueShopping.gif" border="0" vspace="20"></a>';
        }else{
            messageText.innerHTML += '<b>Thank you for your time ' + unescape(name) +' !</b><br><br>';
            messageText.innerHTML += 'We appreciate your involvement in helping  ' + prClientName + '  create the ultimate online shopping experience.';
            messageText.innerHTML += '<br><br><a href="#" onClick="prHideLayerWin(\'pr\')"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butContinueShopping.gif" border="0" vspace="20"></a>';
        }
        //************ SET DIV DISPLAY *************
        ieHideSelect(true);
        messageDisplay.className = "prShow";
        reviewForm.className = "prHide";
        prDisplayLayerWin('pr');
    }
}
function sendEmailsDisplay(state){
    if(state == "on"){
        document.getElementById('prSendEmails').style.display = "block";
    }else{
        document.getElementById('prSendEmails').style.display = "none";
        document.prForm.sendEmail1.value = "";
        document.prForm.sendEmail2.value = "";
        document.prForm.sendEmail3.value = "";
    }
}
function sendEmailsDisplayClose(){
        document.getElementById('prSendEmails').style.display = "none";
}
function uploadImagesDisplay(state){
    if(state == "on"){
        document.getElementById('prUploadImages').style.display = "block";
    }else{
        document.getElementById('prUploadImages').style.display = "none";
        document.prForm.img1.value = "";
        document.prForm.img2.value = "";
        document.prForm.img3.value = "";
    }
}
function uploadImagesDisplayClose(){
        document.getElementById('prUploadImages').style.display = "none";
}

/****************************************************/
/*********** DISPLAY RATINGS/ REVIEWS ***************/
/****************************************************/
function prRatingDisplay(){
    if(prDebug){alert("ratingDisplay");}

    var reviewsInfo = pdGetProductReviews();
    var overallRating = reviewsInfo.overallRating;
    var reviewCount = reviewsInfo.reviewCount;
    var ratingCount = reviewsInfo.ratingCount;

    var prOverallRating = document.getElementById('prOverallRating');
    if(prOverallRating){
        
    /**************************************************************/
    /*********** DISPLAY OVERALL RATING/REVIEW INFORMATION ********/
    /**************************************************************/
        html = '';
        if(reviewCount > 0){
            if(ratingCount > 1){var prS = "s"}else{var prS = "";}

            html += '<table border="0" cellpadding="0" cellspacing="0">';
            if(overallRating > 0){
            html += '<tr><th colspan="2">Overall Rating';
            if(document.prForm.productName.value){html += ' for ' + document.prForm.productName.value;}
            html += '</th></tr>';
            html += '<tr><td>';
                html += '<img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/ratings/' + overallRating + '.gif" border="0" vspace="4">';
                html += '(based on ' + ratingCount + ' rating' + prS + ')';
            html += '</td>';
            html += '<td align="right">';
            }else{
                html+= '<tr><td>';
            }
            html += '<a href=" " onClick="prDisplayLayerWin(\'pr\');return false;"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butReview.gif" border="0"></a>';
            html+= '</td></tr></table>';
            prOverallRating.innerHTML = html;
        }else{
            prOverallRating.style.display = 'none';
            prOverallRating.innerHTML = '';
        }
    }
    /**************************************************************/
    /*********** DISPLAY RATING/REVIEW LINKS **********************/
    /**************************************************************/
    var prRatingReviewLinks = document.getElementById('prRatingReviewLinks');
    if(prRatingReviewLinks){
        html = '';
        html += '<table border="0" cellpadding="0" cellspacing="0"><tr>';
        
        if(reviewCount > 0){
            html += '<td class="prRatingImg" colspan="2">';
            if(overallRating > 0){
                html += '<a href="#reviews" onClick="setItemTab(\'tabRev\');"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/ratings/' + overallRating + '.gif" border="0"></a>';
            }
            html += '</td></tr>';
            html += '<tr><td>';
            html += '<div class="prLinks">';
            html += '<a href="#reviews" onClick="setItemTab(\'tabRev\');">Read Reviews</a> / ';
            html += '<a href=" " onClick="prDisplayLayerWin(\'pr\');return false;">Rate This</a>';
            html += '</div>';
            html += '</td>';
        }else{
            html += '<td>';
            html += '<div class="prLinks">';
            html += '<a href=" " onClick="prDisplayLayerWin(\'pr\');return false;">Be the first to review!</a>';
            html += '</div>';
            html += '</td>';
        }
        html += '</tr></table>';
        prRatingReviewLinks.innerHTML = html;
    }
    if(prDebug){alert("ratingDisplay");}

}
function prReviewDisplay(){
    if(prDebug){alert("reviewDisplay");}

    var reviewsInfo = pdGetProductReviews();
    var productReviews = reviewsInfo.productReviews;    
    var reviewLength = productReviews.length;
/* ADDED 16th August 2010 ECI*/
    var upperReviewDisplayDiv = document.getElementById('testimonials');
	if(upperReviewDisplayDiv)
		{
		var upperReviewHTML	= "";
		if(reviewLength>1)
			{
				for(i=0;i<2;i++)
					{
					upperReviewHTML += "<p><b>"; 
					//append DATE
					if(!prIsBlank(productReviews[i].dateSubmitted))	
						{ upperReviewHTML += productReviews[i].dateSubmitted; }
					//append rating star image	
					if(productReviews[i].rating && productReviews[i].rating > 0)
						{ upperReviewHTML += ' <img height="14" width="71" border="0" src="http://site.accessorygeeks.com/pd_myAccount/mod_productReviews/skins/accessorygeeks/images/ratings/small/'+ productReviews[i].rating +'.gif" alt="'+ productReviews[i].rating +'stars">'; }
						upperReviewHTML += "</b>"; 
					if(!prIsBlank(productReviews[i].reviewBody))
						{upperReviewHTML	+= '<br><strong>Comments: </strong>'+productReviews[i].reviewBody; }
						
					if(!prIsBlank(productReviews[i].reviewPros))
						{upperReviewHTML	+= '<br><strong>Pros: </strong>'+productReviews[i].reviewPros;}
						
					if(!prIsBlank(productReviews[i].reviewCons))
						{upperReviewHTML	+= '<br><strong>Cons: </strong>'+productReviews[i].reviewCons;}	
					
					if(!prIsBlank(productReviews[i].name)){upperReviewHTML += '<br><strong>'+productReviews[i].name+'</strong>';}
					upperReviewHTML += "</p>"; 		
					//alert('test');
					}
			upperReviewDisplayDiv.innerHTML = upperReviewHTML;
			}
			
		}
/* ADDED 16th August 2010 ECI*/
    var reviewsDisplayDiv = document.getElementById('prReviews');
    if(reviewsDisplayDiv){
        
        /*******************************************/
        /*********** FORMAT REVIEW HTML ************/
        /*******************************************/
        var reviewHTML = '';
        for(var i=0; i < reviewLength; i++){
    
            reviewHTML += '<table border="0" cellspacing="0" cellpadding="0">';
            reviewHTML += '<tr>';
            //******** RATING *******//
            reviewHTML += '<th>';
            if(productReviews[i].rating && productReviews[i].rating > 0){reviewHTML += '<div class="prReviewsRating"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/ratings/small/' + productReviews[i].rating + '.gif" border="0"></div>';}
            //******** REVIEW TITLE *******//
            if(!prIsBlank(productReviews[i].reviewTitle)){reviewHTML += productReviews[i].reviewTitle;}
            reviewHTML += '</th>';
            reviewHTML += '</tr>';

            reviewHTML += '<tr>';
            //******** NAME, LOCATION, DATE POSTED *******//
            reviewHTML += '<td class="prReviewsNameLocation">';
            if(!prIsBlank(productReviews[i].name)){reviewHTML += 'By <b>' + productReviews[i].name + '</b>'}
            if(!prIsBlank(productReviews[i].location)){reviewHTML += ' from <b>' + productReviews[i].location + '</b>'}
            if(!prIsBlank(productReviews[i].dateSubmitted)){reviewHTML += ' on <b>' + productReviews[i].dateSubmitted + '</b>'}
            reviewHTML += '</td>';
            reviewHTML += '</tr>';

            reviewHTML += '<tr>';
            //******** REVIEW, PROS, CONS *******//
            reviewHTML += '<td class="prReviewsText">';
            //******** IS RECOMMENDED *******//
            if(productReviews[i].isRecommended){reviewHTML += '<div class="prReviewsRecommend">I would recommend this item to a friend.</div>';}
            if(!prIsBlank(productReviews[i].reviewBody)){reviewHTML += '<h4>Comments:</h4>' + productReviews[i].reviewBody;}
            if(!prIsBlank(productReviews[i].reviewPros)){reviewHTML += '<h4>Pros:</h4>' + productReviews[i].reviewPros;}
            if(!prIsBlank(productReviews[i].reviewCons)){reviewHTML += '<h4>Cons:</h4>' + productReviews[i].reviewCons;}
            reviewHTML += '</td>';
            reviewHTML += '</tr>';

            //******************************************//
            //******** REVIEW PHOTOS DISPLAY **********//
            //******************************************//
            var img1 = productReviews[i].img1;
            var img2 = productReviews[i].img2;
            var img3 = productReviews[i].img3;
            if(img1 && img1 != "error.jpg" || img2 && img2 != "error.jpg" || img3 && img3 != "error.jpg"){
                reviewHTML += '<tr>';
                reviewHTML += '<td class="prReviewsText"><h4>Review Photos:</h4>';
                reviewHTML += '<div class="prReviewPhotos">';
                if(img1 && img1 != "error.jpg"){
                    reviewHTML += '<div id="prImg1' + productReviews[i].reviewId + '" class="prHide"><div class="prReviewImgDisplay"><a href=" " onClick="prHideReviewImg(\'prImg1' + productReviews[i].reviewId + '\');return false;"><img src="' + prClientDomain + 'mod_productReviews/userReviewImages/large-' + img1 + '" border="0"></a><h4>click image to close</h4></div></div>';
                    reviewHTML += '<a href=" " onClick="prDisplayReviewImg(\'prImg1' + productReviews[i].reviewId + '\');return false;">';
                    reviewHTML += '<img src="' + prClientDomain + 'mod_productReviews/userReviewImages/small-' + img1 + '" border="0">';
                    reviewHTML += '</a>';
                }
                if(img2 && img2 != "error.jpg"){
                    reviewHTML += '<div id="prImg2' + productReviews[i].reviewId + '" class="prHide"><div class="prReviewImgDisplay"><a href=" " onClick="prHideReviewImg(\'prImg2' + productReviews[i].reviewId + '\');return false;"><img src="' + prClientDomain + 'mod_productReviews/userReviewImages/large-' + img2 + '" border="0"></a><h4>click image to close</h4></div></div>';
                    reviewHTML += '<a href=" " onClick="prDisplayReviewImg(\'prImg2' + productReviews[i].reviewId + '\');return false;">';
                    reviewHTML += '<img src="' + prClientDomain + 'mod_productReviews/userReviewImages/small-' + img2 + '" border="0">';
                    reviewHTML += '</a>';
                }
                if(img3 && img3 != "error.jpg"){
                    reviewHTML += '<div id="prImg3' + productReviews[i].reviewId + '" class="prHide"><div class="prReviewImgDisplay"><a href=" " onClick="prHideReviewImg(\'prImg3' + productReviews[i].reviewId + '\');return false;"><img src="' + prClientDomain + 'mod_productReviews/userReviewImages/large-' + img3 + '" border="0"></a><h4>click image to close</h4></div></div>';
                    reviewHTML += '<a href=" " onClick="prDisplayReviewImg(\'prImg3' + productReviews[i].reviewId + '\');return false;">';
                    reviewHTML += '<img src="' + prClientDomain + 'mod_productReviews/userReviewImages/small-' + img3 + '" border="0">';
                    reviewHTML += '</a>';
                }
                reviewHTML += '</div>';
                reviewHTML += '</td>';
                reviewHTML += '</tr>';
            }
            //******************************************//
            //******************************************//
            //******************************************//

            //******************************************//
            //********** MERCHANT RESPONSE *************//
            //******************************************//
            if(!prIsBlank(productReviews[i].response)){reviewHTML += '<tr><td><div class="prMerchantResponse"><h4>Merchant Response:</h4>' + productReviews[i].response + '</div></td></tr>';}

            reviewHTML += '</table>';
        }

        if(reviewLength > 0){
            reviewsDisplayDiv.innerHTML = reviewHTML;
        }else{
            var reviewHTML = '';
            reviewHTML += '<div class="prFirstToReview">';
            reviewHTML += '<a href=" " onClick="prDisplayLayerWin(\'pr\'); return false;"><img src="' + prClientDomain + 'mod_productReviews/skins/' + prClientSkin + '/images/butReview.gif" border="0" align="right"></a>';
            reviewHTML += 'Be the first person to rate and review this item!';
            reviewHTML += '</div>';
            
            reviewsDisplayDiv.innerHTML = reviewHTML;
        }
    }
}

//************************************************************//
//************* DISPLAY REVIEW FORM LOGIC ********************//
//************************************************************//
function prReviewFormDisplay(){
    if(prDebug){alert("prReviewFormDisplay");}
    var writeReview = getQueryVariable("writeReview");
    var reviewSource = getQueryVariable("reviewSource");
    if(writeReview){
        document.prForm.reviewSource.value = reviewSource;
        prDisplayLayerWin('pr');
    }

}
// Eof Myaccount reviewsClientScript.js

// Collapse JS
function Cookie_custom(name) {
    this.setValue = function (value, hours, bridge) {
        var cookieString, date;
        cookieString = name + "=" + escape(value);
        if (hours) {
            date = new Date();
            date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
            cookieString += "; expires=" + date.toGMTString();
        }
        cookieString += "; path=/";
        document.cookie = cookieString;
        if (bridge) {
            // send cookie info to check in
            cookiesForBridge.push(cookieString);
        }
    };
    
    this.getValue = function () {
        var results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
        return results ? unescape(results[2]) : null;
    };
    
    this.remove = function () {
        this.setValue("", -1);
    };
}

function getElementsByClassName_custom(obj, theClass, theTag) {
    var allTagsWithClass = [],
        thisTag, i;
    
    for (i = 0; (thisTag = obj.getElementsByTagName(theTag ? theTag : '*')[i]); i++) {
        if (thisTag.className === theClass) {
            allTagsWithClass.push(thisTag);
        }
    }
    return allTagsWithClass;
}

function custom_collapse() {
    var lastHash, containers, page, cookie, checkHash, eventOverOut, eventClick, qNaCurrent, valCollapse, i, objectList, cookieVal, num;
    lastHash = null;
    containers = [];
    page = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1);
    cookie = new Cookie_custom(page);

    // Check if we need to follow an anchor
    checkHash = function () {
        return function () {
            var sectionToDisplay;
            if (document.location.hash && lastHash !== document.location.hash) {
                lastHash = document.location.hash;
                sectionToDisplay = document.getElementById(document.location.hash.split('#')[1]);
                if (sectionToDisplay && sectionToDisplay.className === 'collapse_tab_block hide_block') {
                    sectionToDisplay.className = sectionToDisplay.className.replace(new RegExp(" hide_block\\b"), "");
                }
            }
        };
    };
    
    // returns an event handler for collapse mouse over and out events
    eventOverOut = function () {
        return function (e) {
            if (this.className === 'collapse_title') {
                this.className += ' collapse_over';
            } else {
                this.className = this.className.replace(new RegExp(" collapse_over\\b"), "");
            }
        };
    };
    
    // returns an event handler for collapse click
    eventClick = function () {
        return function (e) {
            var i, newValue;
            if (this.parentNode.className === 'collapse_tab_block') {
                this.parentNode.className += ' hide_block';
                if (document.location.hash) {
                    if (this.parentNode.id === document.location.hash.split("#")[1]) {
                        document.location.hash = '';
                    }
                }
            } else {
                this.parentNode.className = this.parentNode.className.replace(new RegExp(" hide_block\\b"), "");
            }
            
            // sets a cookie to tell us which qna's were open
            newValue = '|';
            for (i = 0; i < containers.length; i += 1) {
                if (containers[i].className === 'collapse_tab_block') {
                    if (i < 10) {
                        newValue += '0';
                    }
                    newValue += i + '|';
                }
            }
            cookie.setValue(newValue);
        };
    };
    
    // init this thing
    objectList = document.getElementById('collapse_main_box');
    if (objectList) {
        containers = getElementsByClassName_custom(objectList, 'collapse_tab_block', 'div');
        containers = containers.concat(getElementsByClassName_custom(objectList, 'collapse_tab_block', 'span'));
        if (containers.length > 0) {
            // checks cookie to see which qna's were left open last time they were on this page
            cookieVal = cookie.getValue();
            for (i = 0; i < containers.length; i += 1) {
                qNaCurrent = containers[i];
                if (cookieVal) {
                    num = (i < 10) ? '0' + i : i;
                    qNaCurrent.className += (cookieVal.match(num)) ? '' : ' hide_block';
                } else {
                    qNaCurrent.className += ' hide_block';
                }
                
                valCollapse = getElementsByClassName_custom(qNaCurrent, 'collapse_title', 'div');
                if (valCollapse.length > 0) {
                    valCollapse = valCollapse[0];
                    valCollapse.innerHTML = valCollapse.innerHTML.replace("<span>", "").replace("</span>", ""); // temp fix for Chrome
                    valCollapse.onmouseover = eventOverOut();
                    valCollapse.onmouseout = eventOverOut();
                    valCollapse.onclick = eventClick();
                }
            }
            window.setInterval(checkHash(), 200);
        }
    }
}
// Eof Collapse JS
