// Lady scripts

THEIMAGES = new Array; THEWIDTHS = new Array; THEHEIGHTS = new Array; SMWIDTHS = new Array; SMHEIGHTS = new Array;
WINWIDTHS = new Array; WINHEIGHTS = new Array;
FIRST_NAME = "Sophia"; 
LAST_NAME = "Myles";
THE_TEXT = FIRST_NAME + " " + LAST_NAME; 
file_text = FIRST_NAME + "_" + LAST_NAME;


var index_lady = 0; THEIMAGES[index_lady] = file_text+'1.jpg'; THEWIDTHS[index_lady] = 545; THEHEIGHTS[index_lady] = 700;
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'2.jpg'; THEWIDTHS[index_lady] = 521; THEHEIGHTS[index_lady] = 700;
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'3.jpg'; THEWIDTHS[index_lady] = 509; THEHEIGHTS[index_lady] = 700; 
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'4.jpg'; THEWIDTHS[index_lady] = 528; THEHEIGHTS[index_lady] = 700; 
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;	
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'5.jpg'; THEWIDTHS[index_lady] = 503; THEHEIGHTS[index_lady] = 700; 
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'6.jpg'; THEWIDTHS[index_lady] = 522; THEHEIGHTS[index_lady] = 700;
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'7.jpg'; THEWIDTHS[index_lady] = 696; THEHEIGHTS[index_lady] = 700; 
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;

index_lady++; THEIMAGES[index_lady] = file_text+'8.jpg'; THEWIDTHS[index_lady] = 694; THEHEIGHTS[index_lady] = 700; 
d1 = THEWIDTHS[index_lady] / 100; d2 = THEHEIGHTS[index_lady] / 100; var m_d = Math.max (d1,d2);
SMWIDTHS[index_lady] = THEWIDTHS[index_lady] / m_d; SMHEIGHTS[index_lady] = THEHEIGHTS[index_lady] / m_d;
WINWIDTHS[index_lady] = THEWIDTHS[index_lady]+40; WINHEIGHTS[index_lady] = THEHEIGHTS[index_lady]+15;
	

function get_the_lady_name() {

document.write(THE_TEXT);
}

function get_the_ladies() {

LADY_NUMBER = Math.round (Math.random() * index_lady);
var image = THEIMAGES[LADY_NUMBER]; var width = THEWIDTHS[LADY_NUMBER]; 
var height = THEHEIGHTS[LADY_NUMBER]; var text = THE_TEXT;
var total_height_here = height + 200;

document.write("<div style='background-color:#9DC9FE; border-width: 1px; border-style:solid; border-color:darkblue; height:"+total_height_here+"px; width:740px'>");
document.write("<br><img src=http://www.billsuniverse.com/lady_of_the_week/"+image+" width="+width+" height="+height+" alt="+text+" border=0><br><input type=checkbox name=box"+LADY_NUMBER+">");

// Random choosing of pictures
tempOthers = new Array (index_lady); theOthers = new Array (index_lady);

for (i = 0; i <= index_lady; i++)
	{
	temp = Math.round (Math.random() * 10000);
	tempOthers [i] = new Array (i, temp);
	}

highest = 0; ok = 0;

for (incr = 0; incr <= index_lady; incr++)
{
	for (k = 0; k <= index_lady; k++)
		{
		if (k != LADY_NUMBER)
			{
			if (tempOthers [k] [1] > highest)
				{
				highest = tempOthers [k] [1];
				loc = k;
				}
			ok = 1;
			}
		}

if (ok == 1)
	{
		tempOthers [loc] [1] = 0;
		theOthers [incr] = tempOthers [loc] [0];
		highest = 0; ok = 0;
	}
}
// Random choosing of pictures

document.write('<br><br><center><table border=0 cellpadding=0 cellspacing=0><tr><td>');

for (l = 0; l < index_lady; l++)
		{
		var image = "sm_" + THEIMAGES[theOthers[l]]; var link = THEIMAGES[theOthers[l]];
		var width = SMWIDTHS[theOthers[l]]; var height= SMHEIGHTS[theOthers[l]];
		var win_width = WINWIDTHS[theOthers[l]]; var win_height = WINHEIGHTS[theOthers[l]];
		var text = THE_TEXT;

		document.write('<a href=http://www.billsuniverse.com/lady_of_the_week/'+link+' target=_blank><img src=http://www.billsuniverse.com/lady_of_the_week/'+image+' width='+width+' height='+height+' alt='+text+' border=0></a><br><center><input type=checkbox name=box'+theOthers[l]+'></center>');
		document.write('</td><td width=5></td><td>');
		}
	document.write('</td></tr></table></center></div>');
	}


vote_index = 0;


