var openTwitterFollowWin='';
var openTwitterWin='';
var openGenericWin='';
var openInfoWin='';
function openTwitterFollowWindow(pg,nm,w,h){
	window.openTwitterFollowWin=dhtmlwindow.open('follow', "iframe", pg, nm, "width=" + w + "px,height=" + h + "px,resize=1,scrolling=0,center=1", "recal")
	window.openTwitterFollowWin.onclose=function(){ 
		return true;
	}
}
function openTwitterWindow(pg,nm,w,h){
	window.openTwitterWin=dhtmlwindow.open('tellf', "iframe", pg, nm, "width=" + w + "px,height=" + h + "px,resize=1,scrolling=0,center=1", "recal")
	window.openTwitterWin.onclose=function(){ 
		return true;
	}
}

function openGenericWindow(pg,nm,w,h,sc,ctr){
	window.openGenericWin=dhtmlwindow.open('genw', "iframe", pg, nm, "width=" + w + "px,height=" + h + "px,resize=0,scrolling=" + sc + ",center=" + ctr, "recal")
	window.openGenericWin.onclose=function(){ 
		return true;
	}
}

function openInfoWindow(pg,unique,nm,w,h,sc,ctr){
	window.openInfoWin=dhtmlwindow.open(unique, "iframe", pg, nm, "width=" + w + "px,height=" + h + "px,resize=0,scrolling=1,center=" + ctr, "recal")
	window.openInfoWin.onclose=function(){ 
		return true;
	}
}

// Generic function to open a window
function openAWindow( pageToLoad, winName, width, height, center, scroll) {

    //openInfoWindow(pageToLoad,winName,'',width,height,scroll,center);
    //return;
                        
    // if 'center' == 1, then center window, otherwise put in top left corner
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }

    // Window Properties
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=" + scroll + ","
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    // open and focus window
    newWin = window.open( pageToLoad,winName,args );
    newWin.focus();
    return newWin;
}

var homeblog_html = '';
function get_home_blogs(num){
	var surl = "/util/home_blogs.php?c=" + num + "&ts=" + topstoryid;
	//jQuery("#home_blog_content").empty();
	//jQuery("#home_blog_content").append('<div style="text-align:center;padding:20px;">Loading Posts...<br /><img src="/images/loadingAnimation.gif" style="margin:10px;" /></div>');
	jQuery.ajax({
  		url: surl,
  		cache: false,
  		success: function(html){
  			if(document.getElementById('home_blog_content')){
  				jQuery("#home_blog_content").empty();
    			jQuery("#home_blog_content").append(html);
  			}
  		},
  		error: function(o,m,e){
     		alert( "Cant get the page content: " + m + " : " + e );
   		}
   	});
	return homeblog_html;
}

var guestblog_html;
function get_guest_blogs(num){
	var surl = "/util/guest_blogs.php?c=" + num;
	jQuery.ajax({
  		url: surl,
  		cache: false,
  		success: function(html){
  			if(document.getElementById('guest_blog_content')){
  				jQuery("#guest_blog_content").empty();
    			jQuery("#guest_blog_content").append(html);
  			}
  		},
  		error: function(o,m,e){
     		//alert( "Cant get the page content: " + m + " : " + e );
   		}
   	});
	return guestblog_html;
}

var openx_html;
function get_openx_ad(qstring,divid){
	var surl = "/util/openxad.php?" + qstring;
	//alert(surl);
	jQuery.ajax({
  		url: surl,
  		cache: false,
  		success: function(html){
  			//document.write(html);
  			if(divid && document.getElementById(divid)){
  				jQuery("#" + divid).empty();
    			jQuery("#" + divid).append(html);
  			}
  		},
  		error: function(o,m,e){
     		//alert( "Cant get the page content: " + m + " : " + e );
   		}
   	});
	return openx_html;
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
