﻿var fieldvalue = {"search":"Product Search"};

var Cookie = {
  data: {},
  options: {expires: 1, domain: "", path: "", secure: false},

init: function(options, data) {
  Cookie.options = Object.extend(Cookie.options, options || {});

  var payload = Cookie.retrieve();
        if(payload) {
            Cookie.data = payload.evalJSON();
        }
        else {
            Cookie.data = data || {};
        }
        Cookie.store();
    },
    getData: function(key) {
        return Cookie.data[key];
    },
    setData: function(key, value) {
        Cookie.data[key] = value;
        Cookie.store();
    },
    removeData: function(key) {
        delete Cookie.data[key];
        Cookie.store();
    },
    retrieve: function() {
        var start = document.cookie.indexOf(Cookie.options.name + "=");

        if(start == -1) {
            return null;
        }
        if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) {
            return null;
        }

        var len = start + Cookie.options.name.length + 1;   
        var end = document.cookie.indexOf(';', len);

        if(end == -1) {
            end = document.cookie.length;
        } 
        return unescape(document.cookie.substring(len, end));
    },
    store: function() {
        var expires = '';

        if (Cookie.options.expires) {
            var today = new Date();
            expires = Cookie.options.expires * 86400000;
            expires = ';expires=' + new Date(today.getTime() + expires);
        }

        document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires;
    },
    erase: function() {
        document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    },
    getOptions: function() {
        return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : '');      
    }
};

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

var cssMenu = {
   menu_obj: {},
   current_id: null,
	init: function (element) {
			
		//Event.observe(document, 'mousemove', cssMenu.getcords);
		
		if($(element))
	   {
			var menu_array = $(element).childElements();
			
			cssMenu.create_menus(menu_array,"m1");	
		}
	},
	getcords: function(e){
				mouseX = Event.pointerX(e);
				mouseY = Event.pointerY(e);
						
				//$('debug2').innerHTML = cssMenu.current_id+' - mouseX:' + mouseX + '-- mouseY:' + mouseY;
				
				if(cssMenu.menu_obj[cssMenu.current_id])
				{
					m = cssMenu.menu_obj[cssMenu.current_id];
		
					mc = m.submenu.className;
					mc = mc.split("_");
					
					if(m.submenu.className == mc[0]+'_on')
					{
						//$('debug').innerHTML = m.submenu.className;
						
						offsets = Element.cumulativeOffset(m.submenu);
						mtop     = offsets[1]-30;
						mleft    = offsets[0];
						mbottom  = m.submenu.getHeight()+mtop+30;
						mright   = m.submenu.getWidth()+mleft;
						
						//$('debug2').innerHTML = mleft+"+"+m.submenu.getWidth()+"="+mright+"|"+mtop+"+"+m.submenu.getHeight()+"="+mbottom+"|"+'mouseX:' + mouseX + '-- mouseY:' + mouseY;
						if(!(mouseX > mleft && mouseX < mright) || !(mouseY > mtop && mouseY < mbottom))
						{
							m.submenu.removeClassName(mc[0]+'_on');
						   m.submenu.addClassName(mc[0]+'_off');
						}
					}
				}
	},
	create_menus: function(menu,parent) {
		menu.each(function(m)
		{
			var submenu_array = m.childElements();
			
			if(submenu_array.length > 1)
			{
				mid = m.id;
				if(mid != ""  && !mid.include("ul"))
				{
			         cssMenu.create_menus(submenu_array,m.id);
						cssMenu.menu_obj[m.id] = {"submenu":submenu_array[1],"parent_menu":parent};
						m.observe('mouseover',cssMenu.showMenu);
						m.observe('mouseout',cssMenu.hideMenu);
				}
			}
		});
						//if($('debug2'))
						//$('debug2').innerHTML = Object.keys(cssMenu.menu_obj);
	},
	showMenu: function(e) {
		
		//$('debug2').innerHTML = cssMenu.menu_obj[this.id].submenu.id + " | ";
		
		//cssMenu.current_id = this.id;
		m = cssMenu.menu_obj[this.id].submenu;
		pm = cssMenu.menu_obj[this.id].parent_menu;
		mc = m.className;
		mc = mc.split("_");
		
		m.removeClassName(mc[0]+'_off');
		m.addClassName(mc[0]+'_on');
	},
	hideMenu: function(e) {
		
		m = cssMenu.menu_obj[this.id].submenu;
		
		mc = m.className;
		mc = mc.split("_");
		
		m.removeClassName(mc[0]+'_on');
		m.addClassName(mc[0]+'_off');
		
	}
};

