var totalCoveredImages = 1;
var imagesQueue = new Array ();
function runCoverImages() {
var b = imagesQueue.shift();
if ( b != null) {
b.src = b.ssrc;
}
}
function checkRunCover( past, current ) {
if ( past == current ) {
runCoverImages();
} else {
setTimeout('checkRunCover(' +  totalCoveredImages + ', totalCoveredImages);',2000);
}
}
function coveredImage( path , width, coveredImageCount ) {
//if (width == undefined) {
document.write( '<img id="covered_imageCover_' + coveredImageCount +'" src="'+ appproxypath +'images/1x1t.gif" style="position: absolute; z-index: 50000;">');
document.write( '<img id="covered_image_' + coveredImageCount +'" >');
//}else{
//	document.write( '<img id="covered_imageCover_' + coveredImageCount +'" src="'+ appproxypath +'images/1x1t.gif" style="position: absolute; z-index: 50000;width:'+width+'px;">');
//	document.write( '<img id="covered_image_' + coveredImageCount +'" style="width:'+width+'px;">');
//}
document.getElementById('covered_image_' + coveredImageCount).style.visibility = 'hidden';
imgPreloader = new Image();
imgPreloader.iid = 'covered_image_' + coveredImageCount;
imgPreloader.iid2 = 'covered_imageCover_' + coveredImageCount;
imagesQueue.push( imgPreloader );
imgPreloader.onload=function(){
var img = document.getElementById(this.iid);
img.src = this.src;
var w = this.width;
var h = this.height;
var nw = w;
var nh = h;
if ( w >= width ) {
nw = width;
nh = (h * nw) / w;
img.width = nw;
img.height = nh;
}
var cover = document.getElementById(this.iid2);
cover.style.width = nw+'px';
cover.style.height = nh+'px';
img.style.visibility = 'visible';
var divName;
divName = '';
divName = this.iid;
divName = divName.replace(/covered_image_/gi,'');
divName = 'post_div_' + divName;
if(document.getElementById(divName)){
var Iter = {
hasParent:function(oChild,oParent){
var sStr = '';
var bRet = false;
var oNode = oChild;
do {
if (oNode && (oNode == oParent)){
break;
bRet = true;
}
if (oNode == document.body) break;
oNode = oNode.parentNode;
} while(oNode)
return bRet;
}
}
var oImg = $(this.iid);
var oDiv = $(divName);
if (Iter.hasParent(oImg,oDiv) && document.getElementById(divName).offsetHeight < this.height){
document.getElementById(divName).style.height = this.height + 10;
}
//alert(document.getElementById(divName).offsetHeight);
}
runCoverImages();
this.onload=function(){};
}
imgPreloader.ssrc = path;
totalCoveredImages++;
setTimeout('checkRunCover(' +  totalCoveredImages + ', totalCoveredImages);',3000);
}
function resizeAndCover(path, width){
}
