var menuran = 0;
var menuRan2 = 0
var hideRan = 0;
var menuLink = 0;
var hideSubStop = 0;
selMenulink = "";

function moveElement(id, x, y)
{
  // move the element with id to x,y
  // where x,y are the horizontal
  // and vertical position in pixels
  var elm = null;
  if (d.getElementById)
  {
    // browser implements part of W3C DOM HTML
    // Gecko, Internet Explorer 5+, Opera 5+
    elm = d.getElementById(id);
  }
  else if (d.all)
  {
    // Interent Explorer 4 or Opera with IE user agent
    elm = d.all[id];
  }
  else if (d.layers)
  {
    // Navigator 4
    elm = d.layers[id];
  }
  if (!elm)
  {
    // browser not supported or element not found
  }
  else if (elm.style)
  {
    // browser implements part of W3C DOM Style
    // Gecko, Internet Explorer 4+, Opera 5+
    if (typeof(elm.style.left) == 'number')
    {
      // Opera 5/6 do not implement the standard correctly
      // and assume that elm.style.left and similar properties
      // are numbers.
      elm.style.left = x;
      elm.style.top  = y;
    }
    else
    {
      // Gecko/Internet Explorer 4+
      elm.style.left = x + 'px';
      elm.style.top  = y + 'px';
    }
  }
  else if (typeof(elm.left) == 'number')
  {
    // Navigator 4
    elm.left = x;
    elm.top  = y;
  }
}

function layermove(ident,l,t) {
d=document;
moveElement(ident, l, t);
}

function Dropdown(layer,left,top) {
hidesubmenu();
d=document
if (document.layers)
  {
    // Navigator 4
 moveElement(layer, left, top);
  }
	else {
	moveElement(layer, left+4, top+4)
	}
}

function Dropdown2(layer,left,top) {
hidesubmenu2() ;
hideRan = 1
d=document
if (document.layers)
  {
    // Navigator 4
 moveElement(layer, left, top);
  }
	else {
	moveElement(layer, left+4, top+4)
	}
}

function moveback(layer) {
d=document
moveElement(layer, -150, 106);
}

function timemove() {
menuran = 1
move=window.setTimeout("hidesubmenu();",100)
}

function timemove2() {
menuRan2 = 1 ;
hideRan = 0 ; 
selMenulink.className="menuReact"; 
move2=window.setTimeout("hidesubmenu2();",100)
}

function hidesubmenu() {
if (menuran == 1) {
window.clearTimeout(move); }
for (i in menus) {
moveback(menus[i].id); }
}

function hidesubmenu2() {
if (menuRan2 == 1) {
window.clearTimeout(move2); }
for (i in menus2) {
moveback(menus2[i].id); }
}

function keepMenu1() {
selMenulink.className="menuReact1"; 
window.clearTimeout(move); }

function preload() {
a1 = new Image(); a1.src = "Flower_button_light.jpg";
}

function preLoadShop() {
fileposcheck();
b1 = new Image(); b1.src = urlstem+"Shopping-cart_red.gif";
}

function preLoadArrow() {
c1 = new Image();
c1.src = "arrow_right.gif";
}

var urlstem="";

function fileposcheck() {
var ck=0;
var pos=0;
url = new String(window.location.href);
url = url.toUpperCase();
pos = url.indexOf("MARITAJEWELLERY");
pos2 = url.indexOf("/",pos);
pos3 = url.lastIndexOf("/");
if (pos3==pos2) {
urlstem="";
urlstemShort="";
ck=1; }
if (ck==0) {
pos4 = url.lastIndexOf("/",pos3-1);
if (pos4==pos2) {
urlstem="../";
urlstemShort="../";
ck=1; }}
if (ck==0) {
pos5 = url.lastIndexOf("/",pos4-1);
if (pos5==pos2) {
urlstem="../../";
urlstemShort="../../";
ck=1; }}
if (ck==0) {
pos6 = url.lastIndexOf("/",pos5-1);
if (pos6==pos2) {
urlstem="../../../";
urlstemShort="../../../";
}}}

