/* Validation for converting the special charecters to ascii charecters */
function encodeString(field) {
var encodeString = "";
for(i=0; i<field.length; i++) {
var strChar = field.substring(i,i+1);
var convertAsciiValue = escape(strChar);
encodeString = encodeString + convertAsciiValue;
}
return encodeString;
}


/* Validation for converting the ascii charecters to special charecters */
function decodeString(field){
var decodeString = "";
for(i=0; i<field.length; i++) {
var strChar = field.substring(i,i+1);
if(strChar != "%"){
decodeString = decodeString + strChar;
}else {
var asciiValue = field.substring(i,i+3);
var convertAsciiValue = unescape(asciiValue);
decodeString = decodeString + convertAsciiValue;
i = i + 2;
}
}
return decodeString;
}


/* Validation for RemarketingInfo */
function remarketingInfo(formName,display){
for (var i=0; i<eval('document.'+ formName + '.elements.length'); i++){
if( eval('document.'+ formName + '.elements[i].name=="remInfo"') ){
if(eval('document.'+ formName + '.remInfo.checked == true') ){
eval('document.'+ formName + '.remInfoFlag.value = "1"');
}else{
eval('document.'+ formName + '.remInfoFlag.value = "0"');
}
if(display == "show"){
document.myform.remInfoFlag.value = document.remarketingForm.remInfoFlag.value;
}
}
}
}


/* replace bad ascii characters with a blank */
function replaceBadAscii(tempValue){
var newValue = tempValue;

var dynstr = '';
for (i=0;i<badascii.length;i++) {
 if ( i!=0) {
dynstr = dynstr + ' || ' + '(ch.charCodeAt(0) == badascii['+i+'])';
 }else{
dynstr = '(ch.charCodeAt(0) > badascii['+i+'])';
 }
}

for (i=0;i<tempValue.length;i++) {
ch = tempValue.substring(i,i+1);
if(eval(dynstr)){
newValue = newValue.replace(ch, "");
}
}
return newValue;
}


/* This function can be called by configurable text or PMA text to open a pop-up window for any page.
 * It will have the dimensions of a support page.
 */
function openPopupPage(pageName) {
var fullURL = pageName + ".tmpl" + window.location.search; //creates the full URL to go to including query string
var features = "width=566,height=570,status=no,resizable=no,scrollbars=yes";

window.open(fullURL, "pop1", features);
}

/* This function can be called to open new window. */
function openNewWindow(pageURL, features) {
   window.open(pageURL, "newwindow", features);
}