
var position = 0 ;
var currentScreen = 1 ;

function move(dir,ammt,which){
	if (document.getElementById){

		if (which == "other_items"){
			total_screens = other_screens - 1;
		} else if (which == "promo_items"){
			total_screens = promo_screens - 1;
		} else if (which == "featured_items"){
			total_screens = featured_screens - 1;
		} else if (which == "best_sellers"){
			total_screens = best_sellers_screens - 1;
		} else if (which == "coll_items"){
			total_screens = coll_screens - 1;
		}

		if (dir == "left"){
			moveIt = position - 1;
		} else if (dir == "right"){
			moveIt = parseInt(position) + 1;
		} else {
			moveIt = dir;
		}

        if (!(moveIt < 0 || moveIt > total_screens)) {
			if (dir == "left") {
				if (position > 0) {
					moveAmmt = moveIt*ammt;
					position = moveIt;
					document.getElementById(which + '_content').style.left = '-' + moveAmmt + 'px';
				}
			} else if (dir == "right"){
				if (position < total_screens) {
					moveAmmt = moveIt*ammt;
					position = moveIt;
					document.getElementById(which + '_content').style.left = '-' + moveAmmt + 'px';
				}
			} else {
				moveAmmt = moveIt*ammt;
				position = moveIt;
				document.getElementById(which + '_content').style.left = '-' + moveAmmt + 'px';
			}
            // Highlight items viewed in nav bar
	        highlightNavButtonText(moveIt,which);
	    }
	}
}


function highlightNavButtonText(index,where) {
	if (document.getElementById){
		if (where == "other_items"){
			total_screens = other_screens - 1;
			clr = 'org';
		} else if (where == "promo_items"){
			total_screens = promo_screens - 1;
			clr = 'grn';
		} else if (where == "featured_items"){
			total_screens = featured_screens - 1;
			clr = 'org';
		}else if (where == "best_sellers"){
			total_screens = best_sellers_screens - 1;
			clr = 'org';
		} else if (where == "coll_items"){
			total_screens = coll_screens - 1;
			clr = 'grn';
		}
		
		for (var i = 0; i <= total_screens; i++){
		    if (index == i) {
		        document.anchors[where + '_' + index].style.color='#fff';
		    }
		    else {
			    document.anchors[where + '_' + i].style.color='#ffcc00';
			}
		}
    }
}



function setdots(dotimg,where){
	if (document.getElementById){
		if (where == "other_items"){
			total_screens = other_screens - 1;
			clr = 'org';

		} else if (where == "promo_items"){
			total_screens = promo_screens - 1;
			clr = 'grn';

		} else if (where == "featured_items"){
			total_screens = featured_screens - 1;
			clr = 'org';
		} else if (where == "coll_items"){
			total_screens = coll_screens - 1;
			clr = 'grn';
		}

		//howMany = total_screens;

		for (var i = 0; i <= total_screens; i++){
			document.images[where + '_' + i ].src='/rrs/img/module_scroll/' + clr + '_set_marker_off.gif';
		}
		document.images[where + '_' + dotimg ].src='/rrs/img/module_scroll/' + clr + '_set_marker_on.gif';
	}
}

function checkSCType() {
	var msg = document.submitOrder.chkoutMessage.value;
	var memberId = document.submitOrder.memberId.value;
	if(memberId == ""){
		alert(msg);
		return(false);
	}
	return(true);
}


function addMultipleProductsToCart() {

	 var cartValues = "";
   var numberForms = document.forms.length;
   var formIndex;
   var formName;
   var product;
   var sku;
   var qty;
   var is_checked;
   
   for (formIndex = 0; formIndex < numberForms; formIndex++) {
   		formName = document.forms[formIndex].id;
     
      if (formName.substring(0,14) == "addToCartForm_") {
	      product = document.forms[formIndex].productSelected.value;
	      sku = document.forms[formIndex].skuSelected.value;
	      qty = document.forms[formIndex].quantity.value;
	      is_checked = document.forms[formIndex].outfit_check.checked;
	      
	      if (qty == "") {
	      	qty = "1";
	      }

      	//alert(formName + " - " + is_checked + " - " + product + " - " + sku);
      	
      	if (sku != "" && is_checked == true) {
		      	cartValues = cartValues + document.forms[formIndex].productSelected.value + ":" + document.forms[formIndex].skuSelected.value + ":" + qty + ",";
  			}
  			
  			if (sku == "" && is_checked == true) {
  				alert("Please select a color/size");
					return(false);
  			}
      }
   }
		
  cartValues = cartValues.substring(0,cartValues.length-1);
	//alert("cartValues=" + cartValues);

	document.forms.multipleAddToCartForm.multipleSkuProductSelected.value = cartValues;    
	document.forms.multipleAddToCartForm2.multipleSkuProductSelected2.value = cartValues;  
}

