you want to change
*
* @access public
* @return null
*/
function changeRowColor (rowid, form) {
switch (document.getElementById(rowid).className) {
case 'even-row' : document.getElementById(rowid).className = 'selected even-row';
break;
case 'odd-row' : document.getElementById(rowid).className = 'selected odd-row';
break;
case 'selected even-row' : document.getElementById(rowid).className = 'even-row';
break;
case 'selected odd-row' : document.getElementById(rowid).className = 'odd-row';
break;
case 'form-item' : document.getElementById(rowid).className = 'selected';
break;
case 'selected' : document.getElementById(rowid).className = 'form-item';
}
}
/**
* This function is to show the row with selected checkbox in different color
* @param form - name of form that checkboxes are part of
*
* @access public
* @return null
*/
function on_load_init_check(form)
{
for( i=0; i < document.forms[form].elements.length; i++) {
if ( ( document.forms[form].elements[i].type == 'checkbox'
&& document.forms[form].elements[i].checked == true )
|| ( document.forms[form].elements[i].type == 'hidden'
&& document.forms[form].elements[i].value == 1 ) ) {
var ss = document.forms[form].elements[i].id;
var row = 'rowid' + ss;
changeRowColor(row, form);
}
}
}
/**
* reset all the radio buttons with a given name
*
* @param string fieldName
* @param object form
* @return null
*/
function unselectRadio(fieldName, form) {
for( i=0; i < document.forms[form].elements.length; i++) {
if (document.forms[form].elements[i].name == fieldName) {
document.forms[form].elements[i].checked = false;
}
}
return;
}
/**
* Function to change button text and disable one it is clicked
*
* @param obj object - the button clicked
* @param formID string - the id of the form being submitted
* @param string procText - button text after user clicks it
* @return null
*/
var submitcount=0;
/* Changes button label on submit, and disables button after submit for newer browsers.
Puts up alert for older browsers. */
function submitOnce(obj,formId,procText) {
// if named button clicked, change text
if (obj.value != null) {
obj.value = procText + " ...";
}
if (document.getElementById) { // disable submit button for newer browsers
obj.disabled = true;
document.getElementById(formId).submit();
return true;
} else { // for older browsers
if (submitcount == 0) {
submitcount++;
return true;
} else {
alert("Your request is currently being processed ... Please wait.");
return false;
}
}
}
/**
* Function submits referenced form on click of wizard nav link.
* Populates targetPage hidden field prior to POST.
*
* @param formID string - the id of the form being submitted
* @param targetPage - identifier of wizard section target
* @return null
*/
function submitCurrentForm(formId,targetPage) {
alert(formId + ' ' + targetPage);
document.getElementById(formId).targetPage.value = targetPage;
document.getElementById(formId).submit();
}
/**
* Function counts and controls maximum word count for textareas.
*
* @param essay_id string - the id of the essay (textarea) field
* @param wc - int - number of words allowed
* @return null
*/
function countit(essay_id,wc){
var text_area = document.getElementById("essay_" + essay_id);
var count_element = document.getElementById("word_count_" + essay_id);
var count = 0;
var text_area_value = text_area.value;
var regex = /\n/g;
var essay = text_area_value.replace(regex," ");
var words = essay.split(' ');
for (z=0; z
0){
count++;
}
}
count_element.value = count;
if (count>=wc) {
/*text_area.value = essay;*/
var dataString = '';
for (z=0; z0) {
dataString = dataString + words[z] + ' ';
}
}
text_area.value = dataString;
text_area.blur();
count = wc;
count_element.value = count;
alert("You have reached the "+ wc +" word limit.");
}
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=420,left = 202,top = 184');");
}
function imagePopUp ( path ) {
window.open(path,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,screenX=150,screenY=150,top=150,left=150');
}
/**
* Function to show / hide the row in optionFields
*
* @param element name index, that whose innerHTML is to hide else will show the hidden row.
*/
function showHideRow( index ) {
if ( index ) {
cj( 'tr#optionField_' + index ).hide( );
if( cj( 'table#optionField tr:hidden:first' ).length ) cj( 'div#optionFieldLink' ).show( );
} else {
cj( 'table#optionField tr:hidden:first' ).show( );
if( ! cj( 'table#optionField tr:hidden:last' ).length ) cj( 'div#optionFieldLink' ).hide( );
}
return false;
}
/**
* Function to check activity status in relavent to activity date
*
* @param element message JSON object.
*/
function activityStatus( message ) {
var d = new Date(), time = [], i;
var currentDateTime = d.getTime()
var activityTime = cj("input#activity_date_time_time").val().replace(":", "");
//chunk the time in bunch of 2 (hours,minutes,ampm)
for(i=0; i= activity_date_time ) {
if (! confirm( message.scheduled )) {
return false;
}
}
}
/**
* Function to make multiselect boxes behave as fields in small screens
*/
function advmultiselectResize() {
var amswidth = cj("#crm-container form:has(table.advmultiselect)").width();
if (amswidth < 700) {
cj("form table.advmultiselect td").each( function() {
cj(this).css('display', 'block');
});
} else {
cj("form table.advmultiselect td").each( function() {
cj(this).css('display', 'table-cell');
});
}
var contactwidth = cj('#crm-container #mainTabContainer').width();
if (contactwidth < 600) {
cj('#crm-container #mainTabContainer').addClass('narrowpage');
cj('#crm-container #mainTabContainer').addClass('narrowpage');
cj('#crm-container #mainTabContainer.narrowpage #contactTopBar td').each( function(index) {
if (index > 1) {
if (index%2 == 0) {
cj(this).parent().after('
');
}
var item = cj(this);
cj(this).parent().next().append(item);
}
});
} else {
cj('#crm-container #mainTabContainer.narrowpage').removeClass('narrowpage');
cj('#crm-container #mainTabContainer #contactTopBar tr.narrowadded td').each( function() {
var nitem = cj(this);
var parent = cj(this).parent();
cj(this).parent().prev().append(nitem);
if ( parent.children().size() == 0 ) {
parent.remove();
}
});
cj('#crm-container #mainTabContainer.narrowpage #contactTopBar tr.added').detach();
}
var cformwidth = cj('#crm-container #Contact .contact_basic_information-section').width();
if (cformwidth < 720) {
cj('#crm-container .contact_basic_information-section').addClass('narrowform');
cj('#crm-container .contact_basic_information-section table.form-layout-compressed td .helpicon').parent().addClass('hashelpicon');
if (cformwidth < 480) {
cj('#crm-container .contact_basic_information-section').addClass('xnarrowform');
} else {
cj('#crm-container .contact_basic_information-section.xnarrowform').removeClass('xnarrowform');
}
} else {
cj('#crm-container .contact_basic_information-section.narrowform').removeClass('narrowform');
cj('#crm-container .contact_basic_information-section.xnarrowform').removeClass('xnarrowform');
}
}