var SubWindow;

function ChangeImage(ImageName)
{
	//alert(ImageName);
	//LinkImage.src = "images\\" + ImageName;
	LinkImage.src = ImageName;
}

function ConfirmDelete(ContentID)
{
	if(confirm("CAUTION: All data for ID " + ContentID + " will be deleted.  This action cannot be undone.\n\nClick 'Ok' to continue."))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ConfirmDelete_Images(ContentID)
{
	if(confirm("CAUTION: '" + ContentID + "' will be deleted.  This action cannot be undone.\n\nClick 'Ok' to continue."))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function CloseSubWindow()
{
	//alert("Hello");
	if(SubWindow)
	{
		if(SubWindow.closed)
		{
			//Do nothing
		}
		else
		{
			SubWindow.close();
		}
	}
}

function ChangeQty(e,txtBox)
{
	var unicode=e.keyCode? e.keyCode : e.charCode;
	if(unicode==38)		//Up arrow
	{
		if(isNaN(parseInt(txtBox.value)))
		{
			txtBox.value = 1;
		}
		else
		{
			if(parseInt(txtBox.value)<0)	//User may have entered a negative number
			{
				txtBox.value = 0;
			}
			else
			{
				txtBox.value = parseInt(txtBox.value)+1;
			}
		}
	}
	else if(unicode==40)	//Down arrow
	{
		if(isNaN(parseInt(txtBox.value)))
		{
				txtBox.value = 0;
		}
		else
		{
			if(parseInt(txtBox.value)<1)
			{
				txtBox.value = 0;
			}
			else
			{
				txtBox.value = parseInt(txtBox.value)-1;
			}
		}
	}
}

function PreviewContent(FormName)
{
	windowWidth = 1040;
	windowHeight = 400;
	
	if(SubWindow)
	{
		if(SubWindow.closed)
		{
			//Do nothing
		}
		else
		{
			SubWindow.close();
		}
	}
//alert(windowWidth + " x " + windowHeight);
	
	FormName.target="SubWindow";
	FormName.action="EditPage_PreviewContent.php";

	SubWindow = window.open('',"SubWindow","width=" + windowWidth + ",height=" + windowHeight + ",resizable=yes,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,copyhistory=no");
	
	FormName.submit();
	
	FormName.target="";
	FormName.action="EditPage_Submit.php";
//alert("Hello");
}

function ShowStyle(SampleText,Font,Bold,Italic,Underline,FontColor,BackgroundColor,FontSize,Hover_Underline,Hover_FontColor,MainBackgroundColor)
{
	var theText="";
	var theText2="";

//alert('SampleText');

	if(SubWindow)
	{
		if(SubWindow.closed)
		{
			//Do nothing
		}
		else
		{
			SubWindow.close();
		}
	}

	SubWindow = window.open('',"SubWindow","width=600,height=325,resizable=yes,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,copyhistory=no");
	theText = '<html><Head><Title>Font Preview</title>';
	theText += "<style type=text/css>\n";
	theText += ".Sample { ";
	theText += 'font-family:\'' + Font + '\'; ';
	theText2 = 'font-family:\'' + Font + '\'; ';
	//SubWindow.write('<span style="font-family:\'' + Font + \''; ');
	if(Bold=='Yes')
	{
		//SubWindow.write('font-weight: bold; ');
		theText += 'font-weight: bold; ';
		theText2 += 'font-weight: bold; ';
	}
	else
	{
		//SubWindow.write('font-weight: normal; ');
		theText += 'font-weight: normal; ';
		theText2 += 'font-weight: normal; ';
	}
	if(Italic=='Yes')
	{
		//SubWindow.write('font-style: italic; ');
		theText += 'font-style: italic; ';
		theText2 += 'font-style: italic; ';
	}
	else
	{
		//SubWindow.write('font-style: normal; ');
		theText += 'font-style: normal; ';
		theText2 += 'font-style: normal; ';
	}
	if(Underline=='Yes')
	{
		//SubWindow.write('text-decoration: underline; ');
		theText += 'text-decoration: underline; ';
	}
	else
	{
		//SubWindow.write('text-decoration: none; ');
		theText += 'text-decoration: none; ';
	}

	//SubWindow.write('color: ' + FontColor + '; ');
	//SubWindow.write('font-size: ' + FontSize + 'px; ');
	//SubWindow.write('">' . SampleText . '</span>');
	
	theText += 'color: ' + FontColor + '; ';
	if(BackgroundColor)
	{
		theText += 'background-color: ' + BackgroundColor + '; ';
	}
	theText += 'font-size: ' + FontSize + 'px; ';
	theText2 += 'font-size: ' + FontSize + 'px; ';
	theText += "}\n";
	theText += ".Sample:hover { ";
	if(Hover_Underline=='Yes')
	{
		//SubWindow.write('text-decoration: underline; ');
		theText2 += 'text-decoration: underline; ';
	}
	else
	{
		theText2 += 'text-decoration: none; ';
	}
	theText2 += 'color: ' + Hover_FontColor + "; }\n";


	theText += theText2;
	theText += ".SampleHover { ";
	theText += theText2;

	theText += "</style>\n";
	
	theText += "</head><body bgcolor=" + MainBackgroundColor + "><span class=Sample>";
	
	SubWindow.document.write(theText);
	
	//theText = SampleText + '</span>';
	theText = "This is ";
	theText += FontSize + "-pixel "
	if(Font!="")
	{
		theText += Font + ' font.<BR>';
	}
	else
	{
		theText += 'default font.<BR>';
	}
	if(Bold=='Yes')
	{
		theText += 'Bold: Yes<BR>';
	}
	else
	{
		theText += 'Bold: No<BR>';
	}
	if(Italic=='Yes')
	{
		theText += 'Italic: Yes<BR>';
	}
	else
	{
		theText += 'Italic: No<BR>';
	}
	if(Underline=='Yes')
	{
		theText += 'Underline: Yes<BR>';
	}
	else
	{
		theText += 'Underline: No<BR>';
	}
	theText += 'Color Code: ' + FontColor + "<BR>";
	if(BackgroundColor)
	{
		theText += 'Background Color Code: ' + BackgroundColor + '<BR></span>';
	}
	else
	{
		theText += 'Background Color Code: None<BR></span>';
	}
		
	
	SubWindow.document.write(theText);
	
	theText = "<span class=SampleHover><br>Hover Settings (applicable only to links):<br>\n";
	if(Hover_Underline=='Yes')
	{
		theText += "&nbsp;&nbsp;&nbsp;&nbsp;Underline: Yes<BR>";
	}
	else
	{
		theText += "&nbsp;&nbsp;&nbsp;&nbsp;Underline: No<BR>";
	}

	theText += '&nbsp;&nbsp;&nbsp;&nbsp;Color Code: ' + Hover_FontColor + "</span><span class=Sample><BR>\n";
	theText += "<BR>\n";
	theText += "&nbsp;&nbsp;&nbsp;&nbsp;**</span><a href='' class=Sample onClick='javascript:return false'>Hover over this text to see how the hover settings will behave.</a><span class=Sample>**</span>";
 	theText += "</body></html>"	
	SubWindow.document.write(theText);
}

function ShowImage(imagePath)
{
	var windowWidth = 0
	var windowHeight = 0
	var theImage = new Image();

	if(imagePath.substring(imagePath.length-1)=="/")
	{
		alert("No image selected");
		return false;
	}

	theImage.src = imagePath;
	
	windowWidth = theImage.width + 40;
	windowHeight = theImage.height + 35;
	
	if(SubWindow)
	{
		if(SubWindow.closed)
		{
			//Do nothing
		}
		else
		{
			SubWindow.close();
		}
	}
//alert(windowWidth + " x " + windowHeight);

	SubWindow = window.open(imagePath,"SubWindow","width=" + windowWidth + ",height=" + windowHeight + ",resizable=yes,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,copyhistory=no");
	
}

function ShowPage(PagePath)
{

	windowWidth = 1040;
	windowHeight = 400;
	
	if(SubWindow)
	{
		if(SubWindow.closed)
		{
			//Do nothing
		}
		else
		{
			SubWindow.close();
		}
	}
//alert(windowWidth + " x " + windowHeight);

	SubWindow = window.open(PagePath,"SubWindow","width=" + windowWidth + ",height=" + windowHeight + ",resizable=yes,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,copyhistory=no");
	
}

function AvoidNeg1(FormElement)
{
	//alert(FormElement.selectedIndex);
	if(FormElement.value==-1)
	{
		FormElement.selectedIndex=FormElement.selectedIndex-1;
	}
}