$(document).ready(function(){


	ApplyColorPicker("colorSelectorStroke" , "000000" , {
		callback: function(hex){
				window.set_stroke_color(hex);
				$('#div_color1').css("backgroundColor", hex);
			}
	});
	
	ApplyColorPicker("colorSelectorFill" , "ffffff" , {
			callback: function(hex){
				window.set_fill_color(hex);
				$('#div_color2').css("backgroundColor", hex);
			}
	});


	$('#color1').colorPicker();
	$('#color2').colorPicker();
	
});//end ready

function ApplyColorPicker(id , ini_col_hex , fun_var){

		$("#" + id ).css({
			"border": "1px solid black",
			"height" : "30px",
			"width" : "30px",
			"backgroundColor" : "#" + ini_col_hex
			
		});

		$("#" + id).colorPicker({
			color: "#" + ini_col_hex,
			onChange: function (hsb, hex, rgb) {
				$("#" + id).css("backgroundColor", "#" + hex);
				fun_var.callback('#' + hex);
			}
		});
		
} //apply


function return_str_to_html(str){
	// alert("This is svg image in string format \n This will be posted to server \n " + str);
	// posting the data to server
	//document.getElementById("hidden_svg_data").setAttribute("value", escape(str));
	// $.post( "/svgdraw/svg_save.php", {svg_data: escape(str) } );
    var myForm = document.createElement("form");
	myForm.method = "post";
	myForm.action = "/svgdraw/svg_save.php";
    var myInput = document.createElement( "input" );
    myInput.setAttribute( "name", "svg_data" );
    myInput.setAttribute( "value", escape( str ) );
    myForm.appendChild( myInput );
	document.body.appendChild( myForm );
	myForm.submit();
	document.body.removeChild( myForm );
}

function update_svg_to_body(str){
str = '%%(modSVG)' + str + "\n" + '%%';
document.getElementById("body").setAttribute("value",str);
}

function f1(col){
	// $('#colorSelectorStroke').ColorPickerSetColor(col);
}