function selectLink(sellink) {
sellink.className="menuReact1"; }

function leaveLink(sellink) {
sellink.className="menuReact"; }

function leaveLink2(sellink) {
selMenulink = sellink
selMenulink.className="menuReact"; }

//Format and print current date:

function showDate() {
var months = new Array(12);
months[0]="January";
months[1]="February";
months[2]="March";
months[3]="April";
months[4]="May";
months[5]="June";
months[6]="July";
months[7]="August";
months[8]="September";
months[9]="October";
months[10]="November";
months[11]="December";
var current_date = new Date();
month_value = current_date.getMonth();
day_value = current_date.getDate();
year_value = current_date.getFullYear();
document.write(months[month_value]+" "+day_value+" "+year_value);
}

//function to send to menu target even when not over text operates from onClick call:

function menuCellOver(target) {
window.open(target,"_top");
}

//function to create drop down menus specifying id, array containing data, width, height, left and top as hidden, left after making appear:

function NewDropDownMenu() {
fileposcheck();
for (i in menus) {
document.write ('<div id='+menus[i].id+' class="drop" style="border-width:1px; border-style:none; width:'+menus[i].wid+'px; height:'+menus[i].ht+'px; position:absolute; left:'+menus[i].lh+'px; top:'+menus[i].th+'px; z-index:1;" OnMouseOver= "Dropdown(\''+menus[i].id+'\','+menus[i].la+','+menus[i].th+')" OnMouseOut="timemove();"><table class="dropmenu" cellpadding="0" cellspacing="0" width="109" style="background:#F7E9F7">');
thisMenu = menus[i].mData;
for (var t=0; t<thisMenu.length; t++) { 
if (thisMenu[t].menuId=="") {
document.write ('<tr><td height="22" style="border-width:1; border-top-width:0; border-color:rgb(204,102,255); border-style:solid;" onMouseOver="selectLink(this)" onMouseOut="leaveLink(this)" onClick="menuCellOver(\''+urlstem+thisMenu[t].url+'\');"><p style="text-indent:'+thisMenu[t].indent+';"> ');
if (thisMenu[t].grey=="G") {
document.write ('<a style="color:#999999;" target="_top" href="'+urlstem+thisMenu[t].url+'">'); }
else {
document.write ('<a target="_top" href="'+urlstem+thisMenu[t].url+'">'); }
document.write (thisMenu[t].text+'</a></p></td></tr>'); }
else {
for (var g=0; g<thisMenu.length; g++) {
if (g == thisMenu[t].menuId) {
document.write ('<tr><td height="22" style="border-width:1; border-top-width:0; border-color:rgb(204,102,255); border-style:solid;" onMouseOver="selectLink(this); Dropdown2(\''+menus2[g].id+'\','+menus2[g].la+','+menus2[g].th+');" onMouseOut="leaveLink2(this); timemove2();"><p style="text-indent:'+thisMenu[t].indent+';">');
if (thisMenu[g].grey=="G") {
document.write ('<a style="color:#999999;"'); }
else {
document.write ('<a '); }
document.write ('target="_top" href="'+urlstem+thisMenu[t].url+'">'+thisMenu[t].text+'</a></p></td></tr>'); }
}}}
document.write ('</table></div>'); }}

