var color = 0;
var c_product_code = 0;
var c_product_value = 0;
var c_product_id = 0;

function mouseOver(obj, act) {
	obj.style.backgroundColor = (act)?'Gray':'';
}

function colorSelect(obj, id) {
	var sl = document.getElementById('size_list');
	sl.length = 0;
 
	if(document.getElementById('td'+color))
		document.getElementById('td'+color).style.backgroundColor = '';
		
	color = id;
	obj.style.backgroundColor = 'Gray';
	
	var i = 1;
	while(dependenciesMatrix[i]) {
		if(dependenciesMatrix[i][color]) {
	        var len = sl.length++;
	        sl.options[len].value = i;
	        sl.options[len].text = sizes[i];
	        sl.options[len].onclick = function(){ countPrice(); };
		};
		
		i++;
	}
	
	countPrice();
}

function countPrice() {
	var size = document.getElementById('size_list').value;

	c_product_code = dependenciesMatrix[size][color][1];
	c_product_value = dependenciesMatrix[size][color][2];
	c_product_id = dependenciesMatrix[size][color][3];
	
	if(obj = document.getElementById('product_code'))
		obj.innerHTML = c_product_code;
		
	if(obj = document.getElementById('product_value'))
		obj.innerHTML = c_product_value;
}


function findPosY(obj){
    var curtop = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    } else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}

function findPosX(obj){
    var curtop = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curtop += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    } else if (obj.x) {
        curtop += obj.x;
    }
    return curtop;
}

function resizeColor(obj){
    id = obj.id.split('_'); 
    
    obj =  document.getElementById('sc_'+id[1]);
    bobj = document.getElementById('bc_'+id[1]);
    
    bobj.style.left = findPosX(obj) - bobj.width + obj.width   +parseInt((document.all)?'1':'0');
    bobj.style.top = findPosY(obj)  - bobj.height + obj.height +parseInt((document.all)?'1':'0');;
    bobj.style.visibility = "visible";



    //alert(id);
}


function shrinkColor(obj){
    id = obj.id.split('_'); id = 'bc_' + id[1];

    bobj = document.getElementById(id);

    bobj.style.visibility = "hidden";
}
