// Set the following variable to 'false' to set the title
// of the item identified by the id.  Set it to 'true' to
// set the title of the first <p> tag inside that item
// instead.
var uglyParagraphPatch = true;
 
function toggleItems(ison,isoff) {
  if(ison != '')
  	document.getElementById(ison).style.display = 'none';
  if(isoff != '')
  	document.getElementById(isoff).style.display = 'block';
}

function unfoldList(theitem) {
   var item = document.getElementById(theitem);
   if((item.className == 'fold'))
      item.className = 'unfold';
   else
      item.className = 'fold';

   var label = getToggleListLabel(theitem, item.className);
	if(label != undefined) {
		if(uglyParagraphPatch) {
			var paras = item.getElementsByTagName("p");
			if(paras.length>0) {
				paras[0].title=label;
			}
		} else {
			item.title=label;
		}
	}
}

var toggleLists = {};
function setToggleListLabel(list, clazz, label) {
	var item = toggleLists[list];
	if(item == undefined) {
		toggleLists[list] = {};
	}
	toggleLists[list][clazz] = label;
}

function getToggleListLabel(list, clazz) {
	var label = undefined;
	if(toggleLists[list] != undefined) {
		label = toggleLists[list][clazz];
	}
	return label;
}

function initToggleListLabels(clazz) {
	for(var listId in toggleLists) {
		var item = document.getElementById(listId);
		var label = getToggleListLabel(listId, item.className);
		if(label != undefined) {
			if(uglyParagraphPatch) {
				var paras = item.getElementsByTagName("p");
				if(paras.length>0) {
					paras[0].title=label;
				}
			} else {
				item.title=label;
			}
		}
		if(clazz != undefined) {
			item.className=clazz;
		}
	}
}

function toggleOneItem(theitem) {
  if((document.getElementById(theitem).style.display == 'block') || (document.getElementById(theitem).style.display == -1))
    document.getElementById(theitem).style.display = 'none';
  else
    document.getElementById(theitem).style.display = 'block';
}

function toggleTwoItem(theitem1, theitem2) {
  if((document.getElementById(theitem1).style.display == 'none') || (document.getElementById(theitem1).style.display == -1))
  {
    document.getElementById(theitem1).style.display = 'block';
    document.getElementById(theitem2).style.display = 'none';    
  }
}

function toggleClass(theitem) {
  if((document.getElementById(theitem).className == 'close'))
    document.getElementById(theitem).className = 'open';
  else
    document.getElementById(theitem).className = 'close';
}

function changeClassName(theitem, NewclassName) {
  if((document.getElementById(theitem).className != NewclassName)) {
    document.getElementById(theitem).className = NewclassName;
  }
}

function enableSubmit(checkBoxID, buttonID) {
	if(document.getElementById(checkBoxID).checked == true) {
		document.getElementById(buttonID).disabled = false;
		changeClassName(buttonID,'alignRight enabled');
	}
	else {
		document.getElementById(buttonID).disabled = true;	
		changeClassName(buttonID,'alignRight disabled');	
	}	
}

var checkflag = "false";
function check(field) {
  if (checkflag == "false") {
    for (i = 0; i < field.length; i++) {
      field[i].checked = true;
    }
    checkflag = "true";
    return "Uncheck All";
    } else {
      for (i = 0; i < field.length; i++) {
      field[i].checked = false;
    }
    checkflag = "false";
    return "Check All"; }
}

var speed = 5;
var target = -3;

function yMove(objectID) {  
  var objMove = document.getElementById(objectID)
  
  if (parseInt(objMove.style.top) < target) {
    objMove.style.top=parseInt(objMove.style.top)+speed+"px"
    yMoveVar = setTimeout("yMove('"+objectID+"')",20)
  } else {
    clearTimeout(yMoveVar);
  }
}

var targetHide = -108;

function yHide(objectID) {  
  var objMove = document.getElementById(objectID)

  if (parseInt(objMove.style.top) > targetHide) {
    objMove.style.top=parseInt(objMove.style.top)-speed+"px"
    var yHideVar = setTimeout("yHide('"+objectID+"')",20)
  } else {
    clearTimeout(yHideVar);
  }
}

function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
	//alert(newW);
}
function setFlashHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";		
	//alert(newH);	
}
function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
	//alert(newW + '/' + newH);	
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}

