
// This function creates an expanded text area for a smaller text
// area. A popup window with a large text area is created and as the
// user types, the contents of the large text area are copied to the
// smaller text area.
//


function expandedTextArea(name, textArea, initialValue)
{
    newwin = window.open('','','top=20,left=50,width=740,height=610');
    if (!newwin.opener) newwin.opener = self;
    with (newwin.document)
    {
        open();
        write('<html><head><title>' + name + '</title>');
        write('<link rel="stylesheet" type="text/css" href="/v2.0-img/images/NewUI/CSS/Style.css">');
        write('<style type="text/css">');
        write('body	{ margin: 0px; }');
        write('.foo { border: 1px #068ad2 solid; width: 650px; height: 350px; overflow: auto; padding: 3px; font-size: 11px; color: #000; letter-spacing: .06em; font-family: Verdana, Sans-Serif; }');
        write('.helpBorder { border-left: 1px #068ad2 solid; border-right: 1px #068ad2 solid; }');
        write('</style></head>');
		  write('<body><form name="LayoutForm"><table align="center" width="700" cellspacing="0" cellpadding="0" class="helpBorder">');
        write('<tr><td class="headerColor" align="left"><img src="/v2.0-img/images/NewUI/expandedPopUpHeader.jpg" alt="Digital River Command Console" width="700" height="66" border="0" /></td></tr>');
		  write('<tr><td class="topNoMenu"><a class="help" href="javascript:window.close();">close window</a> </td></tr>');
		  write('<tr><td align="center"><br>You may enter your <b>' + name + '</b> here and it will be copied into the form for you.</td></tr>');
        write('<tr><td align="center"><br><textarea class="foo" name="box" onKeyUp=' + textArea + '.value=this.value;>' + initialValue + '</textarea></td></tr>');
        write('<tr><td align="center"><br><input type="button" class="submit" value="update" onClick="window.close();"/></td></tr>');
        write('<tr><td class="copyright">&#169; Digital River, Inc.</td></tr>');
        write('</table></form></body></html>');
        close();
    }
}

// counts # of characters in a field
// shows character count on the ui
// and alerts when user has reached the maxlength
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
		alert('you have entered the maximum number of characters for this field');
	}
	else {
		//countfield.value = maxlimit - field.value.length;
		countfield.value = field.value.length;
	}
}

// Opens the "expanded text" pop-up window
function expandedCount(name, textAreaID, initialValue, counterID, initialLength, maxLength) {
   var expTextWin = self.open('//www.digitalriver.com/v2.0-img/images/NewUI/expandedCount.html?name=' + name + '&textAreaID=' + textAreaID + '&counterID=' + counterID + '&initialLength=' + initialLength + '&maxLength=' + maxLength,'EXPANDED_TEXT','top=20,left=50,width=740,height=610');
   expTextWin.focus();
}

// Opens the "expanded text" pop-up window
function htmlPreview(textAreaID, name) {
   var expTextWin = self.open('//www.digitalriver.com/v2.0-img/images/NewUI/previewHTML.html?name=' + name + '&textAreaID=' + textAreaID,'EXPANDED_TEXT','top=20,left=50,width=740,height=610');
   expTextWin.focus();
}

