 
var runningfunction = "no"
var browser=navigator.appName;
 
 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=480');");
}
// End -->

function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=400');");
}
function setup()
{
var img1 = document.getElementById("image1")
var img2 = document.getElementById("image2")
var img3 = document.getElementById("image3")
var img4 = document.getElementById("image4");
var img5 = document.getElementById("image5")
var img6 = document.getElementById("image6")
var img7 = document.getElementById("image7")
var reastobuy = document.getElementById("reasonstobuy")
var topdiv = document.getElementById("top")
var bottomleftdiv = document.getElementById("bottomleft")
var middlediv = document.getElementById("middle")
var marque = document.getElementById("marqueediv");
var bottomdiv = document.getElementById("bottom")
var viewsocksdiv = document.getElementById("viewsocks")

for (i=1;i<=7;i++)
{
eval("img"+i+".style.height = img"+i+".clientHeight");
}

reastobuy.style.height = img3.clientHeight;
topdiv.style.height = img1.clientHeight;
middlediv.style.height = img4.clientHeight;

for (i=1;i<=7;i++)
{
eval("img"+i+"w = img"+i+".clientWidth");
eval("img"+i+"h = img"+i+".clientHeight");
}
reasw = reastobuy.clientWidth;
reash = reastobuy.clientHeight;

bottomleftdiv.style.width = img4w * 0.75 + "px";
marque.style.width = img6w * 0.60 + "px";

reastobuy.style.position = "relative";
reastobuy.style.left = "-"+ (reasw * 0.65) + "px"; 
reastobuy.style.top = (reash * 0.3) + "px"; 
xreasw = (reasw * 0.25);

topdiv.style.width = (img1w + img2w + img3w + reasw) + "px"
middlediv.style.width = (img1w + img2w + img3w + reasw) + "px"
bottomdiv.style.width = (img1w + img2w + img3w + reasw) + "px"

middlewidth = (img4w + img5w + img6w + img7w)
topdiv.style.marginLeft = ((document.body.clientWidth - middlewidth)*.45) + "px"
middlediv.style.marginLeft = ((document.body.clientWidth - middlewidth)*.45) + "px"
bottomdiv.style.marginLeft = ((document.body.clientWidth - middlewidth)*.45) + "px"


var obj = img5


xpos = findPosX(obj)
ypos = findPosY(obj)

		marque.style.left = xpos + img5w + "px";
		marque.style.top = ypos + (img6h*0.4) + "px";
		
var obj2 = img7
xpos = findPosX(obj2)
ypos = findPosY(obj2)

		viewsocksdiv.style.left = xpos + "px";
		viewsocksdiv.style.top = ypos + img7h + "px";
		
				
var obj3 = img4
xpos = findPosX(obj3)
ypos = findPosY(obj3)

		bottomleftdiv.style.left = xpos + (img4w*0.3) + "px";
		bottomleftdiv.style.top = ypos + (img4h*0.75)+ "px";
		


document.getElementById("maincontainer").style.visibility = "visible";
}

//=========================

//=============================