function NewDropDownMenu2() {
fileposcheck();
for (i in menus2) {
document.write ('<div id='+menus2[i].id+' class="drop" style="border-width:1px; border-style:none; width:'+menus2[i].wid+'px; height:'+menus2[i].ht+'px; position:absolute; left:'+menus2[i].lh+'px; top:'+menus2[i].th+'px; z-index:1;" OnMouseOver= "keepMenu1(); Dropdown2(\''+menus2[i].id+'\','+menus2[i].la+','+menus2[i].th+')" OnMouseOut="timemove2(); timemove()"><table class="dropmenu" cellpadding="0" cellspacing="0" width="109" style="background:#F7E9F7">');
thisMenu2 = menus2[i].mData;
document.write ('<tr><td height="23" style="border-width:1; border-color:rgb(204,102,255); border-style:solid;" onMouseOver="selectLink(this)" onMouseOut="leaveLink(this)" onClick="menuCellOver(\''+urlstem+thisMenu2[0].url+'\');"><p style="text-indent:'+thisMenu2[0].indent+';">');
if (thisMenu2[0].grey=="G") {
document.write ('<a style="color:#999999;"'); }
else {
document.write ('<a '); }
document.write ('target="_top" href="'+urlstem+thisMenu2[0].url+'">'+thisMenu2[0].text+'</a></p></td></tr>'); 
for (var t=1; t<thisMenu2.length; t++) { 
document.write ('<tr><td height="22" style="border-width:1; border-top-width:0; border-color:rgb(204,102,255); border-style:solid;" onMouseOver="selectLink(this)" onMouseOut="leaveLink(this)" onClick="menuCellOver(\''+urlstem+thisMenu2[t].url+'\');"><p style="text-indent:'+thisMenu2[t].indent+';">');
if (thisMenu2[t].grey=="G") {
document.write ('<a style="color:#999999;"'); }
else {
document.write ('<a '); }
document.write ('target="_top" href="'+urlstem+thisMenu2[t].url+'">'+thisMenu2[t].text+'</a></p></td></tr>'); 
}
document.write ('</table></div>'); }}

function indexChange(img,link) {
	if (img!="") {
	fileposcheck();
	path1=urlstem+"Flower_button_light.jpg" ;
	document.getElementById(img).src=path1; }
	document.getElementById(link).className="indexChange"; 
	}

function indexChangeback(img,link) {
	if (img!="") {	
	fileposcheck();
	path2=urlstem+"Flower_button_normal.jpg";
	document.getElementById(img).src=path2; }
	document.getElementById(link).className="indexChangeBack"; 
	}

indexPhotos = new Array();
indexPhotos[0] = new Array("Index_photos/COEBF_index.jpg","Floral Collection: Large Lilac flower (COEBF)");
indexPhotos[1] = new Array("Index_photos/COERG_index.jpg","Floral Collection: 'Springtime' (COERG)");
indexPhotos[2] = new Array("Index_photos/Coral_VW_Br_index.jpg","Wild Collection: Coral Very Wild bracelet (MIR3c)");
indexPhotos[3] = new Array("Index_photos/F12_index.jpg","Floral Collection: 'Hello' (F12)");
indexPhotos[4] = new Array("Index_photos/FN8_index.jpg","Floral Collection: Green/Stone (FN8)");
indexPhotos[5] = new Array("Index_photos/P53.jpg","Pearl Collection: Polished Mother of Pearl necklace (P53)");
indexPhotos[6] = new Array("Index_photos/VW_Coral_index.jpg","Wild Collection: Very Wild Coral Necklace (MIR1c)");
indexPhotos[7] = new Array("Index_photos/VW_Ruby_red_index.jpg","Wild Collection: Very Wild Ruby Red Necklace (MIR1d)");
indexPhotos[8] = new Array("Index_photos/Bundle_index.jpg","Pearl Collection: 'Bundle' Pearl necklace & earrings (P18)");
indexPhotos[9] = new Array("Index_photos/FP19.jpg","Floral Collection: Brown Swirl necklace (FP19)");
indexPhotos[10] = new Array("Index_photos/FN7_index.jpg","Floral Collection: Acorn (FN7)");
indexPhotos[11] = new Array("Index_photos/FN35.jpg","Floral Collection: Cloverleaf (FN35)");
indexPhotos[12] = new Array("Index_photos/F7a.jpg","Floral Collection: Green Knome (F7a)");
indexPhotos[13] = new Array("Index_photos/P36.jpg","Pearl Collection: 'Queen Christina' necklace & earrings - P36");
indexPhotos[14] = new Array("Index_photos/MIR1a.jpg","Wild Collection: Honey Very Wild Necklace (MIR1a)");
indexPhotos[15] = new Array("Index_photos/FN39.jpg","Floral Collection: Pink Bouquet (FN39)");
indexPhotos[16] = new Array("Index_photos/FN44.jpg","Floral Collection: Cream Flower (FN44)");
indexPhotos[17] = new Array("Index_photos/F11.jpg","Floral Collection: Black Twisted Leaf (F11a)");
indexPhotos[18] = new Array("Index_photos/MIR1p.jpg","Wild Collection: Very Wild Blue/Green necklace (MIR1p)");
indexPhotos[19] = new Array("Index_photos/FP30b.jpg","Floral Collection: Black Cocoon necklace (FP30b)");
indexPhotos[20] = new Array("Index_photos/SW2.jpg","Wild Collection: Lime green special very wild necklace (SW2)");