function outfitSelect(product, form) {
	//alert("this is the outfit alert: " + product);
	//alert("this is the outfit alert: " + form.skuSelected.value);

	if (form.skuSelected.value == "" ) {
		form.outfit_check.checked=false;
	}
	else {
		form.outfit_check.checked=true;
	}
}



function outfitCheckbox(product, form) {
	if (form.outfit_check.checked == false) {
		//alert(form.skuSelected.value);
		form.skuSelected.selectedIndex = 0;
	}
}


function movescroll(dir,ammt,which){
	//alert(totalcontentlenth);
	if (document.getElementById){

		if (which == "other_items"){
			displaycell_width = parseInt(other_prodcell_widths * other_display_visible);
			totalcontentlenth = parseInt(total_other_products * other_prodcell_widths);
			totalscreens = parseInt(total_other_products/other_display_visible);
			clr = "org";
			screenAmt = other_screens;
			alert(screenAmt);

		}
		if (which == "promo_items"){
			displaycell_width = parseInt(reco_prodcell_widths * reco_display_visible);
			totalcontentlenth = parseInt(total_reco_products * reco_prodcell_widths);
			totalscreens = parseInt(total_reco_products/reco_display_visible);
			clr = "grn";
		}
		if (which == "featured_items"){
			displaycell_width = parseInt(feat_prodcell_widths * feat_display_visible);
			totalcontentlenth = parseInt(total_feat_products * feat_prodcell_widths - displaycell_width);
			totalscreens = parseInt(total_feat_products/feat_display_visible);
			clr = "org";
		}
		if (which == "coll_items"){
			displaycell_width = parseInt(coll_prodcell_widths * coll_display_visible);
			totalcontentlenth = parseInt(total_coll_products * coll_prodcell_widths - displaycell_width);
			totalscreens = parseInt(total_coll_products/coll_display_visible);
			clr = "grn";
		}


		if (dir == "left"){
			if (position  < totalcontentlenth){
				thenum = parseInt(position) + parseInt(displaycell_width);
				position = thenum;
				//alert('sets position to thenum = ' + position);
				document.getElementById(which + '_content').style.left = '-' + thenum + 'px';
				//position = position - increment;
			}
		} else if (dir == "right") {

			if (position > 0){
				//alert('in here ' + position + '  and  ' + totalcontentlenth);
				thenum = parseInt(position) - parseInt(displaycell_width);
				//thenum = parseInt(position)+increment+vlinewidth;
				position = thenum;
				document.getElementById(which + '_content').style.left = '-' + thenum + 'px';
			}
			//alert('position = ' +position + ' and totalcontentlenth = ' + totalcontentlenth);
		} else {

			movetohere = parseInt(dir * displaycell_width);
			document.getElementById(which + '_content').style.left = '-' + movetohere + 'px';
			position = movetohere;

			for (var i = 0; i < totalscreens; i++){
				document.images[which +'_' + i ].src='/rrs/img/module_scroll/' + clr + '_set_marker_off.gif';
			}
			document.images[which +'_' + dir ].src='/rrs/img/module_scroll/' + clr + '_set_marker_on.gif';
		}
	}
}


function producttabs(whichtab){

	var howmanytab = tabs.length

	if (document.getElementById){

		for (var i = 0; i < howmanytab; i++){
			whichone = tabs[i];

				//change title tabs to off
				document.getElementById(whichone).className = 'prod_tab_off';
				//hide content tabs
				document.getElementById('prod_tab_' + whichone).style.display='none';
			}
			//change selected title tabs to on
			document.getElementById(whichtab).className = 'prod_tab_on';
			//show active content tab
			document.getElementById('prod_tab_' + whichtab).style.display='block';
		}
}


function showTab(){
	theUrl = location.search.substring(1);
	if (theUrl.match("tab=reviews")){
		producttabs('reviews')
	}
}


// home page scrolling
var brandsposition = 0;

