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")) {
        if ($('catright').options.length > 0) {
            $('catright').multiple=true;
            for (x = 0; x < $('catright').length; x++) {
                $('catright').options[x].selected = true;
            }
        }
    }

    if ($("regionsright")) {	
        if ($('regionsright').options.length > 0) {
            $('regionsright').multiple=true;
            for (x = 0; x < $('regionsright').length; x++) {
                $('regionsright').options[x].selected = true;
            }
        }
    }
	
	return true;
}
function ShowCatRegionSelectIfPRItem(select) {
	if (select.value == 2) {
		if ($("catleftbox")) {	
			$("catleftbox").style.display = ""
			$("catrightbox").style.display = ""
			$("regionleftbox").style.display = ""
			$("regionrightbox").style.display = ""
		}
	} else {
		if ($("catleftbox")) {	
			$("catleftbox").style.display = "none"
			$("catrightbox").style.display = "none"
			$("regionleftbox").style.display = "none"
			$("regionrightbox").style.display = "none"
		}	
	}
	if (select.value == 4) {
		if ($("collectionlist")) {
			$("collectionlist").style.display = ""
		}
	} else {
		if ($("collectionlist")) {
			$("collectionlist").style.display = "none"
		}	
	}
}

function SelectAllKids() {
	if ($('kidslist').options.length > 0) {
		$('kidslist').multiple=true
		for (x = 0; x < $('kidslist').length; x++) {
			$('kidslist').options[x].selected = true
		}
	}
}

function MoveItemUp() {
    if ($('kidslist').selectedIndex == 0) {
        return;
    }

    tempv = $('kidslist').options[$('kidslist').selectedIndex - 1].value
    tempd = $('kidslist').options[$('kidslist').selectedIndex - 1].text

    $('kidslist').options[$('kidslist').selectedIndex - 1].value = $('kidslist').options[$('kidslist').selectedIndex].value
    $('kidslist').options[$('kidslist').selectedIndex - 1].text = $('kidslist').options[$('kidslist').selectedIndex].text

    $('kidslist').options[$('kidslist').selectedIndex].value = tempv
    $('kidslist').options[$('kidslist').selectedIndex].text = tempd
    
    $('kidslist').selectedIndex = $('kidslist').selectedIndex - 1
}

function MoveItemDown() {
    if ($('kidslist').selectedIndex == ($('kidslist').options.length - 1)) {
        return;
    }

    tempv = $('kidslist').options[$('kidslist').selectedIndex + 1].value
    tempd = $('kidslist').options[$('kidslist').selectedIndex + 1].text

    $('kidslist').options[$('kidslist').selectedIndex + 1].value = $('kidslist').options[$('kidslist').selectedIndex].value
    $('kidslist').options[$('kidslist').selectedIndex + 1].text = $('kidslist').options[$('kidslist').selectedIndex].text

    $('kidslist').options[$('kidslist').selectedIndex].value = tempv
    $('kidslist').options[$('kidslist').selectedIndex].text = tempd
    
    $('kidslist').selectedIndex = $('kidslist').selectedIndex + 1
}
