function HexToRgb(color)
{
	r = parseInt(color.substr(1,2), 16);
	g = parseInt(color.substr(3,2), 16);
	b = parseInt(color.substr(5,2), 16);
	return "rgb(" + r + ", " + g + ", " + b + ")";
}

function display_result(val) {
	var repr;
	
	repr  = "";
	repr += "Type: " + typeof val + "\n";
	repr += "Value: ";
	if (typeof val == "object" ||
		typeof val == "array") {
		repr += "{ ";
		for (var i in val) 
			repr += i + ": " + val[i] + ", ";
		repr = repr.substr(0, repr.length-2) + " }";
	} else {
		repr += val;
	}
	alert(repr);
}

function chgColors(sitebase,blog_id){
	var c1,c2,c3;
//	alert('aici');
	//preluam culorile
	
	if (document.styleSheets[1].cssRules)
	{
		theStyle = document.styleSheets[1].cssRules;
	}
	//pentru explorer
	else if (document.styleSheets[1].rules)
	{
		theStyle = document.styleSheets[1].rules;
	}
	
	for(i=0;i<theStyle.length;i++)
	{
//		display_result(theStyle[i]);		
//	alert(theStyle[i].selectorText.tolowercase);
		if(theStyle[i].selectorText.toLowerCase() == '#header')
		{
//			display_result(theStyle[i].style);		
			c1 = theStyle[i].style.backgroundColor;
//			alert(c1);
		}
		if(theStyle[i].selectorText.toLowerCase() == '.header_top a:hover')
		{
//			display_result(theStyle[i].style);		
			c2 = theStyle[i].style.color;
//			alert(c2);
		}
		if(theStyle[i].selectorText.toLowerCase() == '.header_top a')
		{
//			display_result(theStyle[i]);		
			c3 = theStyle[i].style.color;
//			alert(c3);
		}
	}
	
//	theStyle[i].style.backgroundColor = newColors[k];
//	theStyle[i].style.color = newColors[k];
//	theStyle[i].style.borderLeftColor = newColors[k];
					
//	alert('sfarsit');
	
	//vedem daca culorile sunt rgb sau hexa
	if( c1.indexOf("#") >= 0 )
	{
		//am culori hexa
		c1 = HexToRgb(c1);
		c2 = HexToRgb(c2);
		c3 = HexToRgb(c3);
	}
	
	s = "blog_id="+blog_id+"&c1="+c1+"&c2="+c2+"&c3="+c3;
//alert(s);
	var myAjax = new Ajax.Updater(
		{success: "x"},
		sitebase+"/responders/colors.php",
		{
			method: "post",
			parameters: s 
		}
	);
}


			