function setup_choose()
{
var manc = document.getElementById("maincontainer");
var topleft = document.getElementById("topleft"); 
var topright = document.getElementById("topright");
var blank = document.getElementById("blank");
var main = document.getElementById("main")
var title = document.getElementById("title")
var forme = document.getElementById("forme")
var gift2 = document.getElementById("gift2")
var viewsocks = document.getElementById("viewsocks")
var footer = document.getElementById("footer")

originalblankheight = blank.clientHeight

manc.style.width = (document.body.clientWidth * 0.8) + "px";
manc.style.height = (document.body.clientHeight * 0.7) + "px";

main.style.width = ( manc.clientWidth * 0.9 ) + "px";



topleftheight = topleft.clientHeight;
toprightheight = topright.clientHeight;

topright.style.marginTop = (topleftheight/2)-(toprightheight/2)+"px";



blank.style.width = main.clientWidth * 0.8 + "px"; 

blank.style.marginLeft = "10%";
blank.style.marginTop = "1%"; 

main.style.height = ((document.body.clientHeight * 0.7)-(topleftheight))*0.9 + "px";


var obj = blank;
blankX = findPosX(obj);
blankY = findPosY(obj);



zz = (blank.clientWidth/2)


	blankwidth = parseInt(blank.clientWidth);
	newtitlewidth = blankwidth * 0.8 
	
	title.style.fontWeight = "bold";
	title.style.width = newtitlewidth + "px";
	
	var obj = blank;
	blankX = findPosX(obj);
	
	title.style.left = (blankX + (blankwidth * 0.1)) + "px";
	title.style.top = blankY + "px";
	title.style.textAlign="center"

var obj = title;
titleX = findPosX(obj);
titleY = findPosY(obj);


forme.style.left = blankX + (blank.clientWidth/2)-(forme.clientWidth)+ "px";
forme.style.top =  titleY + title.clientHeight + 20 + "px";
gift2.style.left = blankX + (blank.clientWidth/2)  + "px";
gift2.style.top =  titleY + title.clientHeight + 20 + "px";

viewsocks.style.top = (titleY + title.clientHeight + forme.clientHeight) * 1.05 + "px"
viewsocks.style.left = blankX + (blank.clientWidth/2)-(viewsocks.clientWidth/2)+ "px";


var obj = main;
mainY = findPosY(obj);

var obj = viewsocks;
viewsocksY = findPosY(obj);

adjust = (  viewsocksY + parseInt(viewsocks.clientHeight)) - (mainY + parseInt(main.clientHeight)  );
main.style.height = main.clientHeight + (adjust) + "px";

footer.style.position = "absolute";
footer.style.width = "100%";
footer.style.left = "0px";

var obj = main;var monthlygift = document.getElementById("monthlygift");	
mainY = findPosY(obj);
footer.style.top = (mainY + main.clientHeight)*1.05 + "px"

sizediffmaintoblank = main.clientHeight/blank.clientHeight


manc.style.visibility = "visible";
}
//==========================================================================================================
function setup_newsubi_resize()
{
	
	if (browser == "Microsoft Internet Explorer")
	{
	setTimeout ( "setup_newsubi('resize')", 100 );
	
	}
	else
	{
	setup_newsubi('resize')
	}
}