function clearField(element)
{
	if(fieldvalue[element.name])
		if(fieldvalue[element.name] == element.value) {
		   element.value = "";
		}
		else if(element.value == "") {
		   element.value = fieldvalue[element.name];
		}
}

function switchView(key,value)
{
	Cookie.init({name: 'rfwcartlayout', path: '/'});
	
	if(key == 'layout')
		if(Cookie.getData('layout')==3)
			Cookie.setData('pagesize',6);
		else
			Cookie.setData('pagesize',6);
			
	Cookie.setData(key,value);
	
	curhref = window.location.href;
	
	newhref = curhref.split("/p-");
	//alert(newhref[0]);
	if(newhref.length > 1) {
		test = newhref[0].split("/artist-");
		if(test.length > 1) window.location.href = newhref[0]+"/";
		else window.location.href = newhref[0]+"/p-1/";
	}
	else window.location.reload();
}

function toggle_advanced() {
	if($('advanced_search').style.display == 'none')
	   Effect.SlideDown('advanced_search');
	else if($('advanced_search').style.display == '')
	   Effect.SlideUp('advanced_search');	
}

function display_login(login_status)
{
	
            var ni = document.getElementById('loginBox');
            var newanchor = document.createElement('a');
          if(ni!=null){
            if (login_status)
              ni.innerHTML ="<a href='cart/my-account.php?Logout=Go&ContinueURL=/index.html' title='Sign Out' class='sign'>SIGN OUT</a>";
            else 
              ni.innerHTML ="<a href='cart/my-account.php?ContinueURL=/index.html' title='Sign Out' class='sign'>SIGN IN</a>";
          }
          
}

function bookmarksite(title, url)
{
    if (document.all) window.external.AddFavorite(url, title);
    else if (window.sidebar) window.sidebar.addPanel(title, url, "");
}


function get_document_window_height()
{
   if (document.body && document.body.clientHeight &&
       (document.body.clientHeight > 1)) return document.body.clientHeight;
   else if (window && window.innerHeight) return window.innerHeight;
   else if (document.documentElement && document.documentElement.offsetHeight)
      return document.documentElement.offsetHeight;
   else if (document.body && document.body.offsetHeight)
      return document.body.offsetHeight;
   return 0;
}

function get_document_window_width()
{
   if (document.body && document.body.clientWidth)
      return document.body.clientWidth;
   else if (window && window.innerWidth) return window.innerWidth;
   else if (document.documentElement && document.documentElement.offsetWidth)
      return document.documentElement.offsetWidth;
   else if (document.body && document.body.offsetWidth)
      return document.body.offsetWidth;
   return 0;
}

function convert_width(width,window_width)
{
   if (width == null) width = page_width + 52;
   else if (typeof(width) == 'string') {
      var percent_pos = width.indexOf('%');
      if (percent_pos != -1)
         width = window_width * (width.substr(0,percent_pos) / 100);
   }
   if (! document.all) {
      if (width > (window_width - 25)) width = window_width - 25;
   }
   else if (width > (window_width - 10)) width = window_width - 10;
   return width;
}

function convert_height(height,window_height)
{
   if (height == null) height = window_height;
   else if (typeof(height) == 'string') {
      var percent_pos = height.indexOf('%');
      if (percent_pos != -1)
         height = window_height * (height.substr(0,percent_pos) / 100);
   }
//   else height += header_offset;
   if (height > (window_height - 40)) height = window_height - 40;
   return height;
}

