/*

SchoolCenter main library

*/

// functions that are redundant, they exist in this file and at least one other(proposals)
/*{{{ Type Checking */

isAlien = function(a) {
   return isObject(a) && (typeof a.constructor != 'function');
};
isArray = function(a) {
	return isObject(a) && (a.constructor == Array);
};
isBoolean = function(a) {
	return (typeof a == 'boolean');
};
isEmpty = function(o) {
	var i, v;
	if (isObject(o)) {
		for (i in o) {
			v = o[i];
			if (isUndefined(v) && isFunction(v)) {
				return false;
			}
		}
	}
	return true;
};
isNull = function(a) {
	return (typeof a == 'object') && !a;
};
isNumber = function(a) {
	return (typeof a == 'number') && isFinite(a);
};
isObject = function(a) {
	return (a && (typeof a == 'object')) || isFunction(a);
};
isString = function(a) {
	return (typeof a == 'string');
};
isUndefined = function(a) {
	return (typeof a == 'undefined');
};
isFunction = function(a) {
	return (typeof a == 'function');
};
/*}}}*/

toggle_Display = function(incObj, incSwitch, doReturn) {/*{{{*/
	var obj       = document.getElementById(incObj);
	var objSwitch = (incSwitch ? incSwitch : 'block');
	if (obj) {
		obj.style.display = (incSwitch ? (obj.style.display = objSwitch) : ((obj.style.display == objSwitch) ? 'none' : objSwitch));
		if (doReturn) {
			return obj.style.display;
		}
	}
};
/*}}}*/

toggle_Visibility = function(incObj, incSwitch) {/*{{{*/
	var obj       = document.getElementById(incObj);
	var objSwitch = (incSwitch ? incSwitch : 'visible');
	if (obj) {
		obj.style.visibility = ((obj.style.visibility == objSwitch) ? 'hidden' : objSwitch);
	}
};
/* }}} */

// non-dups
function CheckTextInput(thisCheck) {/*{{{*/
    var checkText   = new String(thisCheck.value);
    var regEx1      = /\"/g;
    checkText       = String(checkText.replace(regEx1, ''));
    thisCheck.value = checkText;
}/*}}}*/

function ShowThumb(cPicName, cPicAlt, nWidth, nHeight) {/*{{{*/
    if (nHeight > 450) {
        nHeight = 450;
    }
    if (nWidth > 815) {
        nWidth = 815;
    }

    remote = window.open(RootPath + 'page/thumb.php?sectiondetailid=' + nDetailID + '&timestamp=' + timeStamp + '&thumbname=' + cPicName + '&picalt=' + cPicAlt + '&width=' + nWidth, '_THUMBNAIL_', 'resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=1,menuBar=no,width=' + nWidth + ',height=' + nHeight + ',top=50,left=50');
    if (remote) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
                                    
    if (navigator.userAgent.indexOf('MSIE 3') == -1) {
        remote.focus();
    }
}/*}}}*/

function ShowOnlineUsers() {/*{{{*/
    remote = window.open(RootPath + 'admin/users.list.php?timestamp=' + timeStamp, 'CurrentUsers', 'resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=no,menuBar=no,width=300,height=275,top=150,left=150');
    if (remote) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
    if(navigator.userAgent.indexOf("MSIE 3") == -1)    {
        remote.focus();
    }
}/*}}}*/

function ShowDeleteWarning(cName, cMessage, cLink, cJS) {/*{{{*/
    var strError;
    if (cMessage) {
        strError = cMessage + '\n\n(This Cannot Be Undone)';
    }else {
        strError = 'Are you sure you wish to permanently delete this item?\n\n(This Cannot Be Undone)';
    }
    if (confirm(strError)) {
        if (cJS) {
            eval(cJS);
        } else {
            window.location.href = cLink + '&dodelete=deletebutton&timestamp=' + timeStamp;
        }
    }
}/*}}}*/

function ShowDeleteWarning_Dropdown() { /* {{{ */
	// 8.0 #117 - Framework: 4.3.8, Delete Page in Edit Drop Down Menu - changed by JacobS on May  6, 2008
	// function called when clicking the delete this page button in the edit menu.
	if (confirm('Are you sure you wish to permanently delete this item?\n\n(This Cannot Be Undone)')) {
		window.location.href = '?editdelete=' + nDetailID;
	}
} /* }}} */