function setup_newsubi(calledby)
{

		document.getElementById("maincontainer").style.visibility = "hidden";

	
	var manc = document.getElementById("maincontainer");
	var main = document.getElementById("main");
	var topleft = document.getElementById("topleft");
	var img_a = document.getElementById("img_a");
	var img_b = document.getElementById("img_b");
	var img_c = document.getElementById("img_c");
	if (document.getElementById("monthly")) 
	{
	var monthly = document.getElementById("monthly");
	var bimonthly = document.getElementById("bimonthly");
	var quarterly = document.getElementById("quarterly");
	}
	else
	{
	var monthlygift = document.getElementById("monthlygift");	
	var quarterlygift = document.getElementById("quarterlygift");	
	}
	var stages =  document.getElementById("stages");
	var thisstage =  document.getElementById("thisstage");
	var letsgetstarted = document.getElementById("letsgetstarted");
	var viewsocks = document.getElementById("viewsocks");
	var footer = document.getElementById("footer");
	
	
	
	manc.style.width = (document.body.clientWidth * 0.8) + "px";
	manc.style.height = (document.body.clientHeight * 0.7) + "px";

	main.style.width = ( manc.clientWidth * 0.9 ) + "px";
	
	
	
	img_awidth = img_a.clientWidth
	main.style.width = img_awidth + "px";
	
	
	topleft.style.position = "absolute";
	img_a.style.position = "absolute";
	img_b.style.position = "absolute";
	img_c.style.position = "absolute";
	
	if (monthly)
	{
	monthly.style.position = "absolute";
	bimonthly.style.position = "absolute";
	quarterly.style.position = "absolute";
	}
	else
	{
	monthlygift.style.position = "absolute";
	quarterlygift.style.position = "absolute";	
	}
	
	stages.style.position = "absolute";
	thisstage.style.position = "absolute";
	letsgetstarted.style.position = "absolute";
	viewsocks.style.position = "absolute";
	
	
	topleft.style.zIndex = "1";
	
	

	img_a.style.top = topleft.clientHeight*0.75 + "px";
	
	var obj = img_a;
	img_aX = findPosX(obj);
	img_aY = findPosY(obj);
	
	img_b.style.left = img_aX + "px";
	img_b.style.top  = img_aY + "px";
	
	img_c.style.left = img_aX + img_a.clientWidth - img_c.clientWidth  + "px";
	img_c.style.top  = img_aY + "px";
	
	if (monthly) 
	{
	monthly.style.left = img_aX + img_b.clientWidth + "px";
	monthly.style.top = img_aY + (img_b.clientHeight*0.65) + "px";
	
	bimonthly.style.left = (img_aX + img_b.clientWidth + bimonthly.clientWidth) +  ( img_a.clientWidth * 0.06) + "px";
	bimonthly.style.top = img_aY + (img_b.clientHeight*0.65) + "px";
	
	quarterly.style.left = ((img_aX + img_b.clientWidth + monthly.clientWidth + bimonthly.clientWidth )) +  ( img_a.clientWidth * 0.11) + "px";
	quarterly.style.top = img_aY + (img_b.clientHeight*0.65) + "px";
	}
	else
	{
	availablespace =  (findPosX(img_a) + img_a.clientWidth) - (findPosX(img_b) + img_b.clientWidth)
	availablespace = availablespace - monthlygift.clientHeight;
	availablespace = availablespace - quarterlygift.clientHeight;
	
	monthlygift.style.left = findPosX(img_b) + img_b.clientWidth + (availablespace/3)+ "px";
	monthlygift.style.top = findPosY(img_b) + img_b.clientHeight - (monthlygift.clientHeight/2)+ "px";
	
	quarterlygift.style.left = findPosX(img_b) + img_b.clientWidth + (availablespace/3)+ monthlygift.clientWidth + (availablespace * .2) + "px";
	quarterlygift.style.top = findPosY(img_b) + img_b.clientHeight - (monthlygift.clientHeight/2) + "px";
    }
	
	var obj = img_b;
	img_bX = findPosX(obj);
	img_bY = findPosY(obj);
	
	stages.style.left = img_bX +  (img_b.clientWidth * 0.065) + "px";
	stages.style.top = img_bY + (img_b.clientHeight * 0.3) + "px";
	
	var obj = img_c;
	img_cX = findPosX(obj);
	img_cY = findPosY(obj);
	thisstage.style.top = img_cY + (img_c.clientHeight*0.4) + "px"
	thisstage.style.left = img_cX + (img_c.clientWidth*0.15) + "px"
	
	if (monthly)
	{
	var obj = monthly;
	monthlyX = findPosX(obj);
	monthlyY = findPosY(obj);
	
	//letsgetstarted.style.left = monthlyX + (img_a.clientWidth * 0.03) + "px";
	}
	else
	{
	var obj = monthlygift;
	monthlyX = findPosX(obj);
	monthlyY = findPosY(obj);
	//letsgetstarted.style.left = monthlyX + (img_a.clientWidth * 0.03) + "px";
	
	}
	
	
	
	var availablespace = (findPosX(img_a) + img_a.clientWidth) - (findPosX(img_b) + img_b.clientWidth) * 1.05
	var newtextsize = parseInt(letsgetstarted.style.fontSize) 
	
	
		
	
		while (letsgetstarted.clientWidth > availablespace)
		{
		newtextsize = newtextsize - 1
		letsgetstarted.style.fontSize = newtextsize + "px";
		}
	
	
		
	
	blength = (img_b.clientWidth - img_a.clientWidth) 
	textlength = letsgetstarted.clientWidth
	
	letsgetstartedleft = ((blength - textlength) * 0.51)
	letsgetstarted.style.top = findPosY(img_c) + (img_c.clientHeight) + 20 +  "px";
	letsgetstarted.style.left = findPosX(img_a) + img_a.clientWidth + letsgetstartedleft + "px";
	// make sure the text isnt too big for the space
	

	
	
	var obj = img_b;
	img_bY = findPosY(obj);
	img_bX = findPosX(obj);
	viewsocks.style.left = img_bX + (img_b.clientWidth - (viewsocks.clientWidth*1.1)) + "px";
	viewsocks.style.top = img_bY + (img_b.clientHeight * 1.02) + "px";
	
	
	footer.style.position = "absolute";
footer.style.width = "100%";
footer.style.left = "0px";

var obj = img_a;
img_aY = findPosY(obj);
footer.style.top = (img_aY + img_a.clientHeight)*1.05 + "px"


	manc.style.visibility = "visible";
	

	
	if (calledby == "load")
	{
	
			if (window.addEventListener)
			{
			window.addEventListener("resize", setup_newsubi_resize, false)
			}
			
			else if (window.attachEvent)
			{
			window.attachEvent("onresize", setup_newsubi_resize)
			}
	}
	
	runningfunction = "no"
}



//=====================================================================================


