var windowOpenProps = "height="+screen.availHeight+", width="+screen.availWidth+",left=0,top=0,resizable=yes,outerWidth=0,outerHeight=0,menubar=yes,status=yes,scrollbars=yes,directories=yes,location=yes,toolbar=yes";


if(window.name=="")
{

//    window.name = "WebWindow";
    
}



function openPortalItem(portalUrl)
{
    
    
     var w = window.open( getSSLURL(portalUrl),"PortalWindow",windowOpenProps);
     w.focus();

}


function submitForm(formName)
{   
    

    if(formName == 'chkLoginForm')
    {
        
     if(document.forms[formName].elements['portlet_5_6{actionForm.userName}'].value=="" || document.forms[formName].elements['portlet_5_6{actionForm.password}'].value=="")
         {
             alert("UserName/Password fields cannot be left blank");
         }
       else
         {  
  
              

		//document.forms(formName).action = '/LICEPS/appmanager/Visitor/VisitorHome?_nfpb=true&portlet_5_6_actionOverride=/Login/chkLogin';

		//document.forms(formName).action   = getSSLURL('/LICEPS/appmanager/Visitor/VisitorHome?_nfpb=true&portlet_5_6_actionOverride=/Login/chkLogin');

		document.forms[formName].action   = '/LICEPS/Login/webLogin.do';
        
	//	var w = window.open("","PortalWindow",windowOpenProps);
	//	document.forms[formName].target = "PortalWindow";
		//w.focus();
		document.forms[formName].submit();
        
        }
	}
    if(formName == 'chkMerchantLoginForm')
    {
        
     if(document.forms[formName].elements['vistorLoginPage{actionForm.userName}'].value=="" || document.forms[formName].elements['vistorLoginPage{actionForm.password}'].value=="")
         {
             alert("UserName/Password fields cannot be left blank");
         }
       else
         {  
  
              

		
		document.forms[formName].action   = '/LICMerchant/Login/webLogin.do';        
		document.forms[formName].submit();        
        }

       // document.forms[formName].reset();
    }  
}


function validateSearchInput()
        {
            var empty = isEmptyCheck();
            if(empty == false)
            { 
                var searchString  = searchBox.value;
                //var searchWindow = window.open('/LICEPS/appmanager/Generic/PortalSearchHome?searchingString='+searchString,"Portal_Search","toolbar=yes,scrollbars=yes,resizable=yes,height=500,left=0,top=0");

		//var searchWindow = window.open(getSSLURL('/LICEPS/appmanager/Generic/PortalSearchHome?searchingString='+searchString,"Portal_Search","toolbar=yes,scrollbars=yes,resizable=yes,height=500,left=0,top=0"));
                //searchWindow.focus();
		document.forms['portalSearch'].action = document.forms['portalSearch'].action + searchString;
		document.forms['portalSearch'].submit();
            }
        }
        
        function isEmptyCheck()
        {
            var sString = ltrim(rtrim(document.portalSearch.searchString.value));
            if(sString == '')
            {
                alert("Search field is empty, please enter your search String Crieteria");
                return true;
            }
            else
            {
                return false;
            }
        }
        
        function ltrim(s)
        {
            temp=""
            for (i=0;i<s.length;i++)
            {
                if (s.charAt(i)!=" " )
                {
                    temp+=s.substring(i)
                    break
                }
            } 
            return temp
        }
  

        function rtrim(s)
        {
            temp=""
            for(i=s.length;i>=0;--i)
            { 
                if (s.charAt(i-1)!=" ")
                { 
                    temp+=s.substring(0,i)
                    break
                }
            }
            return temp
        }

function getServerName(url)
{
    var dblSlash   = url.indexOf('//')+2;
    var slash      = url.indexOf('/',dblSlash);

    var serverName = url.substring(dblSlash,slash);
    return serverName;
}

function getSSLURL(url)
{
    return 'http://'+getServerName(window.location.href)+url;
}

function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin"; 
}