function movebrands(ammt,which,dir){
	brandslength = totalbrands * indbrandswidth;
	brandsendposition = -parseInt(brandslength - brandswidth);

	if (document.getElementById){
	    //alert("totalbrands: '" + totalbrands + "'  indbrandswidth: '" + indbrandswidth + "'");
        //alert("brandslength: '" + brandslength + "'  brandsposition: '" + brandsposition + "'  brandsendposition: '" + brandsendposition + "'  (brandsposition * 5): '" + (brandsposition * 5) + "'");
		if (dir == 'left'){
			if ((brandsposition * 5) > (brandslength * -1)){
				thenum = parseInt(brandsposition) - ammt;
				brandsposition = thenum;
				//alert("brandsposition: '" + brandsposition + "''");
				document.getElementById(which + '_content').style.left = thenum + 'px';
			}
		}
		if (dir == 'right'){
			if (brandsposition < 0){
				thenum = parseInt(brandsposition)+ammt;
				brandsposition = thenum;
				document.getElementById(which + '_content').style.left = thenum + 'px';
			}
		}
	}
}


function rollon(name,src){
	document.images[name].src = src;
}

function rolloff(name,src){
	document.images[name].src = src;
}



/*
function moveleft(ammt,which){
	thenum = parseInt(position)-ammt;
	position = thenum;
	document.getElementById(which + '_content').style.left = thenum + 'px';
}

function moveright(ammt,which){
	thenum = parseInt(position)+ammt;
	position = thenum;
	document.getElementById(which + '_content').style.left = thenum + 'px';
}
*/

function clickUpdateButton(){
	//document.getElementByName(name).value = true;
    document.getElementById('updatebutton').click();
}


function changeshippingbilling(){

    if (document.forms.shoppingCart.creditcards) {
		document.getElementById('suc').value = (document.getElementById('suc').value).substring(0,document.getElementById('suc').value.indexOf("?")) + "?address=" + escape(document.forms.shoppingCart.addresses.value) +  "&cc=" + escape(document.forms.shoppingCart.creditcards.value);
		document.getElementById('updatebutton').click();
	} else {
		document.getElementById('suc').value = (document.getElementById('suc').value).substring(0,document.getElementById('suc').value.indexOf("?")) + "?address=" + escape(document.forms.shoppingCart.addresses.value);
		document.getElementById('updatebutton').click();
	}
}


function logout(){
	document.forms.logoutform.submit();
}


function hidepasswordinfo(from){
	if (document.getElementById){
		document.getElementById('passwordinfo').style.display='none';
	}
		
}
function showpasswordinfo(from){
	if (document.getElementById){
		document.getElementById('passwordinfo').style.display='block';
	}
		
}

function hidebillinginfo(from){
	if (document.getElementById){
		
		if (from != "checkout"){
			if (document.forms.register.billToShippingAddress.checked == true){
					document.getElementById('billinginfo').style.display='none';
				} else {
					document.getElementById('billinginfo').style.display='block';
				}
			} else {
				if (document.forms.register.addressKey.value == ""){
					document.getElementById('billinginfo').style.display='block';
				} else {
					document.getElementById('billinginfo').style.display='none';
				}
			}
		}
}

function billingmessage(state){
	if (document.getElementById){
	   if (document.forms.register.billToShippingAddress.checked == true){
			document.getElementById('billingmessage').style.display='block';
	   } else {
			document.getElementById('billingmessage').style.display='none';
	   }
   }
}

function populatephone(which){
   
	if (which == 's_') {
        phone_1 = document.forms.register.s_phone_1.value;
		phone_2 = document.forms.register.s_phone_2.value;
		phone_3 = document.forms.register.s_phone_3.value;
		phone_ext = document.forms.register.s_phone_ext.value;

        phoneString = phone_1 + '-' + phone_2 + '-' + phone_3;

        if(phone_ext) {
            phoneString += "x" + phone_ext;
        }

        document.forms.register.s_phoneNumber.value = phoneString;
	} else if (which == 'b_') {

		phone_1 = document.forms.register.b_phone_1.value;
		phone_2 = document.forms.register.b_phone_2.value;
		phone_3 = document.forms.register.b_phone_3.value;
		phone_ext = document.forms.register.b_phone_ext.value;

        phoneString = phone_1 + '-' + phone_2 + '-' + phone_3;

        if(phone_ext) {
            phoneString += "x" + phone_ext;
        }

        document.forms.register.b_phoneNumber.value = phoneString;
	}
}

