<
script
type
=
"text/javascript"
>
//
<![CDATA[
$(document).ready(function(){
(function($) {
$.fn.defaultValue = function(defaultvalue) {
return this.each(function() {
if (!$(this).val() && defaultvalue) {
$(this).val(defaultvalue);
}
if ($(this).val()) {
$(this).attr('defaultValue', $(this).val());
}
$(this).live('focus', function() {
if ($(this).attr('defaultValue') == $(this).val()) {
$(this).val('');
}
});
$(this).live('blur', function() {
if ($(this).val() == '') {
$(this).val($(this).attr('defaultValue'));
}
});
});
};
$.fn.setActiveTab = function(baseurl, currenturl, classname) {
if (baseurl.charAt(baseurl.length - 1) == '/') {
baseurl = baseurl.substr(0, baseurl.length - 1);
}
currenturl.replace(baseurl + '/', '');
if (!classname)
classname = 'active';
return this.each(function() {
$(this).find('a').each(function() {
$(this).removeClass(classname);
var linkhref = $(this).attr('href').replace(baseurl, '');
if (linkhref.charAt(0) == '/') {
linkhref = linkhref.substr(1);
}
if (currenturl == linkhref || linkhref && currenturl.indexOf(linkhref) == 0) {
$(this).parents('li:last').find('a:first').addClass(classname);
return false;
}
});
});
};
$.fn.toggleContent = function(options) {
return this.each(function() {
$(this).toggle(function(event) {
event.preventDefault();
if (options.css) {
$(this).css(options.css);
}
if (options.content) {
if (options.before) {
$(this).before(options.content);
} else {
$(this).after(options.content);
}
}
$(this).trigger('on.toggleContent');
}, function(event) {
event.preventDefault();
$(this).trigger('off.toggleContent');
});
});
};
$.fn.cot_ajaxify = function(options) {
return this.each(function() {
var $this = $(this);
var $targets = $this.find('a[href]');
var path = window.location.pathname.substr(1);
if (options && options.filter) {
$targets = $targets.filter(options.filter);
}
$targets.live('click', function(e) {
var href = $(this).attr('href');
var hash = href.replace(path, '');
if (hash) {
e.preventDefault();
if (options && options.history) {
$.history.load(hash);
} else {
if (options && options.css && options.css.before) {
$this.css(options.css.before);
}
$.get(href, function(data) {
$this.html(data);
if (options && options.css && options.css.after) {
$this.css(options.css.after);
}
});
}
}
});
if (options && options.history) {
$.history.init(function(hash) {
$.get(path + hash, function(data) {
$this.html(data);
if (options && options.css && options.css.after) {
$this.css(options.css.after);
}
});
}, {unescape: "/"});
}
});
};
})(jQuery);
;
$("#search").toggleContent({
css: { 'margin-left': '240px' },
content: '<form id="searchform" action="{PHP|cot_url('plug','e=search')}" method="post"><input id="searchfield" type="text" name="sq" title="Search" value=""></form>',
before: true
}).bind('on.toggleContent', function() {
$(this).parent().find('input').focus();
}).bind('off.toggleContent', function() {
$(this).parent().find('form').submit();
});
$("#login").toggle(function() {
$(this).addClass('active');
$("#loginbox").removeClass('hidden');
$("#loginbox input:first").focus();
}, function() {
$("#loginbox").addClass('hidden');
$(this).removeClass('active');
});
if({PHP.usr.messages}>0){
$("a#messages")
.append('<div id="pmcount">{PHP.usr.messages}</div>')
.attr('title', 'Messages (unread: {PHP.usr.messages})')
.toggle(function(){
$(this).addClass('active');
$('body').append('<div id="pmbox" class="userbox"><p><a href="{PHP|cot_url('pm')}">Inbox</a> - <a href="{PHP|cot_url('pm')}&f=sentbox">Sentbox</a></p></div>');
$.ajax({
url: '/index.php?e=pm&f=inbox&filter=unread',
dataType : "html",
success: function(html) {
rows = ''
var ajax_obj = $(html);
t = ajax_obj.find("#message_theme");
n = ajax_obj.find("#sender_name");
for (var h = 0; h < t.length; h++) {
rows += '<div id="message">';
rows += '<li>'+t[h].innerHTML+'<div id="sender">Sender: '+n[h].innerHTML+'</div></li>';
rows += '</div>';
document.getElementById('pmbox').innerHTML = rows+'<p><a href="{PHP|cot_url('pm')}">Inbox</a> - <a href="{PHP|cot_url('pm')}&f=sentbox">Sentbox</a></p>';
}
}
});
}, function(){
$(this).removeClass('active');
$('div#pmbox').remove();
});
}
});
//]]>
</
script
>