var forms_autocomplete_timer = 0;
var isIE6 = false;
infiniti_box_hidden = true;
message_box_hidden = true;
function show_notify_message_box(message)
{
if (message == null)
message = '';
if ($('notify_message_box_div'))
{
$('notify_message_box_div').style.position = 'fixed';
if (message != '')
$('notify_message_box_content_div').innerHTML = message;
Effect.SlideDown('notify_message_box_div', {duration: 0.75, afterFinish: function(){}});
}
}
function show_error_message_box(message)
{
if (message == null)
message = '';
if ($('error_message_box_div'))
{
$('error_message_box_div').style.position = 'fixed';
if (message != '')
$('error_message_box_content_div').innerHTML = message;
Effect.SlideDown('error_message_box_div', {duration: 0.75, afterFinish: function(){}});
}
}
function hide_notify_error_message_box(type)
{
message_box_hidden = true;
if (type == 'notify')
{
if (document.getElementById('notify_message_box_div'))
{
Effect.SlideUp('notify_message_box_div', {duration: 0.75});
}
}
else
{
if (document.getElementById('error_message_box_div'))
{
Effect.SlideUp('error_message_box_div', {duration: 0.75});
}
}
}
function process_forms_autocomplete(field_id, con)
{
if (forms_autocomplete_timer != 0)
clearTimeout(forms_autocomplete_timer);
$('forms_autocomplete_results').hide();
forms_autocomplete_timer = setTimeout(function()
{
var field_text = $(field_id).value;
if (field_text != '' && field_text.length > 2)
{
new Ajax.Updater('forms_autocomplete_results', 'http://www.luxy.co.za/admin/ajax/forms_autocomplete.php', {parameters: {search_text: field_text, obf: con, id: field_id}, method: 'get', onSuccess: function()
{
$(field_id).setStyle({position: 'relative'});
var t = $(field_id).offsetTop + $(field_id).offsetHeight;
var l = $(field_id).offsetLeft;
var w = $(field_id).offsetWidth;
$('forms_autocomplete_results').setStyle({
top: t + 'px',
left: l + 'px'});
$('forms_autocomplete_results').show();
}});
}
}, 500);
}
function forms_autocomplete_select_value(field_id, val)
{
$(field_id).value = val;
$('forms_autocomplete_results').hide();
}
function create_infiniti_box(w, h, url, title, show_close_button, custom_buttons_array)
{
if (!(custom_buttons_array instanceof Array))
custom_buttons_array = Array();
var basepath = 'http://www.luxy.co.za/';
var body = $$('body')[0];
var bodyWidth = (body.clientWidth > body.scrollWidth ? body.clientWidth : body.scrollWidth);
var bodyHeight = (body.clientHeight > body.scrollHeight ? body.clientHeight : body.scrollHeight);
var bg = $('infiniti_box_background_div');
bg.setStyle({backgroundColor: '#FFFFFF'});
resize_infiniti_box_background_div();
bg.show();
var container = $('infiniti_box_table');
var l = (bodyWidth / 2) - (parseInt(w) / 2) - 10;
var t = 100;
container.setStyle({width: w + 'px', height: h + 'px', left: l + 'px', top: t + 'px'});
scrollTo(0, 0);
container.show();
var content = $('infiniti_box_content_div');
content.style.height = parseInt(h) - 87;
content.innerHTML = "
 |
";
new Ajax.Updater('infiniti_box_content_div', url, {method:'get', evalScripts:true});
$('infiniti_box_close_div').innerHTML = "";
if (show_close_button && custom_buttons_array.length == 0)
{
var btn = Builder.node('input', {type: 'button', className:'btn', onmouseover:'this.className="btn btnhov"', onmouseout:'this.className="btn"', value:'Close', onclick:'destroy_infiniti_box()'});
$('infiniti_box_close_div').appendChild(btn);
}
else
{
if (custom_buttons_array.length == 0)
{
var fnt = Builder.node('font', {size:'1'}, ' ');
$('infiniti_box_close_div').appendChild(fnt);
}
else
{
for (var i=0; i body.scrollWidth ? body.clientWidth : body.scrollWidth);
var bodyHeight = (body.clientHeight > body.scrollHeight ? body.clientHeight : body.scrollHeight);
var bg = $('infiniti_box_background_div');
bg.setStyle({backgroundColor: '#FFFFFF'});
resize_infiniti_box_background_div();
bg.show();
var backing = $('infiniti_box_black_back_div');
var l = (bodyWidth / 2);
var t = 100 - border;
scrollTo(0, 0);
backing.setStyle({width: '1px', height: (h+border+border+extra) + 'px', top: t + 'px', left: l + 'px'});
backing.show();
new Effect.Scale(backing, ((w+border+border)*100), {scaleY:false, scaleContent:false, scaleFromCenter:true, duration: 0.6});
var content = $('infiniti_box_dark_content_div');
//content.setStyle({width: w + 'px'});
content.innerHTML = " |
";
setTimeout(function()
{
new Ajax.Updater('infiniti_box_dark_content_div', url, {method:'get', evalScripts:true});
}, 1400);
$('infiniti_box_dark_buttons_div').innerHTML = "";
if (show_close_button && custom_buttons_array.length == 0)
{
var btn = Builder.node('input', {type: 'button', className:'btn', onmouseover:'this.className="btn btnhov"', onmouseout:'this.className="btn"', value:'Close', onclick:'destroy_dark_infiniti_box()'});
$('infiniti_box_dark_buttons_div').appendChild(btn);
}
else
{
if (custom_buttons_array.length == 0)
{
var fnt = Builder.node('font', {size:'1'}, ' ');
$('infiniti_box_dark_buttons_div').appendChild(fnt);
}
else
{
for (var i=0; i 0)
{
var decimal = false;
var decimal_counter = 2;
for (var i=0; i 47 && str.charCodeAt(i) < 58)
{
if (decimal)
decimal_counter--;
if (decimal_counter >= 0)
new_value += str.charAt(i);
}
if (str.charCodeAt(i) == 46 && !decimal)
{
decimal = true;
new_value += str.charAt(i);
}
if (str.charCodeAt(i) == 45 && i == 0)
new_value += str.charAt(i);
}
element.value = new_value;
}
}
var registered_content_rotators = [];
function create_new_rotator(name, timeout, transition)
{
var new_rotator = {name: name, timeout: timeout, transition: transition, current_index: 0, timeoutid: 0, menu_timoutid: 0, switching: false, paused: false};
registered_content_rotators[registered_content_rotators.length] = new_rotator;
Event.observe('rotator_div_'+ name +'_container', 'mouseover', function(){show_rotator_control_menu(name);});
Event.observe('rotator_div_'+ name +'_container', 'mousemove', function(){show_rotator_control_menu(name);});
Event.observe('rotator_div_'+ name +'_container', 'mouseout', function(){hide_rotator_control_menu(name);});
// helping out with the loading of background images...
// half jQuery, half scriptaculous...
jQuery('#rotator_div_'+ name +'_container').children('DIV').each(function(c, child_element)
{
var id = jQuery(child_element).attr('id');
if (id.substring(id.length-12) != 'control_menu' && id.substring(id.length-2) != '_0')
{
new Effect.Appear(id, {duration: 0.0, to: 0.01}); }
});
check_rotator_images_loaded(name, 0);
}
function show_rotator_control_menu(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
var rotator_index = rotator['rotator_index'];
clearTimeout(rotator['menu_timoutid']);
var menu = $('rotator_div_'+ name +'_control_menu');
if (menu.style.display == 'none')
new Effect.Appear(menu, {duration: 0.35});
registered_content_rotators[rotator_index] = rotator;
}
function hide_rotator_control_menu(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
var rotator_index = rotator['rotator_index'];
rotator['menu_timoutid'] = setTimeout(function()
{
var menu = $('rotator_div_'+ name +'_control_menu');
menu.hide();
}, 400);
registered_content_rotators[rotator_index] = rotator;
}
function check_rotator_images_loaded(name, counter)
{
var container = $('rotator_div_'+ name +'_container');
var images = container.getElementsByTagName('IMG');
var ready = true;
for (var i=0; i 7)
switch_rotator_slide(name, 1);
else
{
counter++;
setTimeout(function(){check_rotator_images_loaded(name, counter);}, 1200);
}
}
function switch_next_rotator_slide(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
switch_rotator_slide(name, (parseInt(rotator['current_index']) + 1));
}
function switch_previous_rotator_slide(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
current_index = parseInt(rotator['current_index']);
current_index--;
if (current_index == 0)
{
current_index++;
while($("rotator_div_"+ name +"_" + current_index))
current_index++;
current_index--;
}
switch_rotator_slide(name, current_index);
}
function switch_rotator_slide(name, next_index)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
if (rotator['switching'] == false)
{
rotator['switching'] = true;
clearTimeout(rotator['timeoutid']);
var rotator_index = rotator['rotator_index'];
var current_index = parseInt(rotator['current_index']);
var transition = rotator['transition'];
var timeout = rotator['timeout'];
var current_slide;
var current_button;
var next_slide;
var next_button;
var show_next_slide = false;
if ($("rotator_div_"+ name +"_" + current_index))
{
current_slide = $("rotator_div_"+ name +"_" + current_index);
if ($("rotator_div_"+ name +"_button_" + current_index))
current_button = $("rotator_div_"+ name +"_button_" + current_index);
if ($("rotator_div_"+ name +"_" + next_index))
{
next_slide = $("rotator_div_"+ name +"_" + next_index);
if ($("rotator_div_"+ name +"_button_" + next_index))
next_button = $("rotator_div_"+ name +"_button_" + next_index);
current_index = next_index;
show_next_slide = true;
}
else if ($("rotator_div_"+ name +"_1") && current_index != 1)
{
next_slide = $("rotator_div_"+ name +"_1");
if ($("rotator_div_"+ name +"_button_1"))
next_button = $("rotator_div_"+ name +"_button_1");
current_index = 1;
show_next_slide = true;
}
}
if (show_next_slide)
{
if (current_button)
{
current_button.removeClassName('rotator_button');
current_button.removeClassName('rotator_button_active');
current_button.addClassName('rotator_button');
}
if (next_button)
{
next_button.removeClassName('rotator_button');
next_button.removeClassName('rotator_button_active');
next_button.addClassName('rotator_button_active');
}
if (current_slide.id.substring(current_slide.id.length-2) != '_0')
{
new Effect.Fade(current_slide.id, {to: 0.01, afterFinish: function()
{
$(current_slide.id).setStyle({zIndex:'2'});
}});
}
else
new Effect.Fade(current_slide.id, {duration: 0.25});
new Effect.Appear(next_slide.id, {afterFinish: function()
{
rotator['current_index'] = current_index;
if (rotator['paused'] == false)
rotator['timeoutid'] = setTimeout(function(){switch_rotator_slide(name, (current_index+1));}, (timeout*1000));
rotator['switching'] = false;
registered_content_rotators[rotator_index] = rotator;
$(next_slide.id).setStyle({zIndex:'3'});
}});
}
}
}
function rotator_pause(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
var rotator_index = rotator['rotator_index'];
clearTimeout(rotator['timeoutid']);
rotator['paused'] = true;
if ($('rotator_div_'+ name +'_play_pause_button'))
{
var button = $('rotator_div_'+ name +'_play_pause_button');
button.removeClassName('rotator_pause_button');
button.removeClassName('rotator_play_button');
button.addClassName('rotator_play_button');
}
registered_content_rotators[rotator_index] = rotator;
}
function rotator_play(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
var rotator_index = rotator['rotator_index'];
rotator['timeoutid'] = setTimeout(function(){switch_rotator_slide(name, (parseInt(rotator['current_index'])+1));}, 750);
rotator['paused'] = false;
if ($('rotator_div_'+ name +'_play_pause_button'))
{
var button = $('rotator_div_'+ name +'_play_pause_button');
button.removeClassName('rotator_pause_button');
button.removeClassName('rotator_play_button');
button.addClassName('rotator_pause_button');
}
registered_content_rotators[rotator_index] = rotator;
}
function toggle_rotator_play_pause(name)
{
var rotator = get_rotator_with_index(name);
rotator = rotator['rotator'];
if (rotator['paused'] == true)
rotator_play(name);
else
rotator_pause(name);
}
function get_rotator_with_index(name)
{
var rotator;
var rotator_index;
for(var i=0; i 5)
{
new Effect.Fade('infiniti_box_heavy_loader_div', {duration: 0.35, afterFinish: function()
{
new Effect.Appear('infiniti_box_heavy_content_div', {duration: 0.35});
}});
}
else
{
counter++;
setTimeout(function(){check_heavy_infiniti_box_content(counter);}, 1200);
}
}
function destroy_heavy_infiniti_box()
{
$('infiniti_box_heavy_loader_div').hide();
$('infiniti_box_heavy_content_div').hide();
new Effect.Fade('infiniti_box_background_div', {duration: 0.35});
}
function resize_infiniti_box_background_div()
{
var bg = $('infiniti_box_background_div');
bg.setStyle({width: '100%', height: '100%', position: 'fixed'}); }
function update_current_flash_uploaded_files(id, digest)
{
if ($(id + '_state_info'))
new Ajax.Updater(id + '_state_info', 'http://www.luxy.co.za/admin/modules/uploads/flash_upload_field/get_current_state_info.php?digest=' + digest, {method: 'get'});
}
function remove_flash_uploaded_file(file_id, id, digest)
{
new Ajax.Request('http://www.luxy.co.za/admin/modules/uploads/flash_upload_field/remove_flash_uploaded_file.php?id=' + file_id, {method: 'get', onSuccess: function()
{
update_current_flash_uploaded_files(id, digest);
}});
//update_current_flash_uploaded_files(id, digest);
}
function infiniti_style_file_input_field(id, cl)
{
var field = jQuery('#'+id);
field.css('position', 'absolute');
field.css('opacity', '0');
var parent = field.parent();
var parent_width = parent.width();
var button = jQuery('');
button.attr('type', 'button');
button.attr('value', 'Browse');
button.addClass('btn');
button.css('width', '55px');
button.css('margin-left', '2px');
button.insertAfter(field);
var textbox = jQuery('');
textbox.addClass(cl);
textbox.insertAfter(field);
textbox.css('width', (parent_width-64)+'px');
// need a delay, in case other on-loaded scripts are changing the display...
setTimeout(function()
{
var left = field.offset().left - button.width();
//field.css('top', top);
field.css('left', left);
}, 1000);
field.change(function()
{
var index = this.value.lastIndexOf('\\');
index++;
textbox.attr('value', this.value.substring(index));
});
}
document.observe('dom:loaded', function()
{
if (!$('AJAX_CHILD_ELEMENT_APPENDER'))
return;
var b = $$('body')[0];
var d = Builder.node('div', {id: 'forms_autocomplete_results'});
//b.appendChild(d);
// update, IE bug...
$('AJAX_CHILD_ELEMENT_APPENDER').appendChild(d);
$('forms_autocomplete_results').setStyle({
position: 'absolute',
borderStyle: 'solid',
borderWidth: '1px',
borderColor: '#999999',
textAlign: 'left',
backgroundColor: '#FFFFFF'});
$('forms_autocomplete_results').hide();
});