//-----------------//
//Show - Delete//
//-----------------//
var id = "none";
function show(name){
	var div = document.getElementById(name);
	div.style.display = "block";
	lineid = find_lineid(name);
	set = 'block';
	set_display(lineid,set);
}
function item_delete(name){
	var div = document.getElementById(name);
	div.style.display = "none";
	lineid = find_lineid(name);
	set = 'none';
	set_display(lineid,set);
}
function position(id){
	var obj = document.getElementById(id);
	var x =  obj.style.left;
	var y =  obj.style.top;
	var style = 'x='+x+' y='+y;
	alert(style);
}


//-----------------//
//Link Editing//
//-----------------//

function linkEdit(id){
	file = which_file();
	what = 'link';
	parse_xml(file,id,what)
	var idName = "'"+id+"'";
	var Floating = "'link_Floating'";
	document.getElementById('link_style').innerHTML = '<label>Background Color<input type="text" id="'+id+'BackgroundColor" name="'+id+'BackgroundColor" /></label><br /><label>Border Color<input type="text" id="'+id+'BorderColor" name="'+id+'BorderColor" /></label><br /><label>Mouse Over Border Color<input type="text" id="'+id+'BorderColorHover" name="'+id+'BorderColorHover" /></label><br /><label>Border Left Size<input type="text" id="'+id+'BorderLeft" name="'+id+'BorderLeft" /></label><br /><label>Border Left Style<select id="'+id+'BorderLeftStyle" name="'+id+'BorderLeftStyle" size="1"><option value="Solid">Solid</option><option value="Dashed">Dashed</option><option value="Dotted">Dotted</option></select></label><br /><label>Border Right Size<input type="text" id="'+id+'BorderRight" name="'+id+'BorderRight" /></label><br /><label>Border Right Style<select id="'+id+'BorderRightStyle" name="'+id+'BorderRightStyle" size="1"><option value="Solid">Solid</option><option value="Dashed">Dashed</option><option value="Dotted">Dotted</option></select></label><br /><label>Padding Left Size<input type="text" id="'+id+'PaddingLeft" name="'+id+'PaddingLeft" /></label><br /><label>Padding Right Size<input type="text" id="'+id+'PaddingRight" name="'+id+'PaddingRight" /></label><br />';
	document.getElementById('link_settings').innerHTML = '<label>Link to URL<input type="text" id="'+id+'Url" name="'+id+'Url" /></label><br /> <label>Link Text<input type="text" id="'+id+'Text" name="'+id+'Text" /></label><br />';
	document.getElementById('link_bottom').innerHTML = '<button dojoType="Button" onclick="linkEdit_process('+idName+');dojo.widget.byId('+Floating+').hide()">Ok</button>';
}

function linkEdit_process(id){
	div = document.getElementById(id);
	var background = document.getElementById(id+'BackgroundColor').value;
	var borderColor = document.getElementById(id+'BorderColor').value;
	var borderColorhover = document.getElementById(id+'BorderColorHover').value;
	var borderLeft = document.getElementById(id+'BorderLeft').value;
	var borderLeftStyle = document.getElementById(id+'BorderLeftStyle').value;
	var borderRight = document.getElementById(id+'BorderRight').value;
	var borderRightStyle = document.getElementById(id+'BorderRightStyle').value;
	var paddingLeft = document.getElementById(id+'PaddingLeft').value;
	var paddingRight = document.getElementById(id+'PaddingRight').value;
	var url = document.getElementById(id+'Url').value;
	var text = document.getElementById(id+'Text').value;
	var display = div.style.display;
	if (display == ""){var display = "block";}
	div.innerHTML = '<style>.'+id+' a{border-left:'+borderLeft+' '+borderLeftStyle+' '+borderColor+';border-right:'+borderRight+' '+borderRightStyle+'  '+borderColor+';background:'+background+';color:'+borderColorhover+';padding-left:'+paddingLeft+';padding-right:'+paddingRight+';}.'+id+' a:hover{border-color:'+borderColorhover+';}</style><a href="'+url+'">'+text+'</a>';
	if (id == "showAllButton"){
		div.innerHTML = '<style>.'+id+' a{border-left:'+borderLeft+' '+borderLeftStyle+' '+borderColor+';border-right:'+borderRight+' '+borderRightStyle+'  '+borderColor+';background:'+background+';color:'+borderColorhover+';padding-left:'+paddingLeft+';padding-right:'+paddingRight+';}.'+id+' a:hover{border-color:'+borderColorhover+';}</style><a href="'+url+'">'+text+'</a>';
			}
	values = 'display="'+display+'" borderLeft="'+borderLeft+" "+borderLeftStyle+'" borderRight="'+borderRight+" "+borderRightStyle+'" borderColor="'+borderColor+'" borderColor-hover="'+borderColorhover+'" background="'+background+'" url="'+url+'" text="'+text+'" paddingLeft="'+paddingLeft+'" paddingRight="'+paddingRight+'"';
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}

