
var idsofsboxs = new Array();
var at_point = 0; // NEW
var at_v_point;
var at_h_point;
var top_end_at;
var left_end_at;
var v_scroll_amount
var h_scroll_amount 
var incroment = 1;
var stepping;
var clock_handel;



function init(){//document.getElementById("display").value="mark";
//idsofsboxs.push('$itemnum');
for (i=0;i<idsofsboxs.length;i++) {
what = idsofsboxs[i];
//document.getElementById("display").value=i;
define_what(what);
buttens_to_display(what);

}; //for (i=0;idsofsboxs.length;i++) 

};

function scroll_down(what){
define_what(what);



document.getElementById(what).at_v_point = document.getElementById(what).at_v_point + v_scroll_amount;
if (document.getElementById(what).at_v_point > (top_end_at - v_scroll_amount)){document.getElementById(what).at_v_point = top_end_at - v_scroll_amount};

start_v_scroll(what);

}; 

function scroll_up(what){

define_what(what);



document.getElementById(what).at_v_point = document.getElementById(what).at_v_point - v_scroll_amount;
if (document.getElementById(what).at_v_point < 0){document.getElementById(what).at_v_point = 0};

start_v_scroll(what);

}; 


function define_what(what){
//document.getElementById("display").value='--'+what;
if (document.getElementById(what).in_uses != 1){
document.getElementById(what).in_uses = 1;
document.getElementById(what).at_v_point =0;
document.getElementById(what).at_h_point =0;


}; // in_uses != 1



top_end_at = document.getElementById(what +"_end").offsetTop;

left_end_at = document.getElementById(what +"_end").offsetParent.offsetLeft;


v_scroll_amount = parseInt(document.getElementById(what).style.height);
h_scroll_amount = parseInt(document.getElementById(what).style.width);

};

function start_v_scroll(what){

if (document.getElementById(what).scrollTop != document.getElementById(what).at_v_point){
clock_handel = setInterval('v_scrolling("'+what+'")', 10);

};

};

function v_scrolling(what){

if (document.getElementById(what).scrollTop < document.getElementById(what).at_v_point){stepping = incroment;
if (document.getElementById(what).scrollTop + stepping  > document.getElementById(what).at_v_point){stepping = document.getElementById(what).at_v_point - document.getElementById(what).scrollTop};
}else if (document.getElementById(what).scrollTop > document.getElementById(what).at_v_point){stepping = incroment * -1;
if (document.getElementById(what).scrollTop + stepping  < document.getElementById(what).at_v_point){stepping = document.getElementById(what).at_v_point - document.getElementById(what).scrollTop};
} else {document.getElementById(what).scrollTop = 0;
stepping = incroment;
};

document.getElementById(what).scrollTop = document.getElementById(what).scrollTop + stepping;


//document.getElementById("display").value="top="+document.getElementById(what).scrollTop+" point="+document.getElementById(what).at_v_point+" end="+(top_end_at - v_scroll_amount) +" ScrollTop = "+document.getElementById(what).scrollTop;

};


function scroll_forward(what){
define_what(what);


document.getElementById(what).at_h_point = document.getElementById(what).at_h_point + h_scroll_amount;
if (document.getElementById(what).at_h_point > (left_end_at - h_scroll_amount)){document.getElementById(what).at_h_point = left_end_at - h_scroll_amount};

start_h_scroll(what);
buttens_to_display(what);

}; 

function scroll_back(what){

define_what(what);

document.getElementById(what).at_h_point = document.getElementById(what).at_h_point - h_scroll_amount;
if (document.getElementById(what).at_h_point < 0){document.getElementById(what).at_h_point = 0};

start_h_scroll(what);
buttens_to_display(what);
}; 

function start_h_scroll(what){

if (document.getElementById(what).scrollLeft != document.getElementById(what).at_h_point){
clock_handel = setInterval('h_scrolling("'+what+'")', 10);

};

};

