/***************************************************************/

String.prototype.isArgument=function()
{
	return /^([a-zA-Z]){1,}=([0-9]){1,}$/.test(this);
}


/*
call this function just work like window.open(url,name,feature);
however, for IE5.0+, it will open a showModelessDialog window;
and For Gecko(Mozilla or Netscape), the child window will stay on top focus untill user close it.
programmed by hedger
hedger@yahoo-inc.com
*/


function dialog(url,name,feature,isModal)
{
 if(url==null){return false;}
 url = url
 if(name==null){name=""}
 if(feature==null){feature=""};
 if(window.showModelessDialog)
 {
  	var WindowFeature = new Object();
	WindowFeature["width"] = 400;
	WindowFeature["height"]  =400;
	WindowFeature["left"]  = "";
	WindowFeature["top"]  =  "";
	WindowFeature["resizable"]  = "";

	if(feature !=null && feature!="")
	{
      feature = ( feature.toLowerCase()).split(",");
	
      for(var i=0;i< feature.length;i++)
		{
          if( feature[i].isArgument())
			{
               var featureName = feature[i].split("=")[0];
			   var featureValue = feature[i].split("=")[1];
			  
			   if(WindowFeature[featureName]!=null){WindowFeature[featureName] = featureValue; }
			}
		}
	}
 
  if(WindowFeature["resizable"]==1 || WindowFeature["resizable"]=="1" || WindowFeature["resizable"].toString().toLowerCase()=="yes"){WindowFeature["resizable"] = "resizable:1;minimize:1;maximize:1;"}
  if(WindowFeature["left"]!=""){WindowFeature["left"] ="dialogLeft:" +  WindowFeature["left"] +"px;";}
  if(WindowFeature["top"]!=""){WindowFeature["top"] ="dialogTop:" +  WindowFeature["Top"] +"px;"; }
  if(window.ModelessDialog ==null){window.ModelessDialog = new Object() ; };
  if(name!="")
  {
   if(window.ModelessDialog[name]!=null && !window.ModelessDialog[name].closed )
   {
     window.ModelessDialog[name].focus();
	 return window.ModelessDialog[name];
   }
  }
	var F = WindowFeature["left"] +WindowFeature["top"] +  "dialogWidth:"+WindowFeature["width"] +" px;dialogHeight:"+WindowFeature["height"]+"px;center:1;help:0;" + WindowFeature["resizable"] +"status:0;unadorned:0;edge: raised; ;border:thick;"
	if(isModal)
	{
		window.showModalDialog(url,self,F);
		return false;
	}
	else
	{
		window.ModelessDialog[name] = window.showModelessDialog(url,self,F);
		return window.ModelessDialog[name];
	}	
 }
 else
 {
   if(document.getBoxObjectFor)
   {
	

	 if(isModal)
	 {		 
		 var Modal = window.open(url,name,"modal=1," + feature);
		 var ModalFocus = function()
		 {
			if(!Modal.closed){Modal.focus();}
			else{Modal =null;window.removeEventListener(ModalFocus,"focus");ModalFocus = null; };					
		 }
		 window.addEventListener( "focus",ModalFocus, false ); 
		 return false;
	 }
	 else
	 {
		return window.open(url,name,"modal=1," + feature);
	 }	 
   }
   else
   { 
     return window.open(url,name,feature);
   }
 }
 return null;
}
  
function modal(url,feature)
{
	dialog(url,"",feature,true);
	return false;
}
/*****************************************************************/

	function ShowEmail(dlgWith,dlgHeight)
	{
		var leftVal = (screen.width - dlgWith)/2;
		var topVal  = (screen.height - dlgHeight)/2;
		var dlg;
		dlg = window.open('Dialogs/eMailPopUp.aspx','Email','dependent=1,width='+dlgWith+',height='+dlgHeight+',left='+leftVal+',top='+topVal+',scrollbars=0,toolbars=0,resizable=0,status=0');
		dlg.focus();
	}
	function ShowWarranty(dlgHeight,dlgWith)
	{		
		var leftVal = (screen.width - dlgWith)/2;
		var topVal  = (screen.height - dlgHeight)/2;
		var addr = "http://www.us.kohler.com/general/warranty.jsp";
		
		window.modal(addr,'dependent=1,width='+dlgWith+',height='+dlgHeight+',left='+leftVal+',top='+topVal+',scrollbars=yes,toolbars=0,resizable=0');		
	}	

	function ShowReturnPolicy(dlgWith,dlgHeight)
	{				
		var leftVal = (screen.width - dlgWith)/2;
		var topVal  = (screen.height - dlgHeight)/2;
		var wnd = window.open('','example','width='+dlgWith+',height='+dlgHeight+',left='+leftVal+',top='+topVal+',status=0,menu=0');
		wnd.focus();
		wnd.document.open();
		wnd.document.write("<HTML><HEAD><LINK REL=STYLESHEET TYPE=TEXT/CSS HREF=CSS/SUBMODAL.CSS/></HEAD><BODY>");
		wnd.document.write("<DIV ALIGN=CENTER WIDTH=300><FONT CLASS=SHOPPINGWARRANTYFONT>");
		wnd.document.write("Must be returned within 45 days of the Kohler shipped<br> date. Must be in new and saleable condition. Must<br>");
		wnd.document.write("have prior authorization from Kohler. Items returned<br> without authorization will be disposed of without credit<br>");
		wnd.document.write("being issued. To obtain authorization call 1-800-456-<br>4537");
		wnd.document.write("</DIV></BODY></HTML>");
		wnd.document.close();		
	}
	
	function ShowChangeColor(addr)
	{
		var dlgWith = 520;
		var dlgHeight = 610;
		var leftVal = (screen.width - dlgWith)/2;
		var topVal  = (screen.height - dlgHeight)/2;		
		window.open(addr,'','status=1,width='+dlgWith+',height='+dlgHeight+',left='+leftVal+',top='+topVal+',scrollbars=0,toolbars=1,resizable=1');		
	}	