// 1: http://lib.store.yahoo.net/lib/yhst-71585368631737/recent-edit.js
// 2: http://lib.store.yahoo.net/lib/yhst-71585368631737/ysw-bookmark.js
// 3: http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-featuredItems.js
// 4: http://lib.store.yahoo.net/lib/yhst-71585368631737/featured-tabs-item.js


// FROM: http://lib.store.yahoo.net/lib/yhst-71585368631737/recent-edit.js
var name = "recentItems"; //cookieName
var days = 7; // days before expiration
var newString = "";
var num = 4; // number of items to display
var unique ="yes"; //

// create cookie assigning name, value and expiration days


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


// read cookie by name and list value
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// delete cookie by name
function eraseCookie(name) {
	createCookie(name,"",-1);
}

var preCookie = readCookie(name);

// append new data to cookie.
function setCookie(){
	var s = curString.replace("^",""); // strips ^ from curent string
	if (!preCookie || preCookie == ""){
	// if cookie does not exist, create it with the current item's data
		newString = curString;
	} else { 
	// If cookie exists, split and compare its content to current item 
		var eachItem = preCookie.split("^");
		for (i = 0; i < num; i++){
			if (eachItem[i] == s ) { 
			unique = "no";
			} 	
		} if (unique == "yes"){
		// if current data is unique, add it to cookie
		  newString = curString + preCookie;
		  } else {
		// if current data is not unique, do not add it to cookie
		  newString = preCookie;

		  }
	}  
	createCookie(name,newString,days)
}

//splitting and writing cookie data
function writeRecent(){
	if (preCookie && preCookie != ""){
		var eachItem = preCookie.split("^");
		var i2 = 0
    document.write("<br /><div id=\"recentItemHeader\">Recently Viewed Items</div>");
		for (i = 0; i < num || i2 < num; i++){
			//only write item if it exists, is not empty and is unique
			if (eachItem[i] && eachItem[i] != ""){
				var eachElement = eachItem[i].split("|");	
				if (eachElement[0] != prodID){
					document.write("<div id=\"recentItem" + i2 + "\"" + "  class=\"recentItem\"> ");
					document.write("<div class=\"recentImg\"><a href=\"" + eachElement[0] + ".html\"><img src=\"" + eachElement[1] + "\" border=\"0\" class=\"reflect\" /></a></div>");
					document.write("<div class=\"recentName\"><a href=\"" + eachElement[0] + ".html\">" + eachElement[2] + "</a></div>");
					if (eachElement[3] && eachElement[3] != ""){
						document.write("<div class=\"recentPrice\">Retail Price: " + eachElement[3] + "</div>");
						}
					if (eachElement[4] && eachElement[4] != ""){
						document.write("<div class=\"recentSprice\">Your Price: " + eachElement[4] + "</div>");
						}
					document.write("</div>");
					i2 = i2 + 1; 
				}
			} else { i2 = i; } // don't increment counter is the current page is already displayed
		}
	}	 
}



// FROM: http://lib.store.yahoo.net/lib/yhst-71585368631737/ysw-bookmark.js

/***********************************************
* Bookmark site script- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}



// FROM: http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-featuredItems.js
function changeTabbedItem(b){
if(b == "1")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-tabbedLinksBG.jpg) no-repeat scroll center top");
}
else if(b == "2")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-tabbedLinksBG.jpg) no-repeat scroll center -29px");
}
else if(b == "3")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-tabbedLinksBG.jpg) no-repeat scroll center -58px");
}
else if(b == "4")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-tabbedLinksBG.jpg) no-repeat scroll center -87px");
}
else
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-71585368631737/ey-tabbedLinksBG.jpg) no-repeat scroll center -116px");
}

$(".tabbedA").removeClass('selectedTab');
$("#TabbedA" + b).addClass('selectedTab');
$(".tabbedItemsTable").css("display", "none");
$("#TabbedItemsTable" + b).css("display", "block");

}

// ring mountings template tabs
function changemountTab(d)
{
$(".itemmounttabs").css("display", "none");
$("#mTab"+d).css("display", "block");
$(".itemmountClass").removeClass('selected');
$("#mttab"+d).addClass('selected');


if (d==1)
{
$(".itemmountTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/mss-mount-tabs.jpg) no-repeat scroll 0 0");
}

if (d==2)
{
$(".itemmountTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/mss-mount-tabs.jpg) no-repeat scroll 0 -21px");
}

if (d==3)
{
$(".itemmountTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/mss-mount-tabs.jpg) no-repeat scroll 0 -42px");
}
}

// FROM: http://lib.store.yahoo.net/lib/yhst-71585368631737/featured-tabs-item.js
function changeTab(d)
{
$(".itemtabs").css("display", "none");
$("#Tab"+d).css("display", "block");
$(".itemClass").removeClass('selected');
$("#tab"+d).addClass('selected');


if (d==1)
{
$(".itemTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/ey-item-tabs.jpg) no-repeat scroll 0 0");
}

if (d==2)
{
$(".itemTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/ey-item-tabs.jpg) no-repeat scroll 0 -21px");
}

if (d==3)
{
$(".itemTable").css("background", "url(https://lib.store.yahoo.net/lib/yhst-71585368631737/ey-item-tabs.jpg) no-repeat scroll 0 -42px");
}
}

// ring mounting js
function selectGem(gid) {
$(".gems").css({'display' : 'none'});
$(".vwit[name=\"vwitem\"]").each(function(i){
  $(this).attr('name', 'vwitem'+(i+2));
});
$(".vwqty[name=\"vwquantity\"]").each(function(i){
  $(this).attr('name', 'vwquantity'+(i+2));
});
function countChecked() {
if($('.vwqty').is(':checked')){
//alert("OK");
$(this).attr('value', '1');
} else {
$('.vwqty').attr('value', '1');
} }
$(":checkbox").click(countChecked);

 var gemName = gid; 
 $("#"+gemName).css("display", "block");
}