function AddPicLink(PicID, theURL, formName) {/*{{{*/
    var theURL = (theURL) ? theURL : 'http://';
    strAddPicLink = escape(prompt('Enter a web address to link this picture to:', theURL));
    if (strAddPicLink != theURL && strAddPicLink != 'null') {
        if (formName) {
            strFormName = eval('document.' + formName);
            strFormName.record_piclink.value = strAddPicLink;
            strFormName.dosave.value = 'dosave';
            strFormName.submit();
        } else {
            strAddPicLink = (strAddPicLink) ? strAddPicLink : 'NULL';
            location.href = ThisURL + '?sectiondetailid=' + nDetailID + '&timestamp=' + timeStamp + '&go=' + jsGo + '&pagecat=' + jsCat + '&picid='+ PicID + '&addPicLink=' + strAddPicLink;
        }
    }
}/*}}}*/

function AddPicAlt(PicID, theAlt, formName) {/*{{{*/
    theAlt       = (theAlt) ? theAlt : '';
    strAddPicAlt = escape(prompt('Enter text to be associated with this picture to:', theAlt));
    if (strAddPicAlt != theAlt && strAddPicAlt != 'null') {
        if (formName) {
            strFormName = eval('document.' + formName);
            strFormName.record_picalt.value = strAddPicAlt;
            strFormName.dosave.value = 'dosave';
            strFormName.submit();
        }else {
            strAddPicAlt = (strAddPicAlt) ? strAddPicAlt : 'NULL';
            //location.href = ThisURL + '?sectiondetailid=' + nDetailID + '&timestamp=' + timeStamp + '&go=' + jsGo + '&pagecat=' + jsCat + '&picid=' + PicID + '&addPicAlt=' + strAddPicAlt;
			/***---#CorpTicket:44142  - Alt Tag Remains after Image Replaced - changed by chinmay on Aug 18, 2008----***/
			//Last Changed by JRM on Aug 29, 2008 - 44903 - Cannot edit image alt tags on homepages -- Changed to use scLocalImage instead of relative path
			 var url = scLocalImage + '/includes/functions.prototype.php';
			 var params= '?action=' + 'addImageAltTag'+'&sectiondetailid=' +  nDetailID + '&timestamp=' + timeStamp +'&go=' + jsGo+'&pagecat=' +  jsCat+'&picid=' +  PicID+'&addPicAlt=' + strAddPicAlt;
             var ajax = new Ajax.Request(url,
              {
                method: 'get', 
                parameters : params,
                onSuccess: function(transport){
                  location.href = ThisURL + '?sectiondetailid=' + nDetailID + '&timestamp=' + timeStamp + '&go=' + jsGo + '&pagecat=' + jsCat + '&picid=' + PicID ;
			    }, 
			    onFailure: function(){ alert('Failure: Unable to add image alt tag') }
			  }
			  );

			/***---------------------***/
        }
    }
}/*}}}*/

function ShowBuyWin(comID) {/*{{{*/
    remote = window.open(RootPath + 'page/buy.php?comid=' + comID + '&timestamp=' + timeStamp, 'BUY_COM_', 'resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=1,menuBar=no,width=300,height=450,top=100,left=100');
    if (remote) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
    if (navigator.userAgent.indexOf('MSIE 3') == -1) {
        remote.focus();
    }
}/*}}}*/

function PageSettings(thisDetail, backPage, openWidth, openHeight) {/*{{{*/
    showStatus = 0;
    cPass      = (backPage) ? backPage : settingsBackURL;
    remote     = window.open(RootPath + 'page/settings.php?sectiondetailid=' + thisDetail + '&windowWidth=' + openWidth + '&frompage=' + cPass, 'PageSettings', 'resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=' + showStatus + ',menuBar=no,width=' + ((openWidth && openWidth != 0) ? openWidth : 400) + ',height=' + ((openHeight && openHeight != 0) ? openHeight : 350) + ',top=50,left=50');
    //cPageName = RootPath + 'page/settings.php?sectiondetailid=' + thisDetail + '&windowWidth=' + openWidth + '&frompage=' + (backPage ? backPage : settingsBackURL);
    //EditWin.create(cPageName);
    
    // this isn't necessary anymore since we aren't using popup windows
    if (remote) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
    if (navigator.userAgent.indexOf("MSIE 3") == -1) {
        remote.focus();
    }
    
}/*}}}*/

function changeImages() {/*{{{*/
  if (document.images) {
      for (var i = 0;i < changeImages.arguments.length;i += 2) {
          document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
      }
  }
}/*}}}*/

