/* 
Copyright © 2006-2007 Robert Darrell - All rights reserved 
*/

function clearExample(element_id) {
	elem = document.getElementById(element_id);
	if(elem.value == elem.defaultValue || elem.value == "NO PHOTO") {
		elem.value = "";
		elem.title = "";
		elem.style.fontStyle = "normal";
	}
}

function usePlaceholderPic() {
	document.getElementById("imageID").value = "http://i42.photobucket.com/albums/e336/lilgiant47/Rob_Thunder/begonias_01.jpg";
}

function useNoPic() {
	document.getElementById("imageID").value = "NO PHOTO";
}

var mpswitch = "margin-top: 40px;";
var regexp_br = /\n/g;

function getUserInput() {
	heading = document.getElementById("headingID").value;
	imageURL = document.getElementById("imageID").value;

	if (imageURL != "" && imageURL != "NO PHOTO") {
		imageCode = '<p><img align="left" style="margin: 0px 10px 10px 0px;" src="' + imageURL + '">';
	} else {
		imageCode = "";
	}

	blurb_raw = document.getElementById("blurbID").value;
	blurb = blurb_raw.replace(regexp_br,'<br>');
	friendid = document.getElementById("friendID").value;
	// If music player option (i.e., is not plain black or plain white overlay)
	if (document.getElementsByName("mplayer")[0]) {	
	mpswitch = (document.getElementsByName("mplayer")[0].checked == true) ? "margin-top: 40px;" : "margin-top: -30px;";
	}
}


function selectCode(happy) {
	document.getElementById(happy).select();
}

// TEST AUTOFILL
function autofillGen() {
	document.getElementById("headingID").value = "The Shadow";
	document.getElementById("imageID").value = "http://robthunder.com/pics/rob_bw_small.jpg";
	document.getElementById("blurbID").value = 'Greetings! You have stumbled upon Rob Thunder\'s MySpace DIV Layout Lab.  This profile is used to test the MySpace DIV layouts I make available at <a href="http://robthunder.com">robthunder.com</a>. The following is just filler text... Aliquam accumsan ullamcorper velit. Nulla facilisi. Nunc molestie ligula et turpis. Nulla quis felis non ante hendrerit eleifend. Sed volutpat cursus est.\n\nMorbi dignissim iaculis purus. Suspendisse dictum aliquam nisi. Fusce fringilla nonummy nisl. Fusce vehicula dapibus arcu. In mattis, ipsum ac imperdiet laoreet, nunc augue varius mi, ac interdum enim risus eu velit. Aliquam erat volutpat. Pellentesque ut ipsum placerat felis consectetuer sagittis. Maecenas eu neque. Donec euismod. Curabitur nulla odio, aliquam id, auctor non, consequat eget, tortor. Nullam lectus. Nam eu elit.';
	document.getElementById("friendID").value = "283183391";
}

// SCREENSHOT AUTOFILL
function autofill4screenshot() {
	document.getElementById("headingID").value = "Little Giant";
	document.getElementById("imageID").value = "http://robthunder.com/pics/rob_bw_small.jpg";
	document.getElementById("blurbID").value = 'Your blurb goes here.. Aliquam accumsan ullamcorper velit. Nulla facilisi. Nunc molestie ligula et turpis. Nulla quis felis non ante hendrerit eleifend. Sed volutpat cursus est.\n\nMorbi dignissim iaculis purus. Suspendisse dictum aliquam nisi. Fusce fringilla nonummy nisl. Fusce vehicula dapibus arcu. In mattis, ipsum ac imperdiet laoreet, nunc augue varius mi, ac interdum enim risus eu velit. Aliquam erat volutpat. Pellentesque ut ipsum placerat felis consectetuer sagittis. Maecenas eu neque. Donec euismod. Curabitur nulla odio, aliquam id, auctor non, consequat eget, tortor. Nullam lectus. Nam eu elit.\n\n<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/wY3oEvaq71A&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/wY3oEvaq71A&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
	document.getElementById("friendID").value = "49246637";
}

function getPageID() {
var parentWindow = parent.location.href;
// alert("Parent Window = " + parentWindow);
var sitematch = "";

if (parentWindow.indexOf("localhost") != -1) {
	sitematch = "http://localhost/robthunder/";
} else if (parentWindow.indexOf("robthunder.com/") != -1) {
	sitematch = "robthunder.com/";
}

// var regexp1 = (sitematch == "http://localhost/robthunder/") ? "/robthunder/g" : "/robthunder.com//g";
// alert(regexp1);

var regexp1 = /http:\/\/localhost\/robthunder\//g;
var regexp2 = /http:\/\/robthunder.com\//g;
var regexp3 = /\//g;
var regexp4 = /.php/g;

if (sitematch == "http://localhost/robthunder/") {
	var pageID = parentWindow.replace(regexp1,"");
} else {
	var pageID = parentWindow.replace(regexp2,"");
}

var pageIDmod = pageID.replace(regexp3,"-");
var pageIDmod2 = pageIDmod.replace(regexp4,"");

// alert("pageIDmod2 = " + pageIDmod2);
return pageIDmod2;
}