function randomPhoto() {
num=Math.random();
photoLen=indexPhotos.length-1;
ranPhoto=num*photoLen;
randPhoto=Math.round(ranPhoto);
document.write ('<a target="_top" href="Collections/Collections.html" Title="Click here to see details of our jewellery collections"><img src="'+indexPhotos[randPhoto][0]+'" border="1"></a><p>'+indexPhotos[randPhoto][1]+'</p>');
}

//function to open the search page and encode the search query in the Url:

function sendToSearch() {
code = document.search_form.code_text.value;
code1=code.toUpperCase();
if (document.search_form.searchType[0].checked==true) {
locString="Search.html?code="+code1;
window.location.href=locString; }
if (document.search_form.searchType[1].checked==true) {
code2=code1.split(" ");
for (i in code2) {
if (i==0) {
locString=code2[0]; }
else {
locString=locString+"+"+code2[i]; }}
locString="Search.html?query="+locString;
top.location.href=locString; }
}

//function to open wholesale registration page

function regMain() {
top.location.href="w-sregistration.html";
}

//function to process password and log in:

function wsaccess() {
a = document.password_form.password.value;
b = "/ws_info.html";
c = "?index";
d = a+b+c;
top.location.href=d;
}

//function to set a cookie where a is the name and b is the value:

function setCookie(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=/";
}

//function to read from a cookie where 'name' is the cookie name= attribute:

function getCookie(name) { 
var result = "";
var myCookie = document.cookie;
var searchName = name+"=";
startpos=myCookie.indexOf(searchName);
if (startpos != -1) {
startpos=startpos+searchName.length;
endpos=myCookie.indexOf(";",startpos);
if (endpos==-1) endpos=myCookie.length;
result=unescape(myCookie.substring(startpos,endpos));
}
return result; }

//function to delete a cookie where 'name' is the cookie name= attribute:

function ClearCookie(name) {
  setCookie(name, "", -1);
}

function setPassCookie() {
a = "pass";
b = document.password_form.password.value;
setCookie(a,b,365);
}

function getPassCookie() {
document.password_form.password.value=getCookie("pass"); }

function extractReg(str,el) {
start=str.indexOf(el);
if (start != -1) {
end=str.indexOf(">",start);
start=start+el.length;
value=str.substring(start,end); }
else {
value = ""; }
return value; }

function welcome() {
details=getCookie("cust");
name=extractReg(details,"fn<");
name=name.toUpperCase();
document.write('back '+name);
}

//function to put a close window button into the terms and conditions popup page

function termsCloseWindow() {
if (window.location.hash=="#shopTerms") {
document.write ('<form NAME="Close_terms"><p align="right"><br><input type="button" value="Close window" onClick="window.close();"></p></form>'); }
else {
document.write ('<p>&nbsp;</p>'); }
}

function shopAdReveal() {
document.getElementById("orderAdvert").style.visibility="visible";
}

function shopAdHide() {
document.getElementById("orderAdvert").style.visibility="hidden";
}