function processForm() {
	form = " ";
max = 2;

box0 = document.placeForm.box0.checked; box1 = document.placeForm.box1.checked; box2 = document.placeForm.box2.checked;
box3 = document.placeForm.box3.checked; box4 = document.placeForm.box4.checked; box5 = document.placeForm.box5.checked;
box6 = document.placeForm.box6.checked; box7 = document.placeForm.box7.checked;

count = (box0 ? 1 : 0) + (box1 ? 1 : 0) + (box2 ? 1 : 0) + (box3 ? 1 : 0) + (box4 ? 1 : 0) + (box5 ? 1 : 0) + (box6 ? 1 : 0) + (box7 ? 1 : 0);


if (count == 0) {
	alert("You haven't selected any pictures!");
	return false;
	}

if (count == 1)
	if (confirm("You've only selected 1 picture. Do you want to select another picture?")) { return false; }

if (count > max) {
	difference = count - max;
		if (difference > 1) {
			alert("You chose " + count + " pictures and the most you can select is " + max + ".\n\nPlease unselect " + difference + " pictures!");
			return false;
		}
		if (difference == 1) {
			alert("You chose " + count + " pictures and the most you can select is " + max + ".\n\nPlease unselect " + difference + " picture!");
			return false;
		}
	}

	shit0 = 0; shit1 = 0; shit2 = 0; shit3 = 0; shit4 = 0; shit5 = 0; shit6 = 0; shit7 = 0;

	if (document.placeForm.box0.checked == true) { shit0 = 1; } if (document.placeForm.box1.checked == true) { shit1 = 1; }
	if (document.placeForm.box2.checked == true) { shit2 = 1; } if (document.placeForm.box3.checked == true) { shit3 = 1; }
	if (document.placeForm.box4.checked == true) { shit4 = 1; } if (document.placeForm.box5.checked == true) { shit5 = 1; }
	if (document.placeForm.box6.checked == true) { shit6 = 1; } if (document.placeForm.box7.checked == true) { shit7 = 1; }

	form += shit0+"\n"; form += shit1+"\n"; form += shit2+"\n"; form += shit3+"\n"; form += shit4+"\n"; form += shit5+"\n"; form += shit6+"\n"; form += shit7+"\n";

	document.submitForm.result.value = form;
	document.submitForm.submit();

return false; // this shouldn't be here???
}

function processComments() {

form= " ";

// All <> are filtered out during the POST

search_for_email1 = document.placeForm.text1.value.search(/@/);
if (search_for_email1 != -1) { document.placeForm.text1.value=""; }
search_for_email2 = document.placeForm.text2.value.search(/@/);
if (search_for_email2 != -1) { document.placeForm.text2.value=""; }
search_for_email3 = document.placeForm.text3.value.search(/@/);
if (search_for_email3 != -1) { document.placeForm.text3.value=""; }
search_for_email4 = document.placeForm.text4.value.search(/@/);
if (search_for_email4 != -1) { document.placeForm.text4.value=""; }
search_for_email5 = document.placeForm.text5.value.search(/@/);
if (search_for_email5 != -1) { document.placeForm.text5.value=""; }
search_for_email6 = document.placeForm.text6.value.search(/@/);
if (search_for_email6 != -1) { document.placeForm.text6.value=""; }
search_for_email7 = document.placeForm.text7.value.search(/@/);
if (search_for_email7 != -1) { document.placeForm.text7.value=""; }
search_for_email8 = document.placeForm.text8.value.search(/@/);
if (search_for_email8 != -1) { document.placeForm.text8.value=""; }

form=document.placeForm.text1.value+"/f"+document.placeForm.text2.value+"/f"+document.placeForm.text3.value+"/f"+document.placeForm.text4.value+"/f"+document.placeForm.text5.value+"/f"+document.placeForm.text6.value+"/f"+document.placeForm.text7.value+"/f"+document.placeForm.text8.value+"/f"+document.placeForm.lady_name.value;
document.submitForm.submit();
//alert (form);
return false;
}


// End of Lady scripts


// Start misc scripts

function techEmail() {

name ="tech" 
domain ="billsuniverse" 
extension =".com" 
document.write('<a href="mailto:' + name + '@' + domain + extension +'?subject=Technical Problem">Technical Problems?</a>'); 

}

function billEmail() {

name ="bill" 
domain ="billsuniverse" 
extension =".com" 
document.write('<a href="mailto:' + name + '@' + domain + extension +'?subject=Suggestion">suggestions</a>'); 

}

function ladyEmail() {

name ="bill" 
domain ="billsuniverse" 
extension =".com" 
document.write('<a href="mailto:' + name + '@' + domain + extension +'?subject=Lady Suggestion">Make a suggestion for Lady!</a>'); 

}


function send (tech) {

from_email = tech.from_email.value;
if (from_email == "") { from_email = "anonymous"; }

to_email = "tech@billsuniverse.com, ...";
//if (form == lady) { to_email = "..."; }

	newmessage = ""; message_temp = document.tech.message.value;
	for (j = 0;  j < message_temp.length; j++) {
		char_crap = message_temp.charAt(j);
			if (char_crap == "\"" || char_crap == "\'") {
				char_crap = "``";
			}
		newmessage = newmessage + char_crap;
		}
	message = newmessage+"~";

			document.submitForm.result.value = to_email + "~" + from_email + "~" + message;
			document.submitForm.submit();
}


function send_suggestion (lady) {

from_email = lady.from_email.value;
if (from_email == "") { from_email = "anonymous"; }

to_email = "tech@billsuniverse.com";

	newmessage = ""; message_temp = document.lady.message.value;
	for (j = 0;  j < message_temp.length; j++) {
		char_crap = message_temp.charAt(j);
			if (char_crap == "\"" || char_crap == "\'") {
				char_crap = "``";
			}
		newmessage = newmessage + char_crap;
		}
	message = newmessage+"~";

			document.submitForm.result.value = to_email + "~" + from_email + "~" + message;
			document.submitForm.submit();
}


function key() {
	alert (event.keyCode);
}
