BackgroundPicker_targetInput = null;

BackgroundPicker_targetSpan = null;

function BackgroundPicker_writeDiv(){document.writeln("<DIV ID=\"backgroundPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");}

function BackgroundPicker_show(anchorname){this.showPopup(anchorname);}

function BackgroundPicker_pickBackground(background,obj){obj.hidePopup();pickBackground(background);}

function pickBackground(background){if(BackgroundPicker_targetInput==null){alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickBackground' function to handle the picked background!");return;}BackgroundPicker_targetInput.value = background;document.edit_profile.submit();}

function BackgroundPicker_select(inputobj,linkname){if(inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea"){alert("backgroundpicker.select: Input object passed is not a valid form input object");window.BackgroundPicker_targetInput=null;return;}window.BackgroundPicker_targetInput = inputobj;this.show(linkname);}

function BackgroundPicker_highlightBackground(c){var thedoc =(arguments.length>1)?arguments[1]:window.document;var d = thedoc.getElementById("backgroundPickerSelectedBackground");d.style.backgroundBackground = c;d = thedoc.getElementById("backgroundPickerSelectedBackgroundValue");d.innerHTML = c;}

function BackgroundPicker(){
var windowMode = false;
if(arguments.length==0){
	var divname = "backgroundPickerDiv";
}
else if(arguments[0] == "window"){
	var divname = '';windowMode = true;
}
else{var divname = arguments[0];}
	if(divname != "")
	{
		var bp = new PopupWindow(divname);
	}
	else{
		var bp = new PopupWindow();
		bp.setSize(430,380);}bp.currentValue = "000000";
		bp.writeDiv = BackgroundPicker_writeDiv;
		bp.highlightBackground = BackgroundPicker_highlightBackground;
		bp.show = BackgroundPicker_show;
		bp.select = BackgroundPicker_select;
		var names = new Array("Blue Sport","Candy","Caution Yellow","Pink Circles","Graffiti","Blue Green Circles","Audio System","Black Red Sport","Green Circles","Army","Cotton Candy Circles","Pink Cute","White Circles","Crazy Lights","Green Orange Circles","Embroidered","Hot Orange","Pink Shades","Carbon Fiber","Caution Red","Surgery","Neon","Red Circles","Blue Circles","Explosion");
		var thumbs = new Array("blue_myspace_layouts.gif","candy_lollipops_girly_myspace_layouts.gif","caution_myspace_layout.gif","pink_girly_cute_myspace_layouts.gif","graffiti_myspace_layouts.gif","blue_green_orange_myspace_layouts.gif","hot_myspace_layouts.gif","black_red_myspace_layouts.gif","green_circles_myspace_layouts.gif","army_myspace_layout.gif","cotton_candy_myspace_layouts.gif","pink_myspace_layouts.gif","clean_myspace_layouts.gif","crazy_myspace_layouts.gif","awesome_myspace_layouts.gif","pink_white_myspace_layouts.gif","bright_myspace_layouts.gif","girly_myspace_layouts.gif","carbon_fiber_myspace_layout.gif","red_caution_myspace_layout.gif","simple_myspace_layouts.gif","neon_myspace_layouts.gif","gothic_myspace_layouts.gif","blue_circles_myspace_layouts.gif","cool_myspace_layouts.gif");
		var backgrounds = new Array("blue_myspace_layouts.gif","candy_lollipops_girly_myspace_layouts.jpg","caution_myspace_layout.jpg","pink_girly_cute_myspace_layouts.gif","graffiti_myspace_layouts.jpg","blue_green_orange_myspace_layouts.gif","hot_myspace_layouts.jpg","black_red_myspace_layouts.gif","green_circles_myspace_layouts.gif","army_myspace_layout.jpg","cotton_candy_myspace_layouts.gif","pink_myspace_layouts.gif","clean_myspace_layouts.gif","crazy_myspace_layouts.jpg","awesome_myspace_layouts.gif","pink_white_myspace_layouts.gif","bright_myspace_layouts.gif","girly_myspace_layouts.jpg","carbon_fiber_myspace_layout.gif","red_caution_myspace_layout.jpg","simple_myspace_layouts.gif","neon_myspace_layouts.jpg","gothic_myspace_layouts.gif","blue_circles_myspace_layouts.gif","cool_myspace_layouts.jpg");
		var total = backgrounds.length;
		var diff = 3-total%3;
		var width = 2;
		var bp_contents = "";
		var windowRef =(windowMode)?"window.opener.":"";
		if(windowMode){
			bp_contents += "<HTML><HEAD><style type=\"text/css\">body{bgcolor:FFFFFF;font-size:10pt;font-family:Arial;margin:0px;color:000099;}td{color:000099;font-size:10pt;font-weight:900;font-family:Arial;}</style><TITLE>Pick Background</TITLE></HEAD>";
			bp_contents += "<BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0><CENTER>";
		}
		bp_contents += "<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=0>";
		bp_contents += "<TR>";
		var use_highlight =(document.getElementById || document.all)?true:false;
		for(var i=0;i<total;i++){
			if(i==(total+diff)/3 || i==(total+diff)/3*2){
				bp_contents += "<TR>";
			}
			if(use_highlight){
				var mo = 'onMouseOver="'+windowRef+'BackgroundPicker_highlightBackground(\''+backgrounds[i]+'\',window.document)"';
			}
			else{mo = "";}
				bp_contents += '<TD><FONT SIZE="-3"><A HREF="" onClick="'+windowRef+'BackgroundPicker_pickBackground(\'http://files.UploadMirror.com/makeyourspace/myspace_profile_editor/myspace_layouts/myspace_backgrounds/'+backgrounds[i]+'\','+windowRef+'window.popupWindowObjects['+bp.index+']);return false;" '+mo+' STYLE="text-decoration:none;"><IMG SRC="http://files.UploadMirror.com/makeyourspace/myspace_profile_editor/myspace_layouts/myspace_backgrounds_thumbs/'+thumbs[i]+'" TITLE="'+backgrounds[i]+'" HEIGHT=100 WIDTH=100><br>'+names[i]+'</A></FONT></TD>';
			if(i==(total+diff)/3-1 || i==(total+diff)/3*2-1){
				bp_contents += "</TR>";
			}
		}
		bp_contents += "</TR>";
			if(document.getElementById){var width1 = Math.floor(width/2);
			var width2 = width = width1;
//			bp_contents += "<TR><TD COLSPAN='"+width1+"' BGCOLOR='ffffff' ID='backgroundPickerSelectedBackground'>&nbsp;</TD><TD COLSPAN='"+width2+"' ALIGN='CENTER' ID='backgroundPickerSelectedBackgroundValue'>FFFFFF</TD></TR>";
		}
		bp_contents += "</TABLE>";if(windowMode){bp_contents += "</CENTER></BODY></HTML>";}
	bp.populate(bp_contents+"\n");
	bp.offsetY = 15;
	bp.autoHide();
	return bp;
}

