﻿// This file must be reference below the latest jquery script reference.

function showPrice(price, productItemId){
    $('#price-display div').html(price);
    $('#ProductItemId').attr('value', productItemId);
}

function hidePrice(){
    //$('#price-display div').html('Buy <br />Me');
}

function addProductItemId(productItemId) {
     $('#ProductItemId').attr('value', productItemId);
}

function showElement(elementId) {
    $('#' + elementId).show();
}

function hideElement(elementId) {
    $('#' + elementId).hide();
}

function changeImage(imageId, imageSrc) {
    var image = $('#' + imageId);
    if (!image) return false;
    
    image.attr('src', imageSrc);
    $('html,body').animate({scrollTop: image.offset().top}, 1000);
    return false;
}

function bookmark(name, url)
{
    netscape="Use CTRL+D to add a bookmark to this site."
    if (window.sidebar)  // Mozilla Firefox Bookmark
    {
        window.sidebar.addPanel(name, url, "");
    }
    else if( window.external ) // IE Favorite 
    {
        window.external.AddFavorite(url, name); 
    }
    else
    {
        alert(netscape);
    }
}

function setTargetForExternalLinks() { 

 if (!document.getElementsByTagName) return; 

 var anchors = document.getElementsByTagName("a"); 

 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   {
	 anchor.target = "_blank"; 

	 if (anchor.getAttribute("title"))
	 	anchor.title = anchor.title + " - ";

	 anchor.title = anchor.title + "Opens a new window to an external web site";

   }
 } 
} 

$(document).ready(setTargetForExternalLinks);