function submitAdminForm(thisVal) {/*{{{*/
    with (document.adminForm) {
        switch (thisVal) {
            case 'viewmode' :
                viewmode.value = 'viewmode';
                break;
            case 'editmode' :
                editmode.value = 'editmode';
                break;
            case 'killadmin' :
                killadmin.value = 'killadmin';
                break;
            case 'siteoptions' :
                siteoptions.value = 'siteoptions';
                break;
        }
        submit();
    }
}/*}}}*/

function rollAdmin(imgID,imgRepl) {/*{{{*/
    if (document.images) {
        document.images[imgID].src = eval(imgRepl + '.src')
    }
}/*}}}*/

function showDetails(whereTo, itemID, sectionDetailID, bit_use_plain) {/*{{{*/
    var addOn = '';
    var sid   = sectionDetailID ? ('sectiondetailid=' + sectionDetailID) : '';
    var iid   = itemID ? ('itemID=' + itemID) : '';
    if (sid || iid) {
        append = (whereTo.indexOf('?') >= 0) ? '&' : '?';
        addOn  = (sid) ? (append + sid + ((iid) ? ('&' + iid) : '')) : (append + iid);
    }
    //#20969# #EJF#
    //detailWin = window.open(whereTo + addOn,'DetailView','width=500,height=300,screenY=25,screenX=25,top=25,left=25,resizable=1,scrollbars=0,menubar=0,location=0,status=0,toolbar=0,titlebar=0,alwaysRaised=1');
	if (bit_use_plain) {
		var bit_plain = true;
	} else {
		var bit_plain = false;
	}
	ShowEditWin(whereTo + addOn, 'DetailView', 700, 500, null, null, null, bit_plain);
	/*
	if (detailWin) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
	*/
}
// legacy callbacks
JS_showDetails = function(whereTo, itemID, sectionDetailID) { showDetails(whereTo, itemID, sectionDetailID, 1); }
/*}}}*/

function loadWizard(incDetailID) {/*{{{*/
    wiz = window.open(RootPath + 'page/wizard.php?sectiondetailid=' + incDetailID + '&frameType=index&indexType=primary','Wizard','resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=1,menuBar=no,width=550,height=400,top=50,left=50');
    if (wiz) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
    wiz.focus();
	
}
// legacy callbacks
JS_loadWizard = function(incDetailID) { loadWizard(incDetailID); }
/*}}}*/

function ShowChatWin(fromID, userID) {/*{{{*/
    chat = window.open(RootPath + 'page/chat.php?fromid=' + fromID + '&timestamp=' + timeStamp, '_CHATWIN_' + fromID + '_' + userID + '_', 'resizable=yes,scrollBars=yes,location=no,directories=no,toolbar=no,status=0,menuBar=no,width=450,height=350,top=50,left=50');
    if (chat) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
    if (navigator.userAgent.indexOf('MSIE 3') == -1) {
        chat.focus();
    }
}/*}}}*/

function DoLogOut() {/*{{{*/

	var str_logout_url = '';
	
	if (confirm('You are currently logged out.\n\n\nClick \'OK\' to log back in as another user.\n\nClick \'Cancel\' to return to the website.')) {
		str_logout_url = '&relog=1';
	}
	
	str_logout_url = ThisURL + '?killadmin=1' + str_logout_url;
	
	window.location = str_logout_url;
	
}/*}}}*/

function feePayLogout() {/*{{{*/
	//added by jasona on 4/15/09 ticket#48079 Anoka FeePay logout Modifications
	window.location = '../../../education/district/district.php?sectionid=10298&killadmin=1';
	
}/*}}}*/

function ChangeDrillDown() {/*{{{*/
    url = document.drillDown.urlSelect.options[document.drillDown.urlSelect.options.selectedIndex].value;
    location.href = url;
}/*}}}*/

function getPageXY(elm) {/*{{{*/
    var point = { x: 0, y: 0 };
    while (elm) {
        point.x += elm.offsetLeft;
        point.y += elm.offsetTop;
        elm = elm.offsetParent;
    }
    return point;
}/*}}}*/

function setPageXY(elm, x, y) {/*{{{*/
    var parentXY = {x: 0, y: 0 };
    if (elm.offsetParent) { parentXY = getPageXY(elm.offsetParent); }
    elm.style.left = (x - parentXY.x) + 'px';
    elm.style.top  = (y - parentXY.y) + 'px';
}/*}}}*/