function calculate_left(width,window_width)
{
   var left = (window_width - width) / 2;
   if (! document.all) left += 10;
   if (left < 0) left = 0;
   return left;
}

function calculate_top(height,window_height)
{
   var top = ((window_height - height) / 2) - 3;
   if (top < 0) top = 0;
   return top;
}
	

//---------------------------------- ice white scripting ------------------
function search_onselect(myinput)
{
	//var myinput = me;
    if(myinput.value == "keyword or item #") {
      myinput.value="";
    }else if(myinput.value == "") {
        myinput.value="keyword or item #";
    }
}

function go_search_top() {
	document.search_form_top.action="/~icewhite/_oldsite/";
	document.search_form_top.search_form_top_submit.value ="yes";
	document.search_form_top.submit();
}

function email_onselect()
{
		var eminput = document.myform_sub.email;
    if(eminput.value == "ENTER YOUR EMAIL HERE") { eminput.value=""; }
}
function precheck()
{
	  var submit_form = "yes";
 		var eminput = document.myform_sub.email;

    if( !eminput.value.match(/\./) || !eminput.value.match(/@/) )
    {
        alert("please enter a valid [E-Mail]");
        submit_form = "no";
    }
  
  if( submit_form == "yes" ) {
  document.myform_sub.submit();
  }
}
function onlyint(e,field) 
{ 
     if (window.event) keynum = e.keyCode; 
     else if (e.which) keynum = e.which; 
 
     if (keynum == "0x08") return true; 
     if (keynum == "0x09") return true; 
       if (keynum == "0x20") return true; 
		 if ((keynum == "0x2d" || keynum == "0x2e" || keynum == "0x28" || keynum == "0x29")&& field == 'phone') return true;
     if (keynum == "0x2E" && field == 'currency') return true;
		 if(keynum == "0x2d"&& field == 'ein') return true;
		 if((keynum == "0x24" || keynum == "0x2e" || keynum =="0x2C") && field =='usd') return true;
		 if (keynum == "0x2D" && field == 'zip') return true;
     if (keynum == "0x2F" && field == 'date') return true; 
     if ((keynum >= "0x30") && (keynum <="0x39")) return true; 
     return false;
}

function onlyAlphaNumeric(e)  
{  
     if (window.event) keynum = e.keyCode;  
     else if (e.which) keynum = e.which;  
  
     if (keynum == "0x08") return true;  
     if (keynum == "0x09") return true;  
       if (keynum == "0x20") return true;  
     if ((keynum >= "0x30") && (keynum <="0x39")) return true;  
     if ((keynum >= "0x41") && (keynum <="0x5A")) return true;  
     if ((keynum >= "0x61") && (keynum <="0x7A")) return true;  
     return false;  
}

function onlyAlpha(e)  
{  
     if (window.event) keynum = e.keyCode;  
     else if (e.which) keynum = e.which;  
  
     if (keynum == "0x08") return true;  
     if (keynum == "0x09") return true;  
       if (keynum == "0x20") return true;  
     //if ((keynum >= "0x30") && (keynum <="0x39")) return true;  
     if ((keynum >= "0x41") && (keynum <="0x5A")) return true;  
     if ((keynum >= "0x61") && (keynum <="0x7A")) return true;  
     return false;  
}

function autotab(current,to){  
    if (current.getAttribute &&   
      current.value.length==current.getAttribute("maxlength")) {  
        to.focus(); 
        } 
}
var allcolor = new Array("D","E","F","G","H","I","J","K");
var allclarity = new Array("FL","IF","VVS1","VVS2","VS1","VS2","SI1","SI2","I1");
var allcarat = new Array(0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.10,1.15,1.25,1.30,1.35,1.40,1.45,1.50,1.55,1.60,1.65,1.70,1.75,1.80,1.85,1.90,1.95,2.00,2.25,2.50,2.55,2.60,2.70,2.80,3.00,3.25,3.50,4.00,4.25,4.50,5.00,5.25,5.50,6.0);
var allcut = new Array("IDEAL","EXCELLENT","VERY GOOD","GOOD","FAIR");
var allflo = new Array("VERY STRONG","STRONG","MEDIUM","FAINT","NONE");
var allpolsym = new Array("IDEAL","EXCELLENT","VERY GOOD","GOOD","FAIR");

