var NS4 = (document.layers)?true:false;
var IE4 = (document.all)?true:false;
var IE5 = (document.getElementById)?true:false;


//Creating Layer Objects
function divObj(ObjName,visProp,AnchorPos,height){
	if(NS4){
		this.Obj= eval("document."+ObjName)
	}else if(IE4){
		this.Obj=eval("document.all['"+ObjName+"']");
	}else if(IE5){
		this.Obj= eval("document.getElementById('"+ObjName+"')");
	}
	var Coordinates = getAnchorPosition(AnchorPos);
	//alert(Coordinates.y)
	if(NS4){
		this.Obj.left=Coordinates.x;
		this.Obj.top=Coordinates.y;
	}else{
		this.Obj.style.left=Coordinates.x;
		this.Obj.style.top=Coordinates.y;
	}
	this.height=height;
	this.visProp=visProp;
}

//reLaying of Layer Objects
function setPostition(divStepObjArr){
	if(NS4){
		topPos=parseInt(divStepObjArr[0].Obj.top);
	}else{
		topPos=parseInt(divStepObjArr[0].Obj.style.top);
	}
	//alert(topPos);
	for(i=0;i<divStepObjArr.length;i++){
		if(NS4){
			divStepObjArr[i].Obj.top=topPos;
		}else{
			divStepObjArr[i].Obj.style.top=topPos;
		}
		if(divStepObj[i].visProp){
			topPos+=divStepObjArr[i].height+10;
			showObject(divStepObjArr[i].Obj)
		}else{
			hideObject(divStepObjArr[i].Obj)
		}
	}
	
}

//Show Layer Objects
function showObject(obj){
	if(NS4){
		obj.visibility="show";
	}else{
		obj.style.visibility="visible";
	}
}

//Hide Layer Objects
function hideObject(obj){
	if(NS4){
		obj.visibility="hide";
	}else{
		obj.style.visibility="hidden";
	}
}

//Write in to Layer Objects
function writeHTML(obj,text){
	if(NS4){
		obj.document.open(); 
		obj.document.write(text);
		obj.document.close();
	}else{
		obj.innerHTML=text;
	}
}

//Striping the Decimal points
function tidy(original_number) {
	decimals=2
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}


//get Anchor Position

function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}