//-----------------//
//Image Editing//
//-----------------//

function imgEdit(id){
	file = which_file();
	what = 'image';
	parse_xml(file,id,what)
	var idName = "'"+id+"'"
	var Floating = "'img_Floating'";
	document.getElementById('img_dimensions').innerHTML = '<label>Height<input type="text" id="'+id+'ImageHeight" name="'+id+'ImageHeight" /></label><br /><label>Width<input type="text" id="'+id+'ImageWidth" name="'+id+'ImageWidth" /></label><br />';
	document.getElementById('img_settings').innerHTML = '<label>Image Source URL<input type="text" id="'+id+'ImageSource" name="'+id+'ImageSource" /></label><br /> <label>Link Website URL<input type="text" id="'+id+'Url" name="'+id+'Url" /></label><br /><label>Alternative Text<input type="text" id="'+id+'ImagealtText" name="'+id+'ImagealtText" /></label><br />';
	document.getElementById('img_bottom').innerHTML = '<button dojoType="Button" onclick="imgEdit_process('+idName+');dojo.widget.byId('+Floating+').hide()">Ok</button>';
}

function imgEdit_process(id){
	img = document.getElementById(id);
	var source = document.getElementById(id+'ImageSource').value;
	var alt = document.getElementById(id+'ImagealtText').value;
	var height = document.getElementById(id+'ImageHeight').value;
	var width = document.getElementById(id+'ImageWidth').value;
	var url = document.getElementById(id+'Url').value;
	var display = img.style.display;
	if (display == ""){var display = "block";}
	document.getElementById(id).innerHTML = '<a href="'+url+'" title="'+alt+'"><img src="'+source+'" alt="'+alt+'" height="'+height+'" width="'+width+'" /></a>';
	values = 'display="'+display+'" height="'+height+'" width="'+width+'" source="'+source+'" url="'+url+'" alt="'+alt+'"';
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}

//------------//
//Gen Widget Style Editing//
//-----------//
function genText(id){
	file = which_file();
	what = 'style';
	parse_xml(file,id,what)
	var idName = "'"+id+"'"
	var Floating = "'Floating'";
				document.getElementById('gen_dimensions').innerHTML = '<label>Height<input type="text" id="'+id+'Height" name="'+id+'Height" /></label><br /><label>Width<input type="text" id="'+id+'Width" name="'+id+'Width" /></label><br />'
				document.getElementById('gen_background').innerHTML = '<label>Background Color<input type="text" id="'+id+'BackgroundColor" name="'+id+'BackgroundColor" /></label><br /><label>Background Image URL<input type="text" id="'+id+'BackgroundImg" name="'+id+'BackgroundImg" /></label><br /><label>Background Image Align<select id="'+id+'BackgroundImgAlign" size="1"><option value="center">Top Center</option><option value="left">Top Left</option><option value="right">Top Right</option><option value="bottom center">Bottom Center</option><option value="bottom left">Bottom Left</option><option value="bottom right">Bottom Right</option></select></label><br /><label>Background Image Repeat<select id="'+id+'BackgroundImgRepeat" size="1"><option value="no-repeat">none</option><option value="repeat-y">y-axis</option><option value="repeat-x">x-axis</option><option value="repeat">tile</option></select></label><br />'
				document.getElementById('gen_border').innerHTML = '<label>Border Color<input type="text" id="'+id+'BorderColor" name="'+id+'BorderColor" /></label><br /><label>Border Size<input type="text" id="'+id+'BorderSize" name="'+id+'BorderSize"></label><br /><label>Border Style<select id="'+id+'BorderStyle" name="'+id+'BorderStyle" size="1"><option value="Solid">Solid</option><option value="Dashed">Dashed</option><option value="Dotted">Dotted</option></select></label><br />'
				document.getElementById('gen_font').innerHTML = '<label>Font<select id="'+id+'Font" name="'+id+'Font" size="1"><option value="Arial, Helvetica, sans-serif">Arial</option><option value="Georgia, Times, serif">Georgia</option><option value="Verdana, Arial, Helvetica, sans-serif">Verdana</option><option value="Geneva, Arial, Helvetica, sans-serif">Geneva</option></select></label><br /><label>Font Color<input type="text" id="'+id+'FontColor" name="'+id+'FontColor" /></label><br /><label>Font Size<select name="'+id+'FontSize" size="1" id="'+id+'FontSize"><option value="100%">Normal</option><option value="80%">Small</option><option value="140%">Large</option></select></label><br />'
				document.getElementById('gen_bottom').innerHTML = '<button dojoType="Button" onclick="process('+idName+');dojo.widget.byId('+Floating+').hide()">Ok</button>';
}

