
function jb_replace(string,rtext,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = rtext.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(rtext);
    if ((!i) && (rtext != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += jb_replace(string.substring(i+txtLength,strLength),rtext,by);
    return newstr;
}

function wopen(url,popupname,attributes) {
  win = window.open(url,popupname,attributes);
  win.focus();
}

//===============================DATE VALIDATION START
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(yy,mm,dd){
	var daysInMonth = DaysArray(12)
	if (mm<1 || mm>12){
		//alert("Please enter a valid month")
		return false
	}
	if (dd<1 || dd>31 || (mm==2 && dd>daysInFebruary(yy)) || dd > daysInMonth[mm]){
		//alert("Please enter a valid day")
		return false
	}
	if (yy==0 || yy<minYear || yy>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
return true
}
//===============================DATE VALIDATION END


function jb_create_comment_form(postid){
	//var cf_output = document.getElementById('post_comment_'+postid);
	if(postid){
		var cf_str = post_common_form;
		cf_str = jb_replace(cf_str,'jbpostid',postid);
		//cf_str = jb_replace(cf_str,'this_human_check_img','<img src="'+eval('human_check_img_'+postid)+'" border="0"/>');
		document.write(cf_str);
		//cf_output.innerHTML = cf_str;
	}
}

function jb_comment_show_hide(postid){
	var new_status = (document.getElementById('post_comment_'+postid).style.display=='none')?'block':'none';
	document.getElementById('post_comment_'+postid).style.display = new_status;
}

function jb_switch_comment_form(ptype, postid){
	document.getElementById('mb'+postid).style.display='none';
	document.getElementById('ob'+postid).style.display='none';
	if(ptype){
		document.getElementById(ptype+'b'+postid).style.display='block';
	}
}

function jb_get_photo_src(v1,v2,v3){
	var ppath = '/jumbo/album/';



}

function jb_display_photo(pdiv,psrc,pwidth,pheight){
	document.getElementById(pdiv).setAttribute("style","background: url("+psrc+") top no-repeat; width: "+pwidth+"px; height: "+pheight+"px;");
}

//for jumbo album 20051226
function jb_display_bigger_photo(ptitle,psrc,pwidth,pheight) {
 var html = "<HTML><HEAD><TITLE>"+ptitle+"</TITLE>" +
  "</HEAD><BODY LEFTMARGIN=0 " +
  "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0 onload='window.resizeTo("+pwidth+","+pheight+")'><CENTER>" +
  "<div style='background: url(" + psrc + ") top no-repeat; width: "+pwidth+"px; height: "+pheight+"px;'></div>"+
  "</CENTER>" +
  "</BODY></HTML>";
	popup=window.open
   ('','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
	//popup.document.open();
	popup.document.write(html);
	popup.focus();
	//popup.document.close();
}