function convertPhone(which){
	if (which == 's_') {
		theStr = document.forms.register.s_phoneNumber.value;
		cleanStr = theStr.replace(/-/g,"")
        cleanStr = cleanStr.replace(/x/g, "")

        area = cleanStr.substring(0,3);
		pre = cleanStr.substring(3,6);
		num = cleanStr.substring(6,10);
		ext = cleanStr.substring(10,29);

		document.forms.register.s_phone_1.value = area;
		document.forms.register.s_phone_2.value = pre;
		document.forms.register.s_phone_3.value = num;
		document.forms.register.s_phone_ext.value = ext;

	} else if (which == 'b_') {

		theStr = document.forms.register.b_phoneNumber.value;
		cleanStr = theStr.replace(/-/g,"")
        cleanStr = cleanStr.replace(/x/g, "")

        area = cleanStr.substring(0,3);
		pre = cleanStr.substring(3,6);
		num = cleanStr.substring(6,10);
		ext = cleanStr.substring(10,29);

		document.forms.register.b_phone_1.value = area;
		document.forms.register.b_phone_2.value = pre;
		document.forms.register.b_phone_3.value = num;
		document.forms.register.b_phone_ext.value = ext;

	}
}

function addReview(doWhat){
	if (document.getElementById){
		if (doWhat == 'showform'){
			document.getElementById('reviewLink').style.display='none';
			document.getElementById('reviewForm').style.display='block';
		} else {
			document.getElementById('reviewLink').style.display='block';
			document.getElementById('reviewForm').style.display='none';
		}
	}
}

function showReviewTabWithForm(){
   var howmanytab = tabs.length;
    
	if (document.getElementById){

		for (var i = 0; i < howmanytab; i++){
			whichone = tabs[i];

				//change title tabs to off
				document.getElementById(whichone).className = 'prod_tab_off';
				//hide content tabs
				document.getElementById('prod_tab_' + whichone).style.display='none';
			}
			//change selected title tabs to on
			document.getElementById('reviews').className = 'prod_tab_on';
			//show active content tab
			document.getElementById('prod_tab_reviews').style.display='block';
		}
   document.getElementById('reviewLink').style.display='none';
   document.getElementById('reviewForm').style.display='block';
}

function contactform(){
	var howmanytext = contactOptions.length

	if (document.getElementById){
		for (var i = 0; i < howmanytext; i++){
			whichtext = contactOptions[i];
				//hide text
				document.getElementById(whichtext + '_text').style.display='none';
			}

			//show selected text
			display = document.forms.contactForm.type.value + '_text' ;
			document.getElementById(display).style.display='block';

			//show/hide form elements
			if (document.forms.contactForm.type.value == 'Orders'){
				document.getElementById('orders_fields').style.display='block';
				document.getElementById('club_fields').style.display='none';
				document.getElementById('catalog_fields').style.display='none';

			} else if (document.forms.contactForm.type.value == 'Club'){
				document.getElementById('club_fields').style.display='block';
				document.getElementById('orders_fields').style.display='none';
				document.getElementById('catalog_fields').style.display='none';

			} else if (document.forms.contactForm.type.value == 'Catalog'){
			    document.getElementById('catalog_fields').style.display='block';
				document.getElementById('club_fields').style.display='none';
				document.getElementById('orders_fields').style.display='none';

			} else {
				document.getElementById('club_fields').style.display='none';
				document.getElementById('orders_fields').style.display='none';
				document.getElementById('catalog_fields').style.display='none';
				document.getElementById('WomanInMotion_fields').style.display='none';

			}
	}
}

function openContentWin(page){
	window.open(page,'contentWin',"height=500,width=525,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=200,left=300");
}

function openContentWin2(page, width, height){
	window.open(page,'contentWin',"height=" + height + ",width=" + width + ",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=200,left=300");
}


function openContentWinWithSizing(page, width, height){
	window.open(page, 'contentWin', "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, location=no, scrollbars=no, top=200, left=300");
}


function isMember(){
	
	password = document.forms.register.password.value;
	confirmPassword = document.forms.register.passwordConfirm.value;
	if(password.length == 0  && confirmPassword == 0){
		document.forms.register.member.value = false;
		document.forms.register.confirmPassword.value = false;
	
	}
	
}