function attach_addLink(elm) {/*{{{*/
    new_fs = document.createElement('fieldset');
    new_legend = document.createElement('legend');
    new_select = document.createElement('select');
    new_option1 = document.createElement('option');
    new_option2 = document.createElement('option');
    new_option3 = document.createElement('option');
    new_option4 = document.createElement('option');
    new_option5 = document.createElement('option');
    new_option6 = document.createElement('option');
    new_input1 = document.createElement('input');
    new_input2 = document.createElement('input');
    new_label = document.createElement('label');

    new_fs.style.display = 'none';
    new_fs.className = 'standard-01';

    new_legend.innerHTML = 'URL&nbsp;&nbsp;';
    
    new_close = document.createElement('a');
    new_close.setAttribute('href', 'javascript://');
    new_close.setAttribute('onclick', 'JS_attach_delLink(this)');
    new_close.style.color = '#000';
    new_close.style.textDecoration = 'none';
    new_close.innerHTML = '[X]';
    new_legend.appendChild(new_close);
    
    new_input1.className = 'textbox';
    new_input1.setAttribute('type', 'text');
    new_input1.setAttribute('size', '30');
    new_input2.setAttribute('type', 'checkbox');
    new_input2.setAttribute('value', '1');
    new_label.innerHTML = 'Open link in a new window.';

    new_option1.setAttribute('value', 'http://');
    new_option1.innerHTML = 'http://';
    new_option2.setAttribute('value', 'https://');
    new_option2.innerHTML = 'https://';
    new_option3.setAttribute('value', 'mailto:');
    new_option3.innerHTML = 'mailto:';
    new_option4.setAttribute('value', 'ftp://');
    new_option4.innerHTML = 'ftp://';
    new_option5.setAttribute('value', '/');
    new_option5.innerHTML = '/';
    new_option6.setAttribute('value', '\\');
    new_option6.innerHTML = '\\';

    new_select.appendChild(new_option1);
    new_select.appendChild(new_option2);
    new_select.appendChild(new_option3);
    new_select.appendChild(new_option4);
    new_select.appendChild(new_option5);
    new_select.appendChild(new_option6);
    
    new_fs.appendChild(new_legend);
    new_fs.appendChild(new_select);
    new_fs.appendChild(new_input1);
    new_fs.innerHTML += '<br />';
    new_fs.appendChild(new_input2);
    new_fs.appendChild(new_label);
    new_fs.innerHTML += '<br />';



    link = document.getElementById('attach_link');
    //new_br = document.createElement('br');
    //link.parentNode.insertBefore(new_br, elm.parentNode);
    link.parentNode.insertBefore(new_fs, elm.parentNode);

    new_fs.style.display = 'block';
	//top.EditWin.resize();
}
// legacy callbacks
JS_attach_addLink = function(elm) { attach_addLink(elm); }
/*}}}*/

function attach_addFile(elm) {/*{{{*/
	Element.setStyle($("edit-win-tab-attachments-container"), {'overflow':'none', 'height':'auto'});
	
    new_fs = document.createElement('fieldset');
    new_legend = document.createElement('legend');
    
    new_fs.style.display = 'none';
    
    new_legend.innerHTML = 'File&nbsp;&nbsp;';
    new_close = document.createElement('a');
    new_close.setAttribute('href', 'javascript://');
    new_close.setAttribute('onclick', 'JS_attach_delLink(this)');
    new_close.innerHTML = '[X]';
    new_close.style.color = '#000';
    new_close.style.textDecoration = 'none';
    new_legend.appendChild(new_close);

    new_a = document.createElement('a');
    //new_a.setAttribute('href', 'javascript://');
    new_a.setAttribute('href', 'javascript: AttachFile();');
    new_a.innerHTML = '<b>+</b> Add a File';
    new_fs.appendChild(new_legend);
    new_fs.appendChild(new_a);
    new_fs.innerHTML += '<br />';
    
    link = document.getElementById('attach_file');
    //new_br = document.createElement('br');
    //link.parentNode.insertBefore(new_br, elm.parentNode);
    link.parentNode.insertBefore(new_fs, elm.parentNode);

    new_fs.style.display = 'block';
	EditWin.resize();
}
// legacy callbacks
JS_attach_addFile = function(elm) { attach_addFile(elm); }
/*}}}*/