function h_scrolling(what){

if (document.getElementById(what).scrollLeft < document.getElementById(what).at_h_point){stepping = incroment;
if (document.getElementById(what).scrollLeft + stepping  > document.getElementById(what).at_h_point){stepping = document.getElementById(what).at_h_point - document.getElementById(what).scrollLeft};
}else if (document.getElementById(what).scrollLeft > document.getElementById(what).at_h_point){stepping = incroment * -1;
if (document.getElementById(what).scrollLeft + stepping  < document.getElementById(what).at_h_point){stepping = document.getElementById(what).at_h_point - document.getElementById(what).scrollLeft};
} else {clearInterval(clock_handel);
stepping =0;
};

document.getElementById(what).scrollLeft = document.getElementById(what).scrollLeft + stepping;


//document.getElementById("display").value="Left="+document.getElementById(what).scrollLeft+" point="+document.getElementById(what).at_h_point+" end="+(left_end_at - h_scroll_amount);

};


function buttens_to_display(what){

//document.getElementById("display").value= document.getElementById(what).at_h_point +'>= ('+left_end_at+' - '+h_scroll_amount + ' --- '+document.getElementById(what +"_end").offsetParent.offsetLeft;


/*

// Up Down


if (document.getElementById(what).at_h_point >= (left_end_at - h_scroll_amount)){

document.getElementById(what+"_arrow_up").src="images/arrow_none.gif";

} else {

document.getElementById(what+"_arrow_up").src="images/arrow_up.gif";

};




if (document.getElementById(what).at_v_point > 0) {

document.getElementById(what+"_arrow_down").src="images/arrow_down.gif";

} else {

document.getElementById(what+"_arrow_down").src="images/arrow_none.gif";

};



// side to side


if (document.getElementById(what).at_h_point >= (left_end_at - h_scroll_amount)){

document.getElementById(what+"_arrow_right").src="images/arrow_none.gif";

} else {

document.getElementById(what+"_arrow_right").src="images/arrow_right.gif";

};




if (document.getElementById(what).at_h_point > 0) {

document.getElementById(what+"_arrow_left").src="images/arrow_left.gif";

} else {

document.getElementById(what+"_arrow_left").src="images/arrow_none.gif";

};

*/


};

function add_box_id(what){

idsofsboxs.push(what);

};



/*    ------- All Notes and Refeces ---------

//Notes 
//at_v_point="" at_h_point="" in_uses=""

from function init()

//what = idsofsboxs[i].substring(0,idsofsboxs[i].length);

//scroll_amount = document.getElementById("itemscatalog").style.posHeight;
//end_at = document.getElementById("end").offsetTop;

//document.display.value="yes";//not working


//document.getElementById("display").value=document.getElementById("$itemnum").scrollTop
//document.getElementById("display").value=document.getElementById("$itemnum_end").offsetTop;
//document.getElementById("$itemnum").at_v_point="1";
//document.getElementById("display").value=document.getElementById("$itemnum").at_v_point;

//document.getElementById("$itemnum").at_v_point = 0;

from function scroll_down(what)
//document.getElementById(what).scrollTop = top_end_at - v_scroll_amount ;

from function scroll_up(what)
//document.getElementById("itemscatalog").scrollTop = 0 ;

from function define_what(what)
//-//if (document.getElementById(what).at_h_point == "NaN"){};

//at_v_point=document.getElementById(what).at_v_point;
//at_h_point=document.getElementById(what).at_h_point;

//-//document.getElementById("display").value = left_end_at;

//-//document.getElementById(what).style.width;
//-//  offsetLeft offsetWidth  

//-//document.getElementById("display").value = h_scroll_amount


//-//document.getElementById("display").value = document.getElementById(what).scrollTop;
//-//document.getElementById("display").value = document.getElementById(what).scrollLeft;

from function start_v_scroll(what)

from function v_scrolling(what)
//document.getElementById("display").value =what;

//document.getElementById(what).at_v_point= at_v_point;

from function scroll_forward(what)

from function scroll_back(what)

from function start_h_scroll(what)


from function h_scrolling(what)
//document.getElementById("display").value =what;

//document.getElementById(what).at_v_point= at_v_point;

from function buttens_to_display(what)
 Up Down
//-// if (end_at >= (frame_hight + at_point)) 
//-//if (top_end_at >= (v_scroll_amount + document.getElementById(what).at_v_point)) {

 side to side
//if (left_end_at >= (h_scroll_amount + document.getElementById(what).at_h_point)) 







*/