function flashToUrl(url, method) {
	var method;
	if (!method) {
		location.href = url;
	} else if(method == '_blank') { // if flash movie set a variable _blank we open in a new window     
		window.open (url,'new','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes'+',width='+800+',height='+600+',left='+25+',top='+25);
	}
	sendModifiedOmniturePageName('flashlink');
}


function gotoSite(thisUrl, thisWidth,thisHeight,thisTop,thisLeft) {

     var url = '/shopping/popups/personal/leaving.jsp?url=' + thisUrl;
     optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=yes,scrollbars=yes');
     mainWin = window.open(url,'goExternal',optionString);

 }
 
 function rollover(obj){
	var src = "";
	if(document.getElementById(obj).src.indexOf('off')!=-1){
		src = document.getElementById(obj).src.replace('off','over');
	}else if(document.getElementById(obj).src.indexOf('over')!=-1){
		src = document.getElementById(obj).src.replace('over','off');
	}
	document.getElementById(obj).src = src;
}

function updateProgressBar(inputProgress){ 
	if (inputProgress < 100) {
		document.getElementById("progress_update").innerHTML = inputProgress + '%<span>uploaded</span>';
	}
	else if (inputProgress == 100) {
		document.getElementById("progress_update").innerHTML = inputProgress + '%<span>completed</span>';
	}

	document.getElementById("progress_bar").style.width = inputProgress + '%';
}

function updateIframeSrc(iframeName, source) {
	document.getElementById(iframeName).src = source;
}

function updateDiv(divName, content) {
	document.getElementById(divName).innerHTML = content;
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}

	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE==""){
		return "";
	}

	else{
		return TRIM_VALUE;
	}

} //End Function

 

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0){
		return"";
	}

	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}

		iTemp = iTemp-1;

	} //End While

	return strTemp;

} //End Function

 

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	
	if(v_length < 1){
		return"";
	}

	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){}
			else{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
	} //End While

	return strTemp;

} //End Function

function checkAll(checkboxName) {
	var el = document.getElementsByName(checkboxName);
	for(i=0;i<el.length;i++){
		el[i].checked = true;
	}
}

function uncheckAll(checkboxName) {
	var el = document.getElementsByName(checkboxName);
	for(i=0;i<el.length;i++){
		el[i].checked = false;
	}
}

function showWarning(msg, xtype, rtnFunctionName) {
	// xtype - if 1: there will be 2 buttons, cancel and ok, else it will be only ok

	// rtnFunctionName - will return true of false to the function name enter here
	// ie: if rtnFunctionName = 'myFunction', for the button cancel we will have onClick="myFunction(False)"
	//     if rtnFunctionName = 'myFunction', for the button ok we will have onClick="myFunction(True)"
	var content = '';
	content = '<p>' + msg + '</p><p>';

	// add the cancel button
	if (xtype == 1) {
		content += '<a href="javascript: return false;" class="lbAction" rel="deactivate"><input type="button" class="button" value="Cancel"';
		if (rtnFunctionName != null && rtnFunctionName != '' && rtnFunctionName != undefined && rtnFunctionName != false) {
			content += ' onClick="'+rtnFunctionName+'(false);"';
		}
		content += ' /></a>';
	}

	content += '<a href="javascript: return false;" class="lbAction" rel="deactivate"><input type="button" class="button" value="Ok"';

	if (xtype == 1)
		content += ' hspace="10"';

	content += '"';

	if (rtnFunctionName != '')
		content += ' onClick="'+rtnFunctionName+'(true);"';

	content += ' /></a>';

	content += '</p>';

	document.getElementById('msgWarning').innerHTML = content;
	document.frmWarning.reset();
}

function scriptPost(formName, page, params, newWindow){

        /*clear form first*/
        document.forms[formName].innerHTML = "";
        
        document.forms[formName].method='post';
        document.forms[formName].action= page;
        
        var allParams = params.split('&');
        
        for(i=0; i<allParams.length; i++){
            var itempair = allParams[i];
            var item = itempair.split('=');
        
            var currentElement = document.createElement("input");
            currentElement.setAttribute("type", "hidden");
            currentElement.setAttribute("name", item[0]);
            currentElement.setAttribute("id", item[0]);
            currentElement.setAttribute("value", item[1]);
            document.forms[formName].appendChild(currentElement);
        }        
        document.forms[formName].target='_self';
        if(newWindow)document.forms[formName].target="_blank";
    
        document.forms[formName].submit();
}
