﻿//Mike Marshall 2/22/2008
//JScript File

function Init()
{	
	FixSidebarHeight();
	// initialize the DHTML History
	//changeInputs();

}
function changeInputs()
{
	var els = document.getElementsByTagName('input');
	var elsLen = els.length;
	var i = 0;
	for ( i=0;i<elsLen;i++ )
	{
		if ( els[i].getAttribute('type') )
		{
			if (els[i].getAttribute('type') == "button")
				els[i].className = 'button';
			else
				els[i].className = 'text';
		}
	}
}

function WindowClose()
{
	if(confirm("Would you like to participate in our survey before exiting?", "yes", "no"))
		window.open("http://www.namifiers.com", "_blank", "", "");
}
	
	
function OnChange(colors)
{


    var selected = ""
    for(var i=0; i < colors; i++)
	{
        var dropdown = document.getElementById("ctl00_ContentMain_specPrinted_ColorDrop" + i);
		var box = document.getElementById("ctl00_ContentMain_specPrinted_ColorBox" + i);
		
	
		var myindex  = dropdown.selectedIndex
		var SelValue = dropdown.options[myindex].value
		if(SelValue == "Other")
		{
			
			box.style.display = '';
			box.value = "Specify Pantone Here";
		}
		else
		{
			box.style.display = 'none';		
			box.value = SelValue;
		}
		selected += SelValue + ":";
	}
	
}

function AddChatBox(chatID, name, msg, domain) {
	var ni = document.getElementById('ChatHolder');
	
	var ChatName = name;
	var Body = msg;
	if (name == null || ChatName == '')
		ChatName = 'Guest';
	if (msg == null)
		Body = "";
	
	var newdiv = document.getElementById('chat' + chatID);
	

	if (newdiv == null) {
		newdiv = document.createElement('div');
		
		var divIdName = 'chat' + chatID;
		newdiv.setAttribute('id', divIdName);
		newdiv.className = "ChatBox";		
		newdiv.style.margin ='100px 0px 0px 100px';


		//newdiv.innerHTML = "<h2>" + ChatName + "</h2><textarea id='boxMsg" + chatID + "' style='height:120px; width:392px; background: white;' readonly='true'>" + Body + "</textarea><input type='button' value='Send'  onclick=\"alert('');\" />";
		newdiv.innerHTML = "<a style='float:right;' href=\"javascript:RemoveChat('" + chatID + "');\"><img src='" + domain +"Framework/Images/cart-delete-item.gif' alt='Exit' /></a><h2>" + ChatName + "</h2><div id='boxMsg" + chatID + "' style='height:120px; width:392px; background: white; overflow: auto;' >" + Body + "</div><center><a href=\"javascript:RemoveChat('" + chatID + "');utilWindow('" + domain +"Chat/ChatRoom.aspx?room=" + chatID + "','480','400', 'no', 'no')\"><h2>Click to Respond</h2></a>";
		
		//Remove
		//newdiv.innerHTML = "<h2>" + ChatName + "</h2><textarea id='boxMsg" + chatID + "' style='height:120px; width:392px; background: white;' readonly='true'>" + Body + "</textarea><a style='float:right;' href=\"javascript:RemoveChat('" + chatID + "');\">Click to Respond</a>";
		
	}
	//utilWindow('Chat/ChatRoom.aspx?room=" + chatID + "','480','400', 'no', 'no')
	//<input type='text' style='width:320px' id='box'" + chatID + "' />
	else {
		var chatWindow = document.getElementById('boxMsg' + chatID);
		if (chatWindow != null) {
			chatWindow.innerHTML = msg;
		}

	}

	ShowChat(chatID);
	self.focus();
	ni.appendChild(newdiv);
}
function RemoveChat(chatID) {
	var div = document.getElementById('chat' + chatID);
	if (div != null) {
		div.style.display = 'none';
	}


}
function ShowChat(chatID) {
	var div = document.getElementById('chat' + chatID);
	if (div != null) {
		div.style.display = '';
	}


}
function FixSidebarHeight()
{
	var sidebar = document.getElementById("left-bar");
	var content = document.getElementById("content");
	var middle = document.getElementById("main");
	if (sidebar && content)
	{			
		if (content.offsetHeight >= sidebar.offsetHeight)
		{
			sidebar.style.height = content.offsetHeight + "px";
			content.style.height = content.offsetHeight + "px";			
			middle.style.height = content.offsetHeight + "px";
		}
		else
		{
			content.style.height = sidebar.offsetHeight + "px";
			sidebar.style.height = sidebar.offsetHeight + "px";			
			middle.style.height = sidebar.offsetHeight + "px";
		}		
	}	
	
}

function AddHeightToMiddle()
{
	
	var content = document.getElementById("content");
	content.style.height = (content.offsetHeight + 300) + "px";	
	FixSidebarHeight();
}




function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
	  elm = document.forms[0].elements[i]
	  if (elm.type == 'radio')
	  {
		 if (re.test(elm.name))
		 {
			elm.checked = false;
		 }
	  }
   }
   current.checked = true;
}
function OpenImageInNewWindow(imgsrc)
{
	/*
	var isMac = false;
	if(navigator.userAgent.toUpperCase().indexOf("SAFARI") != -1 || navigator.userAgent.toUpperCase().indexOf("MAC") != -1)
		isMac = true;
			
	if(!isMac)
	{	
		var newImage = new Image();
		newImage.src = imgsrc;
		for(var i =0; i < 10000; i++){}
	}	
	
	window.open(imgsrc,'_image','height='+ (isMac ? 300 : (newImage.height + 25)) +',width='+ (isMac ? '500 ,resizable' : (newImage.width + 25)) +',scrollbars=no,left=10,right=10');
	*/
	window.open(imgsrc, '_image', 'height=500, width=500, resizable, scrollbars=no');
	return false;
	
}
function utilWindow(url,W,H, toolbar, scroll)
{
	var uniqueId = 'NewWindow_' + new Date().getTime();
 	var width="700", height="450";
	if((W != null) || (H != null))
	{
	 var width=W, height=H;
	}
	var myToolBar = "yes";	
	
	if(toolbar != null)
	{
		myToolBar = toolbar;
		
	}
	var scrollbars = "yes";
	if(scroll != null)
	{
		scrollbars = scroll;
		
	}
	
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar='+myToolBar+',location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbars+',resizable='+scrollbars+',copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	open(url, uniqueId, styleStr);
}
function ShowDiv(div)
{	
	document.getElementById(div).style.display = '';		
}
function HideDiv(div)
{	
	document.getElementById(div).style.display = 'none';		
}