

var nextSet = "next5_01";

function addMoreLinks ()
{
document.getElementById(nextSet).style.display = "block";
if(nextSet=="next5_01"){
nextSet="next5_02";
}else if (nextSet=="next5_02"){
nextSet="next5_03";
}else if (nextSet=="next5_03"){
nextSet="next5_04";
}else if (nextSet=="next5_04"){
nextSet="next5_05";
}else if (nextSet=="next5_05"){
nextSet="next5_06";
}else if (nextSet=="next5_06"){
nextSet="next5_07";
}else if (nextSet=="next5_07"){
nextSet="next5_08";
}else {
nextSet="next5_01";
document.getElementById("addMoreButton").style.display = "none";
}
}

function getElementsByClassName(name){
var res = new Array();
var els = document.all ? document.all :
document.getElementsByTagName('*');
var cnRegex = new RegExp('(^| )' + name + '( |$)' );
for(var i=0; i < els.length; i++){
if(cnRegex.test(els[i].className)){
res.push(els[i]);
}
}
return res;
}

function toggleEditControls (){
var els = getElementsByClassName('hideable');
for(var i=0; i < els.length; i++){
var dsp = els[i].style.display;
els[i].style.display = (dsp == 'none' )? '' : 'none';
}
els = getElementsByClassName('showable');
for(var i=0; i < els.length; i++){
var dsp = els[i].style.display;
els[i].style.display = (dsp == 'none' )? '' : 'none';
}
}

function hideEditControls ()
{
for(i=0;i<document.getElementsByName("edit_controls").length;i++){
document.getElementsByName("edit_controls")[i].style.display="none";
}
var el = document.getElementById("hide_edit_button");
if(el )el.style.display="none";
el = document.getElementById("show_edit_button");
if(el )el.style.display="";
}

function showEditControls ()
{
for(i=0;i<document.getElementsByName("edit_controls").length;i++){
document.getElementsByName("edit_controls")[i].style.display="";
}
var el = document.getElementById("hide_edit_button");
if(el )el.style.display="";
el = document.getElementById("show_edit_button");
if(el )el.style.display="none";
}


function showLearnMorePopup(blogId, options){
window.open('/_do/learn_more?blogID=' + blogId, 'LearnMorePopup', options);
}

function showReminderPopup(showPopup, hideCheckbox, blogId, options){
if(!showPopup){
return;
}

if(hideCheckbox){
showPopup = true;
}else {
var cookies = getCookies();
if((cookies.IMReminderPopup == 'true')|| (cookies.newBlog == 'true')){
showPopup = false;
}
}

if(showPopup){
window.open('/_do/im_reminder_popup?blogID=' + blogId +
'&hideCheckbox=' + hideCheckbox,
'IMReminderPopup',
options);
}
}


var hexchars = "0123456789ABCDEF";

