﻿// JScript File
    
function checkpo(e, ctl)
    {
        if(e == null) 
            {
                var url = 'ajaxstuff.aspx?T=checkpo&PO=' + ctl.value;
                ajaxMsgBox(url, ctl.id, true)
                return true;
            }
        else
            {
                if(e.keyCode == 13) 
                    {
                        document.getElementById('ctl00_ContentPlaceHolder1_CustInfo1_txtContact').focus();
                        return true;
                    }
            }
    }

function getpagetitle()
    {
        var id = location.search.toUpperCase(); 
        if(id == '')
            document.title = 'Nourison Industries, Inc - Area Rugs, Broadloom, Custom Rugs, Roll Runners, Accents, Scatters';
        else
            {
                id = id.replace("?", "").replace("=", ":");
                var url = 'http://www.nourison.com/ajaxcode/default.aspx?T=checkstock&P=' + id;
                alert(url);
                //ajaxPageTitleFunction(url, async)
            }
    }
function checkloginfordeleted()
	{
		var u = document.getElementById('ctl00_ContentPlaceHolder1_txtUserID').value;
		var msg = '';
		if(u.toLowerCase() == 'rugs')
			{
				msg = 'The User ID: RUGS, is no longer available.\r\n';
				msg = msg + 'Employees please Click on Consumer Registration.\r\n';
				msg = msg + 'Employees must use their valid nourison.com email address.\r\n';
			}

		if(u.toLowerCase() == 'retail')
			{
				msg = 'The User ID: RETAIL, is no longer available.\r\n';
				msg = msg + 'Dealers please Click on the Dealer Registration.\r\n';
				msg = msg + 'Use your Account # and Bill-To Zip to Register.\r\n';
			}
		if(msg != '')
			{
				alert(msg);
				return false;
			}
		else
			return true;
		
	}
function checkredirects()
    {
        var id=location.search.toUpperCase(); //this line read the querystring passed in the url (everything from ?->)
        if(id.search('FORM') > -1) //this line checks to see if the word FORM is in the querystring)
            {
                //copy from here
                if(id.search('ADVSVC') > -1) //this line checks to see if the keyword for redirect exists in the querystring
                    {
                        msg = 'Please note that this link has changed\n\r';
                        msg = msg + 'If you have bookmarked this page, please\n\rupdate your bookmark.\n\r';
                        alert(msg);
                        document.location.replace('Main.aspx?FORM=marketing'); //this replaces the current page with the new
                    }
               //to here
               //for new pages, copy the above code, chnage the keywords and paste if below this line but before }
            }
            
    }
function registerselect()
    {
        popup_show('ropup', 'ropup_drag', 'ropup_exit', 'screen-center', 10, 0);
    }

function login()
    {
        popup_show('popup', 'popup_drag', 'popup_exit', 'screen-center', 10, 0);
        document.getElementById('txtuserid').focus();
    }

function enterskus() //to enter skus directly in to rug cart
    {
        popup_show('skuin', 'skuin_drag', 'skuin_exit', 'screen-center', 10, 0);
        document.getElementById('txtsku').focus();
    }
    
function forgotpassword() 
    {
        document.getElementById('popup').style.visibility='hidden';
        popup_show('fopup', 'fopup_drag', 'fopup_exit', 'screen-center', 10, 0);
    }
function dealerrequest() 
    {
        document.getElementById('dlreq').style.visibility='hidden';
        popup_show('dlreq', 'dlreq_drag', 'dlreq_exit', 'screen-center', 10, 0);
    }
//****************************************************************************************************************************
//* Search Functions
//****************************************************************************************************************************
function asearch()  //advanced search option
    {
        //document.getElementById('popup').style.visibility='hidden';
        //popup_show('searc', 'searc_drag', 'searc_exit', 'screen-center', 10, -200);
        alert('Sorry, Advanced Search is not available');
    }
function submitsimplesearch() //simple search option
		{
		    ctl = window.document.getElementById("txtcriteria");
		    if(ctl.value != '')
		        {		        
			        window.location.replace("SearchResults.aspx?CRIT=" + ctl.value);
			        return true;
			    }
		}

//captures return key in simple search text box
function checkkeypressed(e)
	{
		if(window.event)
			{
				keynum = e.keyCode;
			}
		else
			{
				if(e.which)
					{
						keynum = e.which;
					}
			}
		if (keynum 	== 13)
			{
				submitsimplesearch();
			}
		else
		    return false;
	}

//******************************************************************************************************************************
//Below Required so ie 6 will work with css menus
//******************************************************************************************************************************
sfHover = function() 
		{    
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		     	for (var i=0; i<sfEls.length; i++) 
				{         
					sfEls[i].onmouseover=function() 
						{             
							this.className+=" sfhover";
					         }
				        sfEls[i].onmouseout=function() 
						{
					             this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
					         }     
				} 
		} 

if (window.attachEvent) window.attachEvent("onload", sfHover); 
//******************************************************************************************************************************
//Above Required so ie 6 will work with css menus
//******************************************************************************************************************************

//******************************************************************************************************************************
//below resizes the iframe for the know wher map and results
//******************************************************************************************************************************
function ResizeIFrame()
{
var objFramePage = window.document.frames("myframe").document.body;
var objFrame = window.document.getElementById("myframe");
objFrame.style.height = objFramePage.scrollHeight + (objFramePage.offsetHeight - objFramePage.clientHeight);
}
//******************************************************************************************************************************
//above resizes the iframe for the know wher map and results
//******************************************************************************************************************************