function attach_delLink(elm) {/*{{{*/
    if (confirm('Are you sure you wish to remove this item?\nThis can not be undone!')) {
        fs = elm.parentNode.parentNode;
        par = fs.parentNode;
        next_sib = fs.nextSibling;
        if (next_sib.nodeName == 'BR') {
            par.removeChild(next_sib);
        }
        par.removeChild(fs);
		//top.EditWin.resize();
    }
}
// legacy callbacks
JS_attach_delLink = function(elm) { attach_delLink(elm); }
/*}}}*/

function ShowEditWin(str_page_location, str_window_name, int_width, int_height, int_vertical_position, int_horizontal_position, bit_resize, bit_use_plain) {/*{{{*/
	// we need to user the nWinName as our EditWin title
	// go back through the code and mod all ShowEditWin()s
	// titles should be all caps split by underscores
    str_window_name    = (isUndefined(str_window_name) || isNull(str_window_name)) ? ('EDIT_WINDOW_' + timeStamp) : str_window_name;
	//EditWin.bit_resize = (isUndefined(bit_resize) || isNull(bit_resize)) ? 1 : bit_resize;

	if (bit_use_plain) {
		obj_opened_window = window.open(str_page_location, str_window_name, 'width=' + int_width + ', height=' + int_height + ', scrollbars=yes, resizable=yes');
	} else {
		obj_opened_window = EditWin.create(str_page_location, str_window_name, {'width':int_width, 'height':int_height, 'top':int_vertical_position, 'left':int_horizontal_position});
	}
	//alert(typeof obj_opened_window);
	if (!isObject(obj_opened_window)) {
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
	
}
function ShowEditWin_DEPRECATED(cPageName, nWinName, nScrollBars, nWidth, nHeight, nVertPos, nHoriPos, nStatus, nToolbar, nSizable, nExtras) {/*{{{*/
    nWinName    = (nWinName) ? nWinName : 'NEW_WINDOW_' + timeStamp;
    nWidth      = (nWidth) ? nWidth : 300;
    nHeight     = (nHeight) ? nHeight : 300;
    nScrollBars = (nScrollBars == 0) ? 'no' : 'yes';
    nVertPos    = (nVertPos) ? nVertPos : 20;
    nHoriPos    = (nHoriPos) ? nHoriPos : 20;
    nStatus     = (nStatus) ? nStatus : 0;
    nToolBar    = (nToolbar) ? 'yes' : 'no';
    nSizable    = (nSizable == 0) ? 'no' : 'yes';
    sOptions    = 'resizable=' + nSizable + ',scrollbars=' + nScrollBars + ',location=no,directories=no,toolbar=' + nToolbar + ',status=' + nStatus + ',menuBar=' + nToolbar+ ',width=' + nWidth + ',height=' + nHeight + ',top=' + nVertPos + ',left=' + nHoriPos;
	sOptions    = sOptions + (nExtras ? ',' + nExtras : '');
	obj = window.open(cPageName, nWinName, sOptions);
	
	if (obj) {
        var popUpsBlocked = false;
    } else {
        var popUpsBlocked = true;
        alert('SchoolCenter has detected that you are using pop-up blocking software.\nPlease enable pop-ups for this site.');
    }
}/*}}}*/
/*}}}*/

/* {{{ mecho */

var obj_mecho = new Object();
var obj_mechowin;

function mecho(str_out, str_who, bit_alert) {
	if (obj_mecho[str_who]) {
		if (bit_alert) {
			alert(str_out);
		} else {
			if (!obj_mechowin) {
				obj_mechowin = window.open("", "mechowin", "width=400,height=500,scrollbars=1");
				obj_mechowin.document.body.innerHTML = "";
			}
			obj_mechowin.document.body.innerHTML = str_out + "<br/>" + obj_mechowin.document.body.innerHTML;
		}
	}
}
/*}}}*/

// CorpTicket:49735 - Moving Ben's email validator function from userregistration to standard includes - changed by JacobS on Aug 19, 2009
function validateEmailAddress(str_email) { /* {{{ */
	for (var i = 0; i < str_email.length ; i++) {
		str_email = str_email.replace(" ", "");
		str_email = str_email.replace("\n", "");
	}
	var at_symbol = str_email.indexOf("@");
	var dot_symbol = str_email.lastIndexOf(".");
	var number_of_at = str_email.lastIndexOf("@");
	if (number_of_at != at_symbol) {
		return false;
	}
	if (dot_symbol != -1 && at_symbol != -1 && dot_symbol > at_symbol) {
		var arr_dot_split = str_email.split(".");
		var arr_at_split = str_email.split("@");
		if (arr_dot_split[(arr_dot_split.length - 1)].length <= 4 && arr_at_split[0].length > 0 && arr_at_split[1].length > 4) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
/* }}} */

 ////CorpTicket:44719 - Print Page link not working - changed by chinmay on Sept 04, 2008
/* modifyURL(obj_modify)*/
 //###CorpTicket:46367 - Print Form Removes Information- changed by chinmay on Dec 16, 2008
 //var modifyURL= function(obj_modify) {
 var modifyURL= function(obj_modify,int_comp_type,page_iteration) {/*{{{*/
	//CorpTicket:47900 - Post Submission Print Page Does Not Work - modified by chuckc on 4/3/2009
	//if this is the post submission page, ContactForm will not exist and will cause a JS error.
	//I'm checking to see if is the first page, but it may be better to check if it is any page but the last page.
    //if(int_comp_type == 30 || int_comp_type==13) {
    if( (int_comp_type == 30 || int_comp_type==13) && page_iteration == 1) {
      var str_added_field = getFormValue(document.ContactForm.elements);//alert(str_added_field);
	  if(page_iteration){
		  str_added_field+='<input type="hidden" name="page_iteration" value="'+page_iteration+'" />';
	  }
	  document.getElementById('printpage_form_value').innerHTML+=str_added_field; 
  
	}
 //###---------------------------------------- 

 str_location = location.href.toString();
 
     arr_location = str_location.split('?');
 
     str_base_url = arr_location[0];
 
     arr_location = arr_location[1].split('&');
 
     str_query_string = '';
 
     for (i = 0; i < arr_location.length; i++) {
          arr_tmp = arr_location[i].split('=');
 
          if (!isUndefined(obj_modify[arr_tmp[0]])) {
              str_query_string += arr_tmp[0] + '=' + obj_modify[arr_tmp[0]] + '&';
              obj_modify[arr_tmp[0]] = null;
          } else {
              str_query_string += arr_location[i] + '&';
          }
     }
 
     obj_modify = $H(obj_modify);
 
     obj_modify.each(function(arr_link) {
             if (arr_link[1] != null) {
                 str_query_string = arr_link[0] + '=' + arr_link[1] + '&' + str_query_string;
              }
          }
      );
     str_query_string = str_query_string.substring(0, (str_query_string.length - 1));
     str_location = str_base_url + '?' + str_query_string;
	 //location.href = str_location;
	       if(navigator.appVersion.indexOf("MSIE")> -1){
	          startplace=navigator.appVersion.indexOf("MSIE");
	          int_version=navigator.appVersion.substring(startplace+5,startplace+8);
	          if(int_version<=6.0){//for IE 6 as location.href won't work here
              //###CorpTicket:46367 - Print Form Removes Information- changed by chinmay on Dec 16, 2008
	            //window.open(str_location,'','resizable=no scrollbars=yes location=no menubar=no status=no titlebar=yes titlebar=yes toolbar=yes');
				//document.write('');
				window.event.returnValue=false; //Solve the location.href problem in IE 6
	            window.location=str_location;
              //###-----------------------------------------
	           }
	          else{ // For IE7
	            location.href = str_location;
	          }
	        }
	       else{ //for non IE browser
	          location.href = str_location;
	       }
     //###CorpTicket:46367 - Print Form Removes Information- changed by chinmay on Dec 16, 2008
      if(int_comp_type == 30 || int_comp_type==13){
	      document.printpagecontactform.submit();
      }
     //###------------------------------
   
}/*}}}*/
///-------------------------


//###CorpTicket:46367 - Print Form Removes Information- changed by chinmay on Dec 16, 2008
var getFormValue= function(obj_element) { /*{{{*/
	  if(!obj_element){
	    return;
	  }
	  var str_added_field = '';
	  for(var i=0;i<obj_element.length;i++){
	   switch(obj_element[i].type){
		case 'text':
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
		   break;
		case 'textarea':
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
           break; 
		case 'checkbox':
		    if (obj_element[i].checked == true){
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
			}
           break;  
		case 'radio':
			if (obj_element[i].checked == true){
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
			}
           break;  
		case 'select-one':
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
           break; 
        case 'select-multiple':
		   if (obj_element[i].checked == true){
				str_added_field+='<input type="hidden" name="'+obj_element[i].name+'" value="'+obj_element[i].value+'" />';
		   }
           break; 		   
		   
		}
	  }
	  return str_added_field;
}  /*}}}*/
///-------------------------
