<!-- START -- Shopping Cart script -->

function writeItems() {
    var items = readCookies('scitems');
    if (items) {
        if (items == 1) { 
	        document.write( items + ' item in your bag' );
		} else {
		    document.write( items + ' items in your bag' );
		}
    } else {
	    document.write( '0 items in your bag' );
	}

}

function readCookies(name) {
	var cname = 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(cname) == 0) return c.substring(cname.length,c.length) ;
	}
}

<!-- END -- Shopping Cart script-->

<!-- START -- Rotate Landing page images and links-->

function rotateimglnks(type){

    // Home Links
	var homelinks = new Array(); var homeimgs = new Array();
	homelinks[0] = "/n/bs?q=swoon&x=0&y=0"; homeimgs[0] = "swoon_061509";
	homelinks[1] = "/n/bs?q=stretchup&x=0&y=0"; homeimgs[1] = "stretchup_061509";
	homelinks[2] = "/n/bs?q=gladly&x=0&y=0"; homeimgs[2] = "gladly_061509";

	// Shoes Links
	var shoelinks = new Array(); var shoeimgs = new Array();
	shoelinks[0] = "/n/bs?q=swoon&x=0&y=0"; shoeimgs[0] = "swoon_061509";
	shoelinks[1] = "/n/bs?q=stretchup&x=0&y=0"; shoeimgs[1] = "stretchup_061509";
	shoelinks[2] = "/n/bs?q=gladly&x=0&y=0"; shoeimgs[2] = "gladly_061509";
	
	// Handbags Links
	var hblinks = new Array(); var hbimgs = new Array();
	hblinks[0] = "/n/bs?q=clutchflap&x=0&y=0"; hbimgs[0] = "clutchflap_061509";
	
	// Kids Links
	var kidlinks = new Array(); var kidimgs = new Array();
	kidlinks[0] = "/kids.zhtml"; kidimgs[0] = "kids_070208";
    
	if (type == 'main'){
		var num = homelinks.length;
		var xarray = homelinks;
		var yarray = homeimgs;
	}
	if (type == 'shoesbg'){
		var num = shoelinks.length;
		var xarray = shoelinks;
		var yarray = shoeimgs;
	}
	if (type == 'handbagbg'){
		var num = hblinks.length;
		var xarray = hblinks;
		var yarray = hbimgs;
	}
	if (type == 'kidbg'){
		var num = kidlinks.length;
		var xarray = kidlinks;
		var yarray = kidimgs;
	}
    // Rotating images
    var el = document.getElementById(type + 'img');
    var rand = Math.floor(Math.random() * num);
	var swimg = yarray[rand];
    var mystr = "img/cobrand/stuartweitzman/sw_" + type + "_" + swimg + ".jpg";
    el.src = mystr;

    var anchorlink = document.getElementById(type + 'link');
    anchorlink.href = xarray[rand];
}

<!-- END -- Rotate Frontpage buttons -->


<!-- START -- locator.zhtml -- image slideshow-->

var interval = 19;
var numimages = 19;
var curimg = 0;
var nicebrowser = browsercheck();

