function openLookbook(url, winname, width, height) {popupWin = window.open(url, winname, 'resizable=no,width=' + width + ',height=' + height);}
function openJPEGPreview(url, winname, width, height) {popupWin = window.open(url, winname, 'resizable=yes,width=' + width + ',height=' + height);}
function openVideoPreview(url, winname, width, height) {popupWin = window.open(url, winname, 'resizable=no,scrollbars=no,width=' + width + ',height=' + height);}
function updateAdd()
{	var formElement = document.forms["AddItem"].elements["itemcontents"].value;
	var output = document.getElementById("output");
	output.innerHTML = formElement
}
function updateEdit()
{	var formElement = document.forms["EditItem"].elements["itemcontents"].value;
	var output = document.getElementById("output");
	output.innerHTML = formElement
}
function toggle_visibility(id) 
{	var e = document.getElementById(id);
	if(e.style.display == 'none')
		e.style.display = 'block';
	else
		e.style.display = 'none';
}

function GetShoesFlash() {
	popupWin = window.open('/pressroom/macys/macys150/shoes.htm', 'shoes_macys150', 'scrollbars,resizable,width=638,height=450');
}

function GetTimelineFlash()
{
	popupWin = window.open('/pressroom/macys/macys150/timeline_interactive.htm', 'timeline_macys150', 'scrollbars,resizable,width=717,height=400');
}


function checkEnterOrSpace(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(window.event) { // IE
		characterCode = e.keyCode;
	} else if(e.which) { // Netscape/Firefox/Opera
		characterCode = e.which;
	}

	//if(e && e.which){ //if which property of event object is supported (NN4)
	//	e = e
	//	characterCode = e.which //character code is contained in NN4's which property
	//}
	//else{
	//	e = window.event;
	//	characterCode = e.keyCode //character code is contained in IE's keyCode property
	//}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		//document.forms[0].submit() //submit the form
		return true;
	} else if(characterCode == 32){
		return true;
	} else {
		return false;
	}
}

//Edit media kits and Add media kits js functions
function $(id) {
	return document.getElementById(id);
}
function toProperCase(s) {
  return s.toLowerCase().replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); });
}
function addOption(selectbox, value, text) {
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	
	try {
		selectbox.options.add(optn, null);
	} catch(ex) {
		selectbox.options.add(optn);
	}
}
function MoveCatLeft() {
	if ($('catright').selectedIndex != "-1") {
		addOption($('catleft'), $('catright').value, $('catright').options[$('catright').selectedIndex].text);
		$('catright').remove($('catright').selectedIndex);
	}
}
function MoveCatRight() {
	if ($('catleft').selectedIndex != "-1") {
		addOption($('catright'), $('catleft').value, $('catleft').options[$('catleft').selectedIndex].text);
		$('catleft').remove($('catleft').selectedIndex);
	}
}
function MoveRegionLeft() {
	if ($('regionsright').selectedIndex != "-1") {
		addOption($('regionsleft'), $('regionsright').value, $('regionsright').options[$('regionsright').selectedIndex].text);
		$('regionsright').remove($('regionsright').selectedIndex);
	}
}
function MoveRegionRight() {
	if ($('regionsleft').selectedIndex != "-1") {
		addOption($('regionsright'), $('regionsleft').value, $('regionsleft').options[$('regionsleft').selectedIndex].text);
		$('regionsleft').remove($('regionsleft').selectedIndex);
	}
}
function VarifyInput(form) {
	//select all the cat's to send
	if ($('catright').options.length > 0) {
		$('catright').multiple=true
		for (x = 0; x < $('catright').length; x++) {
			$('catright').options[x].selected = true
		}
	} else {
		alert("Please select a " + toProperCase($('catright').name))
		return false
	}
	
	if ($('regionsright').options.length > 0) {
		$('regionsright').multiple=true
		for (x = 0; x < $('regionsright').length; x++) {
			$('regionsright').options[x].selected = true
		}
	} else {
		alert("Please select a " + toProperCase($('regionsright').name))
		return false
	}
	
	for (var x = 0; x < form.elements.length; x++) {
		if (form.elements[x].className.indexOf("required") != -1) {
			if (form.elements[x].type == "text") {
				if (form.elements[x].value == "") {
					alert("Please enter a " + toProperCase(form.elements[x].name))
					return false
				}
			} else if (form.elements[x].type == "select-one") {
				if (form.elements[x].options.length == 0 || form.elements[x].selectedIndex == -1 || form.elements[x].options[form.elements[x].selectedIndex].text == "") {
					alert("Please select a " + toProperCase(form.elements[x].name))
					return false
				}
			}
		}
	}
	
	return true
}