function set_item(hi,low,col,arr){
	var begin = low.options[low.selectedIndex].value;
	var end = hi.options[hi.selectedIndex].value;
	//alert("end: "+end+", begin: "+begin);
	var remove=end*1-begin*1;
	if(begin*1>end*1){
		var temp=begin*1;
		begin=end*1;
		end=temp*1;
	}
	//alert("begin: "+begin+" end: "+end);
	var decimate = new Array();
	for(var i=0;i<arr.length;i++){
		if(i<=end && i>=begin){
			decimate[decimate.length]=arr[i];
		}
	}
	//alert(decimate);
	col.value=decimate.join(",");
}
function set_itemC(one,two,place){
	var sone=one.options[one.selectedIndex].value;
	var stwo=two.options[two.selectedIndex].value;
	if(sone>stwo){
		var temp=sone;
		sone=stwo;
		stwo=temp;
	}
	place.value=sone+","+stwo;
}

function removeBelowSelected(target,me){
	//alert('working');
	selected=target.options[target.selectedIndex].value;
	while(target.options[0]){
		target.remove(0);
	}
	for(i=me.selectedIndex;i<me.length;i++){
		var newopt = document.createElement('option');
		newopt.text=me.options[i].text;
		newopt.value=me.options[i].value;
		if(newopt.value==selected)newopt.selected=true;
		//target.add(newopt,null);
		target.options[target.options.length]=newopt;
	}
	
	//alert('finished');
}

