/*dw_main.js*/
/*shared functions for site*/

var currentIndx = 0;

/* change the thumbnail of the web site style selector*/
function changeStyle()
{
	/* split the template number from the file name */
	var splitArray = document.dw_orderform._req_SiteStyle.options[document.dw_orderform._req_SiteStyle.selectedIndex].value.split('|');

	document.styleImage.src = 'images/' + splitArray[1] + '_small.gif';

	/*required to keep the slideshow functions up to date*/
	currentIndx=document.dw_orderform._req_SiteStyle.selectedIndex;
	
	return;
}

/* slideshow next function for the site styles on the order form*/
function nextStyle()
{
	if (currentIndx<document.dw_orderform._req_SiteStyle.length-1)
	{
		currentIndx=currentIndx+1;
		document.dw_orderform._req_SiteStyle.selectedIndex = currentIndx;
		changeStyle();
	}
	else
	{
		currentIndx=1;
		document.dw_orderform._req_SiteStyle.selectedIndex = currentIndx;
		changeStyle();
	}
	
	return;
}

/* slideshow previous function for the site styles on the order form*/
function prevStyle()
{
	if (currentIndx>1)
	{
		currentIndx=currentIndx-1;
		document.dw_orderform._req_SiteStyle.selectedIndex = currentIndx;
		changeStyle();
	}
	else
	{
		currentIndx=document.dw_orderform._req_SiteStyle.length-1;
		document.dw_orderform._req_SiteStyle.selectedIndex = currentIndx;
		changeStyle();
	}
	
	return;
}

/* pop open the appropriate large version from the web site style selector*/
function popupStyle()
{
	/* split the template number from the file name */
	var splitArray = document.dw_orderform._req_SiteStyle.options[document.dw_orderform._req_SiteStyle.selectedIndex].value.split('|');

	if (splitArray[1] != 'none_selected')
	{
		whereToGo = 'images/' + splitArray[1] + '_large.gif' ;
		myWin = window.open(whereToGo, 'dw_styleWin', 'width=690,height=490,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
		myWin.focus();
	}
	else
	{
		alert('You must select a style from the drop-down menu on the left.');
	}
	
	return;
}

function openWin(URL,w,h,WindowName)
{
	var build;
	var left = 0;
	var top = 0;
	var NewWindow = null;
	
	if (document.layers) //NS4
	{
		left = window.screenX + ((window.outerWidth - w) / 2);
		top = window.screenY + ((window.outerHeight - h) / 2);
		build = "screenX=" + left + ",screenY=" + top + ",resizable=yes,scrollbars=yes,width=" + w + ",height=" + h;
	}
	else if (document.all) //IE4
	{
		left = (screen.width - w) / 2;
		top = (screen.height - h) / 2;
		build = "left=" + left + ",top=" + top +
			",resizable=yes,scrollbars=yes,titlebar=no,status=no,width=" + w + ",height=" + h;
	}
	else
	{
		build = 'width='+w+',height='+h+',resizable=yes,scrollbars=yes';
	}

	NewWindow = window.open(URL, WindowName, build);
	NewWindow.focus();
	NewWindow.opener = self;
	
	return;
}

function CheckDomainAvail(fName)
{
	document.dw_orderform.DomainChecked.value = 1;
	appDest = "http://preview.i-2.com/:domaincheck?CustomerID=" +
		document.dw_orderform.elements[fName].value;
	openWin(appDest , 300, 200, "_dw_domain_check");
	
	return;
}