var imgs = new Array(numimages);
imgs[0] = "/img/cobrand/stuartweitzman/newyork.jpg";
imgs[1] = "/img/cobrand/stuartweitzman/chicago.jpg";
imgs[2] = "/img/cobrand/stuartweitzman/beverlyhills.jpg";
imgs[3] = "/img/cobrand/stuartweitzman/houston.jpg";
imgs[4] = "/img/cobrand/stuartweitzman/lasvegas.jpg";
imgs[5] = "/img/cobrand/stuartweitzman/columbuscircle.jpg";
imgs[6] = "/img/cobrand/stuartweitzman/northpark.jpg";
imgs[7] = "/img/cobrand/stuartweitzman/israel.jpg";
imgs[8] = "/img/cobrand/stuartweitzman/rome.jpg";
imgs[9] = "/img/cobrand/stuartweitzman/atlanta.jpg";
imgs[10] = "/img/cobrand/stuartweitzman/sanfrancisco.jpg";
imgs[11] = "/img/cobrand/stuartweitzman/tysons.jpg";
imgs[12] = "/img/cobrand/stuartweitzman/kingofprussia.jpg";
imgs[13] = "/img/cobrand/stuartweitzman/sandiego.jpg";
imgs[14] = "/img/cobrand/stuartweitzman/naples.jpg";
imgs[15] = "/img/cobrand/stuartweitzman/zurich.jpg";
imgs[16] = "/img/cobrand/stuartweitzman/milan.jpg";
imgs[17] = "/img/cobrand/stuartweitzman/malaysia.jpg";
imgs[18] = "/img/cobrand/stuartweitzman/troy.jpg";
imgs[19] = "/img/cobrand/stuartweitzman/singapore.jpg";
var anchors = new Array(numimages);
anchors[0] = "#newyork";
anchors[1] = "#chicago";
anchors[2] = "#beverlyhills";
anchors[3] = "#houston";
anchors[4] = "#lasvegas";
anchors[5] = "#columbus";
anchors[6] = "#northpark";
anchors[7] = "#israel";
anchors[8] = "#rome";
anchors[9] = "#atlanta";
anchors[10] = "#sanfrancisco";
anchors[11] = "#tysons";
anchors[12] = "#kingofprussia";
anchors[13] = "#sandiego";
anchors[14] = "#naples";
anchors[15] = "#zurich";
anchors[16] = "#milan";
anchors[17] = "#malaysia";
anchors[18] = "#troy";
anchors[19] = "#singapore";

function doslide(){
var nicebrowser = browsercheck();
setInterval("nextSlide()",interval * 200);
}

function browsercheck() {
    if (document.images){
        return true;}
	else{
	    return false;}
    }


function loadSlide(imageURL){
    if (nicebrowser){
	    document.slide.src = imageURL;
		return false;
    } else {
		return true;
    }
	}
	
function nextSlide() {
    curimg = (curimg + 1) % numimages;
    loadSlide(imgs[curimg]);
	}

function gotoanchor(){
    window.location = "/storesnearyou.zhtml" + anchors[curimg];
}


<!-- END -- locator.zhtml -- image slideshow-->

function showmenu(elmnt){
	document.getElementById(elmnt).style.visibility="visible"}
function hidemenu(elmnt){
	document.getElementById(elmnt).style.visibility="hidden"}

<!-- Label hiding / Search Box Code -->

function initOverLabels () {
  if (!document.getElementById) return;  	

  var label, id, field;

  // Set focus and blur handlers to hide and show 
  label = document.getElementById('srchlbl');
  field = document.getElementById('srchnput');
	
      // Change the applied id to hover the label 
      // over the form field.
      label.id = 'srchoverlbl';

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to LABEL elements (for Safari).
      label.onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

  }

function hideLabel (field_id, hide) {
  var field_for;
  var label = document.getElementById('srchoverlbl');
 
  label.style.visibility = (hide) ? 'hidden' : 'visible';
  return true;
}


<!-- START Press Popups -->

function NewWindow(thepage,thename,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+''
	win = window.open(thepage,thename,settings);
	win.focus();
}

<!-- END Press Popups -->

<!-- START E-mail Signup Validation -->

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
Tlength=value.length

if (apos<1||dotpos-apos<2||Tlength-dotpos<2) 
  {alert(alerttxt);return false}
else {window.alert('Thank You!')}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false}
}
}

<!-- END E-mail Signup Validation -->

function selectedPage() {
  if (!document.getElementById("toplevel-nav")) return;
  var loc = window.location["pathname"];
  var anchors = document.getElementById("toplevel-nav").getElementsByTagName("a");

  for (i=0; i < anchors.length; i++) {
    var aHref = anchors[i].getAttribute("href");
    var dotCom = aHref.indexOf(".com") ? aHref.indexOf(".com") : aHref.indexOf(".net");
    var aHrefLoc = aHref.substr(dotCom + 4);

    if (aHrefLoc == loc) {
      if(anchors[i].parentNode.className == "unselected" || anchors[i].parentNode.className == "selectedpage") {
        anchors[i].parentNode.className = "selectedpage";
      } else {
        anchors[i].parentNode.className = "subselected";
        }
      break;
    }
  }
}