//*currency swap settings
var SetCAD='<a href="#" id="flag" onclick="currencySwap(this); return false;" title="Swap to CA Dollar"><img src="images/buttons/canadianFlag.jpg" alt="Swap to CA Dollar" border="0"> Click for pricing in CAD$</a>';
var SetUSD='<a href="#" id="flag" onclick="currencySwap(this); return false;" title="Swap to US Dollar"><img src="images/buttons/usaFlag.jpg" alt="Swap to US Dollar" border="0"> Click for pricing in USD$</a>';
function currencySwap(me){
	if(readCookie("IceWhiteDiamondCurrency") == 'CAD' && me.id!='CAD'){
		//alert("CAD to USD");
		setNonHashingCookie("IceWhiteDiamondCurrency","USD");
		location.reload();
	}else if(readCookie("IceWhiteDiamondCurrency") == 'USD' && me.id!='USD'){
		//alert("USD to CAD");
		setNonHashingCookie("IceWhiteDiamondCurrency","CAD");
		location.reload();
	}
}
function setNonHashingCookie(name,val) {
    var expires = '';
    //alert(name+" "+val);
    var today = new Date();
    expires = 86400000;
    expires = ';expires=' + new Date(today.getTime() + expires);
    document.cookie = name + '=' + val + expires + ";path=/";
}
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;
}
window.onload = function openme(){	cssMenu.init('header_menu');
	var current = readCookie("IceWhiteDiamondCurrency");
	//alert(current);
	if(current){
		if($('currencyFlag')){
			switch(current){
				case 'USD':
					$('currencyFlag').innerHTML=SetCAD;
					break;
				case 'CAD':
					$('currencyFlag').innerHTML=SetUSD;
					break;
			}
		}
	}else{
		setNonHashingCookie("IceWhiteDiamondCurrency","USD");
		if($('currencyFlag')){
		  $('currencyFlag').innerHTML=SetCAD;
		}
	}
	if($('dhtmltooltip')){
		tipobj=$('dhtmltooltip');
		//document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	}
	/*twttr.anywhere(function (T) {
      T('#follow_twitterapi').followButton("icewhitediamond");
    });*/
}
var tipobj;
/*ice whitediamond search functions*/
 //alert(location.href);
 locationstr=location.href;
 if(locationstr.indexOf("diamond_search03.php")>=0||location.href.indexOf('design04.php')>=0){
	//alert("diamond_search03");
	isIE=document.all;
	function ddInit(e){
	  topD=isIE ? "BODY" : "HTML";
	  w=isIE ? document.all.theLayer : document.getElementById("theLayer");
	  h=isIE ? event.srcElement : e.target;
	  //  while (h.id!="titleBar"&&h.tagName!=topD){
	  //    h=isIE ? h.parentElement : h.parentNode;
	  //  }
	  if (h.id=="titleBar"){
		offsetx=isIE ? event.clientX : e.clientX;
		offsety=isIE ? event.clientY : e.clientY;
		nowX=parseInt(w.style.left);
		nowY=parseInt(w.style.top);
		ddEnabled=true;
		document.onmousemove=dd;
	   }
	}
	document.onmousedown=ddInit;
	document.onmouseup=Function("ddEnabled=false");
	var vZoomImage = new Image;
	function loadfirst()	{
		changeNormalImg(0);
	}
	function changeNormalImg(i)	{
		var prdtype = 1;
		//alert(imageArr);
		if(typeof(i) != 'number')
			i = 0;
		document.getElementById('normalImage').src = imageArr[i][1].src;
		document.getElementById('normalImage').alt = imageArr[i][1].alt;
		document.getElementById('normalImage').onclick = null;
		document.getElementById('normalImage').style.cursor='default';
		if(i==1)	  {
			document.getElementById("normalTopDimensions").style.visibility="visible";
			document.getElementById("normalSideDimensions").style.visibility="hidden";
		}else if(i==2)	  {
			document.getElementById("normalSideDimensions").style.visibility="visible";
			document.getElementById("normalTopDimensions").style.visibility="hidden";
		}else	  {
			document.getElementById("normalSideDimensions").style.visibility="hidden";
			document.getElementById("normalTopDimensions").style.visibility="hidden";
		}
	}
	function add_cart(id)	{
		document.add_cart_form.diamond_id.value = id;
		document.add_cart_form.submit();
	}
 } 
 if(location.href.indexOf('design01.php')>=0){
	var offsetxpoint=-60
	//Customize x offset of tooltip
	var offsetypoint=20 
	//Customize y offset of tooltip
	var ie=document.all
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
		function ietruebody(){
			return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
		}
	function ddrivetip(thetext, thecolor, thewidth){
		if (ns6||ie){
			if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
			if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
			tipobj.innerHTML=thetext
			enabletip=true
			return false
		}
	}
	function positiontip(e){
		if (enabletip){
			var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
			var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
			//Find out how close the mouse is to the corner of the window
			var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
			var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
			var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
			//if the horizontal distance isn't enough to accomodate the width of the context menu
			if (rightedge<tipobj.offsetWidth)
				//move the horizontal position of the menu to the left by it's width
				tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
			else if (curX<leftedge)
				tipobj.style.left="5px"
			else
				//position the horizontal position of the menu where the mouse is positioned
				tipobj.style.left=curX+offsetxpoint+"px"
				//same concept with the vertical position
				if (bottomedge<tipobj.offsetHeight)
					tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
				else
					tipobj.style.top=curY+offsetypoint+"px"
				tipobj.style.visibility="visible"
		}
    }
    function hideddrivetip(){
		if (ns6||ie){
			enabletip=false
			tipobj.style.visibility="hidden"
			tipobj.style.left="-1000px"
			tipobj.style.backgroundColor=''
			tipobj.style.width=''
		}
	}
    document.onmousemove=positiontip;
	function ringchangeimage(pid, imgurl)	    {
		document.getElementById(pid).src=imgurl;
    }
	function setting_search(s)	    {
		document.setting_search.order_by.value = s;
		document.setting_search.submit();
	}
 }
 if(location.href.indexOf('design02.php')>=0){
	function sellay0(num){
		for(var id = 1;id<=3;id++)         {
			var ss="tlist"+id;
			if(id==num)
				document.getElementById(ss).style.display="block";
			else 
				document.getElementById(ss).style.display="none";
		} 
        for(var id = 1;id<=3;id++)         {
			var bb="ltitle"+id;
			if(id==num)
				document.getElementById(bb).className="active";
			else 
				document.getElementById(bb).className="";
		}
	}
	/***********************************************
	* Image Thumbnail Viewer II script- ?Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
	* This notice must stay intact for legal use
	***********************************************/
	//Specify image paths and optional link (set link to "" for no link):
	//var dynimages=new Array()
	//dynimages[1]=["../images/1.jpg", ""]
	//dynimages[2]=["../images/2.jpg", ""]
	//dynimages[3]=["../images/3.jpg", ""]
	//      //dynimages[4]=["../images/4.jpg", ""]
	//dynimages[5]=["../images/5.jpg", ""]
	//Preload images ("yes" or "no"):
	var preloadimg="no"
	//Set optional link target to be added to all images with a link:
	var optlinktarget=""
	//Set image border width
	var imgborderwidth=0
	//Optionally, change 1.0 and 0.7 below to affect Wipe gradient size and duration in seconds in IE5.5+:
	var filterstring="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"
	///////No need to edit beyond here/////
	if (preloadimg=="yes"){
		for (x=0; x<dynimages.length; x++){
			var myimage=new Image()
			myimage.src=dynimages[x][0]
		}
	}
	function returnimgcode(theimg){
		var imghtml=""
		if (theimg[1]!="")
			imghtml='<a href="settingimages/'+theimg[1]+'" target="'+optlinktarget+'">'
			imghtml+='<img src="settingimages/'+theimg[0]+'" width="300" height="300" border="'+imgborderwidth+'">'
			if (theimg[1]!="")
				imghtml+='</'+'a>'
		return imghtml
	}
	function modifyimage(loadarea, imgindex){
		if (document.getElementById){
			var imgobj=document.getElementById(loadarea)
			if (imgobj.filters && window.createPopup){
				imgobj.style.filter=filterstring
				imgobj.filters[0].Apply()
			}
			imgobj.innerHTML=returnimgcode(dynimages[imgindex])
			if (imgobj.filters && window.createPopup)
				imgobj.filters[0].Play()
				return false
		}
	}
	function add_cart(id)      {
		var submit_form = "yes";
		if( document.add_cart_form.item_size.value    == "0" ){
			alert("Please Select Ring Size!");
			submit_form = "no";
		}
		//alert(submit_form);
		if( submit_form == "yes" ) {
			//alert("GO!");
			document.add_cart_form.item_id.value = id;
			document.add_cart_form.action.value = "design02.php";
			//document.add_cart_form.submit();
			return true;
		}
		return false;
	}
 }
 if(location.href.indexOf('design03.php')>=0){
 //do nothing
 } 
 if(location.href.indexOf('design05.php')>=0){
	function sellay0(num){
		for(var id = 1;id<=3;id++){
			var ss="tlist"+id;
			if(id==num) 
				document.getElementById(ss).style.display="block";
			else  
				document.getElementById(ss).style.display="none";
		}
		for(var id = 1;id<=3;id++){ 
			var bb="ltitle"+id; 
			if(id==num)        
				document.getElementById(bb).className="active"; 
			else     
				document.getElementById(bb).className="";   
		}  
	}
	/***********************************************
	* Image Thumbnail Viewer II script- ?Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
	* This notice must stay intact for legal use
	***********************************************/
	//Specify image paths and optional link (set link to "" for no link):
	//var dynimages=new Array()
	//dynimages[1]=["../images/1.jpg", ""]
	//dynimages[2]=["../images/2.jpg", ""] 
	//dynimages[3]=["../images/3.jpg", ""]  
	//
	//dynimages[4]=["../images/4.jpg", ""] 
	//dynimages[5]=["../images/5.jpg", ""] 
	//Preload images ("yes" or "no"):  
	var preloadimg="no"    
	//Set optional link target to be added to all images with a link: 
	var optlinktarget=""  
	//Set image border width
	var imgborderwidth=0     
	//Optionally, change 1.0 and 0.7 below to affect Wipe gradient size and duration in seconds in IE5.5+:
	var filterstring="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"
	///////No need to edit beyond here///// 
	if (preloadimg=="yes"){   
		for (x=0; x<dynimages.length; x++){  
			var myimage=new Image() 
			myimage.src=dynimages[x][0] 
		}
	}
	function returnimgcode(theimg){ 
		var imghtml="" 
		if (theimg[1]!="") 
			imghtml='<a href="'+theimg[1]+'" target="'+optlinktarget+'">' 
		imghtml+='<img src="settingimages/'+theimg[0]+'" width="320" height="240" border="'+imgborderwidth+'">' 
		if (theimg[1]!="")
			imghtml+='</'+'a>' 
		return imghtml
	}
	function modifyimage(loadarea, imgindex){
		if (document.getElementById){
			var imgobj=document.getElementById(loadarea) 
			if (imgobj.filters && window.createPopup){
				imgobj.style.filter=filterstring 
				imgobj.filters[0].Apply()
			}  
			imgobj.innerHTML=returnimgcode(dynimages[imgindex])    
			if (imgobj.filters && window.createPopup) 
				imgobj.filters[0].Play()   
			return false 
		}  
	} 
	//var dynimages=new Array()
	//dynimages[1]=["images/image02.jpg", ""];
	//dynimages[2]=["images/image03.jpg", ""]; 
	//dynimages[3]=["images/image04.jpg", ""];  
	function add_cart(id){ 
		var submit_form = "yes";  
		if( document.add_cart_form.item_size.value    == "0" ) {
			alert("Please Select Ring Size!"); submit_form = "no";
		}
		if( submit_form == "yes" ) {
			//document.add_cart_form.item_id.value = id; 
			document.add_cart_form.action.value = "design05.php"; 
			return true;
		} 
		return false;
	}
 }
 function requiredCheck(){
	 //alert("Required Check");
	 return validate_product_form();
 }
 function rateIt(w,h)
 {
    var objBody = $$('body')[0];
 	
 	var closediv = '</div>';
 	
 	var divwidth = w;
 	var divheight = h;

 	var window_width = get_document_window_width();
    var width = convert_width(divwidth,window_width);
    var window_height = get_document_window_height();
    var height = convert_height(divheight,window_height);
    var mleft = calculate_left(width,window_width);
    var mtop = calculate_top(height,window_height);
 		
 	ptop = 200+"px";
 	pleft = mleft+"px"; 
 	 st = "display:none;z-index:10;width:"+w+"px;height:"+h+"px;top:"+ptop+";left:"+pleft;
 	popup = new Element('div', {id:"rateit",style:st});	
 	popup.className     = "details_cont";
 	
 	popup_header = new Element('div',{style:"text-align:right;width:"+w+"px;"})
 	popup_header.className = "details_header";
 	popup_header.insert('<img src="images/buttons/close-gold.gif" onClick="$(\'rateit\').hide();" style="cursor:pointer;" alt="Close" border="0">');
 		
 	popup_content = new Element('div',{style:"text-align:right;width:"+(w-5)+"px;height:"+(h-20)+"px;"})
 	popup_content.className = "details_content";
 	
 	var rateit = "<iframe id=\"rateitframe\" name=\"rateitframe\" width=\""+(w-5)+"px\" height=\""+(h-20)+"px\" frameborder=\"0\"";
 	rateit += "scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://www.ratepoint.com/profile/29707\"></iframe>";
    popup_content.insert(rateit);
  
 	popup.insert(popup_header);
 	popup.insert(popup_content);
    
 	
 	//objBody.insert(rateit);
 	objBody.insert(popup);
 	$('rateit').absolutize();
    $('rateit').show();
 }
