// JavaScript Document
var bHadPosted;
var Cols;
var CanPost;
var ColWidth;
var NextNum = 1;
function replaceIfFlash(version,element_id,replacement_string)
{
document.getElementById(element_id).innerHTML=replacement_string;
}
function renderVideo(element_id,src,width,height,flashvars){
var agent=navigator.userAgent.toLowerCase();var is_iphone=(agent.indexOf("iphone")!=-1);if(is_iphone){document.getElementById(element_id).innerHTML=''}else{replaceIfFlash(10,element_id,'')}
$(".video iframe").height(parseInt(ColWidth) * 0.8);
$(".video iframe").width(parseInt(ColWidth));
$(".video iframe").css("height",parseInt(ColWidth) * 0.8 + "px");
$(".video embed").height(parseInt(ColWidth) * 0.8);
$(".video embed").width(parseInt(ColWidth));
$(".video embed").css("height",parseInt(ColWidth) * 0.8 + "px");
}
$(document).ready(function() {
var newa = document.createElement('a');
newa.setAttribute("href","http://www.themecloud.co/narnia-tumblr-theme.asp");
newa.setAttribute("id","purchase_theme");
var newimg = document.createElement('img');
newimg.setAttribute("src","http://static.tumblr.com/2w7y46r/wuvmba8c2/installtheme.png");
newimg.setAttribute("style","position:fixed; right:10px; top:30px;z-index:99999999 !important;");
newimg.setAttribute("border","0");
newa.appendChild(newimg);
document.body.appendChild(newa);
var script=document.createElement('script');
script.type='text/javascript';
script.src="http://narnia.tcs3.co.uk/themes/narnia/narnia.1/getjs.asp?id=" + $("#guid").html();
$("body").append(script);
if ($("#page_menu").html().indexOf("div") == -1)
{
$("#page_plus").hide();
}
})
function GetPosts(sCols, MinColWidth)
{
var MinusX;
if (parseInt(sCols) > 7)
{
sCols = "7";
}
if ($(window).width() < 480 || $(window).height() < 480) {
//small screen, load other JS files
sCols = "1";
sDevice = "1";
}else
{
sDevice = "";
}
//alert(document.getElementById("container").style.width);
if(document.getElementById("container").style.width == "100%")
{
ColWidth = $(window).width() -17;
MinusX = 40;
//alert(ColWidth);
}else if(document.getElementById("container").style.width == "80%")
{
ColWidth = ($(window).width() * 0.8);
MinusX = 0;
}else if(document.getElementById("container").style.width == "90%")
{
ColWidth = ($(window).width() * 0.9);
MinusX = 0;
}else if(document.getElementById("container").style.width == "95%")
{
ColWidth = ($(window).width() * 0.95);
MinusX = 0;
}else if(document.getElementById("container").style.width == "85%")
{
ColWidth = ($(window).width() * 0.85);
MinusX = 0;
}else if(document.getElementById("container").style.width == "50%")
{
ColWidth = ($(window).width() * 0.5);
MinusX = 0;
}
else
{
MinusX = 0;
ColWidth = parseInt(document.getElementById("container").style.width.replace("px",""));
}
if (parseInt(((ColWidth / sCols))) > parseInt(MinColWidth))
{
if (sDevice == "")
{
ColWidth = MinColWidth;
}else
{
ColWidth = parseInt((ColWidth / sCols));
}
}
else
{
ColWidth = parseInt((ColWidth / sCols));
}
//document.getElementById("posts").style.width = ((ColWidth * sCols) + (sCols * 20)) - MinusX + "px";
document.getElementById("posts").style.width = (ColWidth * sCols) + "px";
// alert(ColWidth * sCols);
Cols = sCols;
//alert(ColWidth);
// Create columns 1st
ColWidth = ColWidth - ((parseInt(document.getElementById("post_padding").innerHTML) * (parseInt(Cols) +1)) / parseInt(Cols));
for(i = 0; i < Cols; i ++)
{
if (document.getElementById("column" + i) == null)
{
var newdiv = document.createElement("div");
newdiv.setAttribute("id","column" + i);
if (i == sCols -1)
{
newdiv.setAttribute("class","column columnlast");
}else
{
newdiv.setAttribute("class","column column" + i);
}
newdiv.setAttribute("style","width:" + ColWidth + "px;");
document.getElementById("posts").appendChild(newdiv);
}
}
//GetMorePosts();
GetMorePosts();
}
function GetMorePosts()
{
//document.getElementById("posts_hidden").innerHTML = document.getElementById("posts_hidden").innerHTML.replace("audio_player_","xx_audio_player_");
var LoadFlashFile = false;
if (CanPost == false)
{
return false;
}
CanPost = false;
var HTMLage;
var sasync = true;
if (NextNum == 1)
{
sasync = false;
}else
{
sasync = true;
}
var sPageName;
if (document.getElementById("tag_page").innerHTML == "")
{
sPageName = "/page/";
}else
{
sPageName = "/tagged/" + document.getElementById("tag_page").innerHTML + "/page/";
}
$.ajax({
url: sPageName + NextNum,
async: sasync,
success: function(data) {
//alert(data.getElementById("posts_hidden").innerHTML);
if (NextNum == 1)
{
async = false;
data = document.getElementById("posts_hidden").innerHTML;
}
//data = data.replace(/audio_player_/g,"xx_audio_player_");
data = data.replace(//g,"");
data = data.replace(/divabc/g,"div");
//data = data.replace(/xx_/g,"");
data = data.replace(//g,"");
data = data.replace(/<x>/g,"");
data = data.replace(/<X>/g,"");
if (data.indexOf("") >=0)
{
var sArr = data.split("");
}
else
{
var sArr = data.split("");
}
if (sArr[1].indexOf("") >=0)
{
var sArray = sArr[1].split("");
}
else
{
var sArray = sArr[1].split("");
}
x = 0;
for(i = 0; i < sArray.length -1; i ++)
{
if (sArray[i].indexOf("audio") >= 0)
{
sArray[i] = sArray[i].replace("[Flash 9 is required to listen to audio.]","");
sArray[i] = sArray[i].replace("Flash 9 is required to listen to audio.]","");
sArray[i] = sArray[i].replace("[Flash 9 is required to listen to audio.]","");
sArray[i] = sArray[i].replace("Flash 9 is required to listen to audio.]","");
}
if (sArray[i].indexOf("shadow_image") >= 0)
{
if (parseInt(document.getElementById("post_padding").innerHTML) < 10)
{
sArray[i] = sArray[i].replace("shadow_image","shadow_image_hide");
}
}
if (sArray[i].indexOf("video") >= 0)
{
sArray[i] = sArray[i].replace("height=","height='" + parseInt(ColWidth) * 0.8 + "'" + " oldheight=");
sArray[i] = sArray[i].replace("width=","oldwidth=");
}
$('#column' + x).append(sArray[i]);
$(".video iframe").height(parseInt(ColWidth) * 0.8);
$(".video iframe").width(parseInt(ColWidth));
$(".video iframe").css("height",parseInt(ColWidth) * 0.8 + "px");
$(".video embed").height(parseInt(ColWidth) * 0.8);
$(".video embed").width(parseInt(ColWidth));
$(".video embed").css("height",parseInt(ColWidth) * 0.8 + "px");
/* This is basic - uses default settings */
//alert($('.quote_title').html());
$("a#single_image").fancybox();
/* Using custom settings */
$("a#inline").fancybox({
'hideOnContentClick': true
});
//$(sArray[i]).appendTo('#column' + x);
x = x + 1;
if (x == Cols)
{
x = 0;
}
}
CanPost = true;
if (NextNum ==1)
{ NextNum = NextNum + 1;
CanPost = true;
GetMorePosts();
}else
{
if (NextNum ==2)
{ NextNum = NextNum + 1;
CanPost = true;
if (document.getElementById("tag_page").innerHTML == "")
{
GetMorePosts();
}
}else
{
CanPost = true;
NextNum = NextNum + 1;
}
}
}
});
}