var divisions = new Array("entries","family","learning","information-overload","digital-life","relationships","avatar-stories","six-word-stories");
var publicdivisions = new Array("Recent Stories","Family","Learning","Information Overload","Digital Life","Relationships","Avatar Stories","Six Word Stories");
var storyup = false;
var currentid = 0;
function story_render (targetfile) {
$.ajax({
type: "GET",
url: targetfile + '.xml',
dataType: "xml",
success: function(xml) {
var special = new Array();
var normal = new Array();
var specialadd = 0;
$(xml).find('rec').each(function(){
var thisrec = new Object();
thisrec.title = $(this).find("tit").text();
thisrec.area = $(this).attr("typ");
thisrec.id = $(this).attr("id");
thisrec.description = $(this).find("dsc").text();
thisrec.thumbnail = $(this).find("tmb").text();
thisrec.fav = $(this).attr("fav");
if(thisrec.fav == "1" && specialadd < 2){
special.push(thisrec);
specialadd++;
} else {
normal.push(thisrec);
}
});
$("#storylarge").hide();
$("#storymain").hide();
var sidenav = '
';
for(var y = 0; y < divisions.length; y++){
if(divisions[y] == targetfile){
sidenav += '- ' + publicdivisions[y] + '
';
} else {
sidenav += '- ' + publicdivisions[y] + '
';
}
}
sidenav += '
';
$("#storynav").html(sidenav);
var specialstuff = '';
var normalstuff = '';
if(special.length < 2){
special.push(normal.shift());
}
if(special.length < 2){
special.push(normal.shift());
}
for(var n = 0; n < normal.length; n++){
normalstuff += '
';
}
for(var s = 0; s < special.length; s++){
specialstuff += '
';
}
$("#storylarge").html(specialstuff);
$("#storymain").html(normalstuff);
$("#storylarge").fadeIn(900);
$("#storymain").fadeIn(900);
}
});
}
function story_preview (targetid,title,area,description) {
if(!storyup){
$("#p"+targetid).addClass("boxover");
$("#p"+targetid).html('' + area + ': ' + unescape(title) + '<\/span>
' + unescape(description));
$("#p"+targetid).click(function (){
story_display(targetid);
});
currentid = targetid;
}
}
function story_previewoff () {
$("#p" + currentid).removeClass("boxover");
$("#p" + currentid).html('');
}
function story_display (targetid) {
$.ajax({
type: "GET",
url: 'records/' + targetid + '.xml',
dataType: "xml",
success: function(xml) {
var emb = $(xml).find("emb").text();
var title = $(xml).find("tit").text();
var description = $(xml).find("dsc").text();
var final = 'CLOSE';
final += emb;
final += '' + title + '
' + description + '
';
document.getElementById('mainover').innerHTML = final;
$("#mainover").fadeIn(400);
storyup = true;
}
});
}
function story_display_close () {
$("#mainover").fadeOut(400, function () {
document.getElementById('mainover').innerHTML = '';
storyup = false;
});
}
function story_form () {
$("#outer").css( { height: $("#mainblock").height() + 70 + "px" });
$("#outer").fadeIn("slow");
var output = 'CLOSE XSend us your stories
To share a story of how digital technology is changing your world, follow these steps:
1. Upload your photo or video to a sharing site like YouTube or Flickr. Videos should be under 1 min in length.
2. Fill out the form below and send us a link to your work.
';
$("#submitform").html(output);
$("#submitform").fadeIn("slow");
$("#submitform").css({ "left": (($("#mainblock").width() / 2) + 83) - 400 });
}
function story_form_close () {
$("#submitform").fadeOut("slow", function () {
$("#outer").fadeOut("slow");
$("#submitform").html('');
});
}
function checksend (thisform) {
var submission = false;
var passfail = true;
var errstring = '';
$(thisform).find(":input").each(function () {
if(this.name == "sendtype"){
submission = (this.value == "submission")? true:false;
}
if(submission){
if(this.name == "link" && this.value == ""){
errstring += '\nPlease enter a link to your work';
passfail = false;
}
}
if(this.name == "email" && this.value == ""){
errstring += '\nPlease enter your e-mail adddress';
passfail = false;
}
if(this.name == "description" && this.value == ""){
errstring += (submission)? '\nPlease enter a short description':'\nPlease enter a comment';
passfail = false;
}
});
if(!passfail){
alert(errstring);
return false;
} else {
return true;
}
}
function checkform(thisfield) {
if(thisfield.value == 'comment'){
$("#formdesc").html('Comment ');
$("#tags").attr('disabled',true);
$("#link").attr('disabled',true);
$("#media").attr('disabled',true);
$("#tags_name").css({ color: "#aaaaaa"});
$("#media_name").css({ color: "#aaaaaa"});
$("#link_name").css({ color: "#aaaaaa"});
} else {
$("#formdesc").html('Short description (160 character limit) ');
$("#tags").attr('disabled',false);
$("#link").attr('disabled',false);
$("#media").attr('disabled',false);
$("#media_name").css({ color: "#414285"});
$("#tags_name").css({ color: "#414285"});
$("#link_name").css({ color: "#414285"});
}
}
$(document).ready(function () {
if(location.href.indexOf('?p=') != -1){
var targetid = location.href.substring(location.href.indexOf('?p=') + 3,location.href.length);
story_display(parseInt(targetid));
}
});