function toHex(n){
return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function MacEncodeURIComponent(s){
var c;
var enc = "";
for(var i= 0; i<s.length; i++){
if(okURIchars.indexOf(s.charAt(i))==-1)
enc += "%"+toHex(s.charCodeAt(i));
else
enc += s.charAt(i);
}
return enc;
}

function BlogEncodeURIComponent(raw){
var enc;
if(typeof encodeURIComponent == "function"){
enc = encodeURIComponent(raw);
}else {
enc = MacEncodeURIComponent(raw);
}
return enc;
}

function smsAlertConfirmation(showConfirmation, confirmationMessage){
if(showConfirmation == 'true'){
return confirm(confirmationMessage);
}else {
return true;
}
}

function resizeArchiveIframe(id,w,h){
document.getElementById(id).style.width = w;
document.getElementById(id).style.height = h;
}

function archiveResizeOnload(){
if(parent != window && parent.resizeArchiveIframe && thisIframeId){
var c = document.getElementById("main_content");
var bounds = Util.getBounds(c);
parent.resizeArchiveIframe(thisIframeId, bounds.width, bounds.height);
}
}
function gotoParentAnchor(href, anchor){
if(href && parent != window && parent.calendarPeriod){
if(parent.location.href.indexOf('MapUrl?')==-1){
parent.location.href = href;
}else {
if(parent.calendarPeriod == calendarPeriod){
var loc = Util.stripAnchor(parent.location.href);
parent.location.href = loc + "#" + anchor;
}else {
return true;
}
}
return false;
}
return true;
}

function checkForParentAnchor(){
if(parent != window){
var anchor = Util.getAnchor(parent.location.href);
if(anchor){
var loc = location.href;
location.href = loc + '#' + anchor;
}
}
}

function toggleEmailFeature(theForm, status){
if(status == "ON"){
theForm.enableEmail.value = "yes";
theForm.mobloggingStatus.value = "ON";
}else {
theForm.enableEmail.value = "no";
theForm.mobloggingStatus.value = "OFF";
}
theForm.submit();
}



function generateNewEmail(theForm){
theForm.reset.value = "yes";
theForm.submit();
}

function changePin()
{
this.invoke = function(){
document.getElementById('pin').innerHTML = document.getElementById("pipeFrame").contentDocument.getElementById("pin_body").innerHTML;
}
}

function turnOnMoblog(theForm){
theForm.enableEmail.value = "yes";
theForm.submit();
}

var preLoad;

function loadPics()
{
var pic = new Array();
pic[0]= 'images/twisties_open.gif';
pic[1]= 'images/twisties_closed.gif';

var p = pic.length;
preLoad = new Array();
var i = 0;
for(i = 0; i < p; i++){
preLoad[i]= new Image()
preLoad[i].src = pic[i]
}
document.images['twisty_img'].src = preLoad[1].src;
}

function switchTwisty ()
{
if(document.getElementById("twisty").style.display == "block"){
document.images['twisty_img'].src = preLoad[1].src;
document.getElementById("twisty").style.display = "none";
}else {
document.images['twisty_img'].src = preLoad[0].src;
document.getElementById("twisty").style.display = "block";
}
}

function setSendEmail (theForm, userName, domainName, errorMsg){
var emailAddressString = userName + "@" + domainName;
if(validateEmailAddress(emailAddressString, errorMsg)== false){return;
}
theForm.sendEmail.value="yes";
theForm.enableEmail.value="yes";
theForm.submit();
}

function validateEmailAddress (str, errorMsg){
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);
if(str.indexOf(at)==-1){
alert(errorMsg);
return false;
}
if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert(errorMsg);
return false;
}
if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert(errorMsg);
return false;
}
if(str.indexOf(at,(lat+1))!=-1){
alert(errorMsg);
return false;
}
if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert(errorMsg);
return false;
}
if(str.indexOf(dot,(lat+2))==-1){
alert(errorMsg);
return false;
}
if(str.indexOf(" ")!=-1){
alert(errorMsg);
return false;
}
return true;
}


function Util (){};

Util.UA = navigator.userAgent.toLowerCase();
Util.IE = (Util.UA.indexOf('msie')!= -1);


Util.browserRedirect = function(href){
if(isSafari){parent.location.href = href;
}else {
document.location.href = href;
}
};


Util.stripAnchor = function(href){
var i = href.indexOf('#');
if(i == -1){
return href;
}
return href.substr(0,i);
};


Util.getAnchor = function(href){
var i = href.indexOf('#');
if(i == -1){
return;
}
return href.substr(i+1);
};

Util.getBounds = function(anElement, containerElement){
var myBounds = new Object();
myBounds.left = 0;
myBounds.top = 0;
myBounds.width = anElement.offsetWidth;
myBounds.height = anElement.offsetHeight;

if(!containerElement){
containerElement = Util.IE ?
anElement.document.body :
anElement.ownerDocument.body;
}

var hasScroll = (anElement.scrollLeft !== void 0);

var trace = anElement;
while(trace != containerElement){
myBounds.left += trace.offsetLeft;
myBounds.top += trace.offsetTop;

var nextEl = trace.offsetParent;
while(hasScroll && (trace != nextEl)){
myBounds.left -= trace.scrollLeft;
myBounds.top -= trace.scrollTop;
trace = Util.IE ? nextEl : trace.parentNode;
}

trace = nextEl;
}

return myBounds;
};


Util.validateOpener = function(){
return (window.opener && !window.opener.closed);
};


Util.getRadioSelectedValue = function(radio){
if(!radio)return null;

for(var i=0; i < radio.length; i++){
if(radio[i].checked){
return radio[i].value;
}
}

return null;
};