function process(id){
	div = document.getElementById(id);
	var height = document.getElementById(id+'Height').value;
	var width = document.getElementById(id+'Width').value;
	var background = document.getElementById(id+'BackgroundColor').value;
	var backgroundimg = document.getElementById(id+'BackgroundImg').value;
	var backgroundimgalign = document.getElementById(id+'BackgroundImgAlign').value;
	var backgroundimgrepeat = document.getElementById(id+'BackgroundImgRepeat').value;
	var bordercolor = document.getElementById(id+'BorderColor').value;
	var bordersize = document.getElementById(id+'BorderSize').value;
	var borderstyle = document.getElementById(id+'BorderStyle').value;
	var font = document.getElementById(id+'Font').value;
	var fontColor = document.getElementById(id+'FontColor').value;
	var fontSize = document.getElementById(id+'FontSize').value;
	var left = div.style.left;
	var top = div.style.top;
	var misc = '';
	if (id == 'profile'){
		var misc = '.main h1,h2,h3,h4,h5,h6,pre,code { font-size:1em; margin: 0px 0px 0px 0px; }.main ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input{ margin:0; padding:0 }.main a img,:link img,:visited img { border:none; text-decoration:none; color:286ea0; }h2 {padding-left: 5px;clear:left;font-size: 1.25em;}h3 {padding-top:5px;padding-left: 5px;clear:left;font-size: .9em;}p{padding-left: 20px;padding-right: 5px;}.profile{margin:20px auto;}.main h1 {padding-left: 5px;font-size: 2.8em;}.main h2 {padding-left: 5px;font-size: 2em;}.main h3 {padding-top:5px;padding-left: 5px;clear:left;font-size: 1.45em;}.main p{padding-left: 20px;padding-right: 5px;font-size:1.35em;} .main a{font-size:1.35em;font-weight:normal;}';
	}
	div.style.height = height;
	div.style.width = width;
	div.style.borderWidth = bordersize;
	div.style.borderStyle = borderstyle;
	div.style.borderColor = bordercolor;
	div.style.fontFamily = font;
	div.style.fontSize = fontSize;
	div.style.color = fontColor;
	div.style.background = background+" url("+backgroundimg+") "+backgroundimgalign+" "+backgroundimgrepeat;
	var values = 'display="'+div.style.display+'" left="'+left+'" top="'+top+'" height="'+height+'" width="'+width+'" borderSize="'+bordersize+'" borderStyle="'+borderstyle+'" borderColor="'+bordercolor+'" font="'+font+'" fontColor="'+fontColor+'" fontSize="'+fontSize+'"  backgroundColor="'+background+'" backgroundUrl="'+backgroundimg+'" backgroundImgAlign="'+backgroundimgalign+'" backgroundImgRepeat="'+backgroundimgrepeat+'" misc="'+misc+'"';
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}

//------------//
//Misc Part Editting//
//-----------//
//Flickr
function flickr_process(){
	div = document.getElementById('flickr_html');
	flickr = document.getElementById('flickrId').value;
	id = 'flickr';
	div.innerHTML = '<embed src="http://www.mentalaxis.com/fl8/badgr2.swf?userid='+flickr+'&limit=25" quality="high" width="190" height="190" type="application/x-shockwave-flash" />';
	values = 'username="'+flickr+'"'
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}
//Myspace
function myspace_process(){
	div = document.getElementById('commentBox_html');
	friendid = document.getElementById('friendId').value;
	myspace_url = document.getElementById('myspaceUrl').value;
	id = 'myspace';
	div.getElementsByTagName('input')[0].value = friendid;
	values = 'friendid="'+friendid+'" url="'+myspace_url+'"';
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}
//Music
function music_process(){
	div = document.getElementById('musicBox_html');
	music_url = document.getElementById('musicUrl').value;
	id = 'music';
	alert(div.getElementsByTagName('embed')[0].getAttribute('FlashVars'));
	div.getElementsByTagName('embed')[0].setAttribute('FlashVars', 'TheSound='+music_url);
	values = 'url="'+music_url+'"';
	lineid = find_lineid(id);
	edit_xml(id,lineid,values);
}
//rss
	