function reducetextsize(availablespace)
{
var letsgetstarted = document.getElementById("letsgetstarted")

	
	
	if (letsgetstarted.clientWidth > availablespace)
	{
	reducetextsize(availablespace)
	}
	
}


//=====================================================================================


function setup_newsuborder()

{
	var img_a = document.getElementById("img_a")
	var img_b = document.getElementById("img_b")
	var manc = document.getElementById("maincontainer")
	var ordersummary = document.getElementById("ordersummary")
	var thisstage = document.getElementById("thisstage")
	var topleft = document.getElementById("topleft")
	var main = document.getElementById("main")
	var footer = document.getElementById("footer")
	var orderform = document.getElementById("orderform")
	var ordertable = document.getElementById("ordertable")
	var letsgetstarted = document.getElementById("letsgetstarted")
	
	manc.style.width = (document.body.clientWidth * 0.8) + "px";
	manc.style.height = (document.body.clientHeight * 0.7) + "px";
	main.style.width = ( manc.clientWidth * 0.9 ) + "px";
	
	//manc.style.backgroundColor = "yellow";
	
	img_a.style.position = "absolute";
	img_b.style.position = "absolute";
	ordersummary.style.position = "absolute";
	thisstage.style.position = "absolute";
	orderform.style.position = "absolute";
	letsgetstarted.style.position = "absolute";
	ordertable.style.position = "absolute";
	
	var obj = topleft;
	topleftY = findPosY(obj);
	topleftX = findPosX(obj);
	
	img_a.style.top = topleftY + topleft.clientHeight + 20 + "px";
	img_a.style.left = topleftX + "px";
	
	var obj = img_a;
	img_aY = findPosY(obj);
	img_aX = findPosX(obj);
	
	ordersummary.style.top = img_aY + (img_a.clientHeight * 0.35) + "px";
	ordersummary.style.left = img_aX + 10 + "px";
		
	orderform.style.width = ((findPosX(manc) + manc.clientWidth) - (findPosX(img_a) + img_a.clientWidth)) * 0.85 + "px"
	orderform.style.height = ((findPosX(manc) + manc.clientWidth) - (findPosX(img_a) + img_a.clientWidth)) * 0.85 + "px"
	//orderform.style.backgroundColor = "red";
	orderform.style.left = findPosX(img_a) + img_a.clientWidth + 20 + "px";
	
	
	img_b.style.left = findPosX(orderform) + orderform.clientWidth - img_b.clientWidth  + "px";
	img_b.style.top = findPosY(orderform) - (img_b.clientHeight/3)  + "px";
	
	orderform.style.zIndex = "1";
	img_b.style.zIndex = "2";
	letsgetstarted.style.zIndex = "2";
	ordertable.style.zIndex = "2";
	thisstage.style.zIndex = "3";
	
	var obj = img_b;
	img_bY = findPosY(obj);
	img_bX = findPosX(obj);
	
	thisstage.style.top = img_bY +  (img_b.clientHeight/2) - (thisstage.clientHeight/2) + "px";
	thisstage.style.left = img_bX + (img_b.clientWidth/2) - (thisstage.clientWidth/2) + "px";
	
	letsgetstarted.style.top = findPosY(img_b) + (img_b.clientHeight * 1.03) + "px";
	letsgetstarted.style.left = findPosX(orderform) + "px";
	letsgetstarted.style.backgroundColor = "green";
	
	while (letsgetstarted.clientWidth > (orderform.clientWidth * 0.85))
	{
	newtextsize = parseInt(letsgetstarted.style.fontSize) - 1

	letsgetstarted.style.fontSize = newtextsize + "px";
	
	}
	letsgetstartedY = findPosY(ordersummary)
	letsgetstartedX = findPosX(letsgetstarted)
	ordertable.style.top = letsgetstartedY + "px";
	ordertable.style.left = letsgetstartedX + "px";
	
	
	footer.style.position = "absolute";
	footer.style.width = "100%";
	footer.style.left = "0px";
	
	var obj = img_a;
	img_aY = findPosY(obj);
	footer.style.top = (img_aY + img_a.clientHeight)*1.05 + "px"
	
	
	manc.style.visibility = "visible";
}


function adjusttextsize(availablespace)

{
	//alert("here   "+document.getElementById("letsgetstarted").clientWidth) 
document.getElementById("letsgetstarted").style.fontSize = "16px"; 
}
	
	

