function logit(message) {
loga = document.getElementById("log");
if(loga) {
loga.innerHTML = loga.innerHTML + message + "
";
}
}
function make_gallink(el) {
el.style.visibility = "visible";
logit("m_gallink applied to "+el.href);
el.onclick = function() {
//mywindow.moveTo(5, 5);
open_gallery_window(el.href);
return false;
}
}
function open_gallery_window(url) {
width = 990;
height = 670;
target = '_blank';
window.open(url, target, "width="+width+",height="+height+",scrollbars,resizable");
}
function make_formwidget_popup(theform) {
theform.style.visibility = "visible";
logit("make_formwidget_popup applied to "+theform.selected_gallery.options[theform.selected_gallery.selectedIndex].value);
theform.onsubmit = function() {
var theurl = theform.selected_gallery.options[theform.selected_gallery.selectedIndex].value;
width = 800;
height = 615;
target = '_blank';
mywindow = window.open(theurl, target, "width="+width+",height="+height+",scrollbars,resizable");
return false;
}
}
function make_popup(el) {
logit("make_popup applied to "+el.href);
el.onclick = function() {
width = (window.outerWidth || window.screen.availWidth) * .75;
height = (window.outerHeight || window.screen.availHeight) * .75;
target = el.getAttribute('target') || '_blank';
mywindow = window.open(el.href, target, "width="+width+",height="+height+",menubar,resizable,location,scrollbars,status,toolbar");
mywindow.moveTo(5, 5);
return false;
}
}
function make_sharedinteractlink(el) {
logit("make_sharedinteractlink applied to "+el.href);
el.onclick = function() {
width = 777;
height = 750;
target = el.getAttribute('target') || '_blank';
mywindow = window.open(el.href, target, "width="+width+",height="+height+",scrollbars,resizable");
mywindow.moveTo(5, 5);
return false;
}
}
var popups_init = {
'a.gallink': make_gallink,
'a.apgallink': make_gallink,
'a.apinterlink': make_gallink,
'a.popup': make_popup,
'a.sharedinteract': make_sharedinteractlink,
'.gallery_form_widget': make_formwidget_popup
};
Behaviour.register(popups_init);
function truncate_widget(el, length) {
logit("truncate_widget applied to "+el.innerHTML);
original = el.innerHTML;
parts = original.split(" ");
if(parts.length > 20) {
shortened = parts.slice(0,30);
el.innerHTML = shortened.join(" ") + "...";
el.className = "body_truncated";
}
}
var widget_rules = {
".cxnhdln .body":function(el) {
truncate_widget(el, 20);
}
};
Behaviour.register(widget_rules);
s_prop24 = ''; //Setting prop since sc doesn't.
function keyword_extraction() {
var meta_keywords = document.getElementsByName('KEYWORDS')[0];
if(!meta_keywords) { return false; }
var special_keywords = [];
keyword_parts = meta_keywords.content.split(",");
for(var index in keyword_parts) {
var kw = keyword_parts[index];
kw = kw.replace(" ", "");
var kw_start = kw.charAt(0);
var kw_stop = kw.charAt(kw.length-1);
if(kw_start == "~" && kw_stop == "~") {
special_keywords[special_keywords.length] = kw.replace(/~/g, ''); // /~/g is a regex for all occurences of ~
}
}
var prop_string = '';
if(special_keywords.length > 1) {
for(var index in special_keywords) {
kw = special_keywords[index];
prop_string = kw + " | " + prop_string;
}
}
else {
prop_string = special_keywords[0];
}
s_prop24 = prop_string;
}
s_prop23_author = "Writer Unknown";
s_prop23_source = "Source Unknown";
s_prop23 = '';
function byline_extraction(el) {
var byline = el.innerHTML;
byline = byline.replace("", '');
byline = byline.replace("", '');
byline = strip(byline).toUpperCase();
if(s_prop23_author.indexOf(byline) != -1) {
//We've got a duplicate
return false;
}
else if(s_prop23_author != "Writer Unknown") {
s_prop23_author = byline + " | " + s_prop23_author;
}
else {
s_prop23_author = byline;
}
}
function strip(sInString) {
sInString = sInString.replace( /^\s+/g, "" );// strip leading
return sInString.replace( /\s+$/g, "" );// strip trailing
}
function source_extraction(el) {
s_prop23_source = strip(el.innerHTML);
}
function blog_source_extraction(el) {
try {
document.getElementById("blog");
}
catch(e) {
return false;
}
source_extraction(el);
}
function author_source_setting(el) {
s_prop23 = s_prop23_author + " || " + s_prop23_source;
}
var metrics_rules = {
"#flag": keyword_extraction,
"span.byline a": byline_extraction,
"p.byline a": byline_extraction,
"span.source": source_extraction,
"p.dateline": blog_source_extraction,
"#cwell": author_source_setting
}
Behaviour.register(metrics_rules);
var behaviour_count = 0;
logit("Initial: "+behaviour_count);
function apply_behaviours() {
loga = document.getElementById("log");
Behaviour.apply();
//Behaviour.apply();
if(behaviour_count == 0) {
logit("If 0: "+behaviour_count);
behaviour_count = behaviour_count + 1;
}
else if(behaviour_count == 1) {
logit("If 1: "+behaviour_count);
behaviour_count = behaviour_count + 1;
}
else {
logit("else: "+behaviour_count);
behaviour_count = behaviour_count + 1;
}
}
//Global Functions below
function openMP(the_url) {
var the_height_width = "height=600,width=890" + ",menubar=no,location=no,toolbar=no,resizable=no,scrollbars=no,status=no";
if (navigator.appName.indexOf("Microsoft") != -1) {
the_height_width += ",left=" + ((screen.availWidth - 890) *.5) + ",top=" + ((screen.availHeight - 600) *.5);
}
else if (navigator.appName.indexOf("Netscape") != -1) {
the_height_width += ",screenX=" + ((screen.availWidth - 890) *.5) + ",screenY=" + ((screen.availHeight - 600) *.5);
}
window.open(the_url,"_blank",the_height_width);
}