var domainVal = window.location.hostname;
var newDomainVal = cutDomainVal(domainVal);

function cutDomainVal(domainVal){

var domArray = domainVal.split('.');

if(domArray[0].indexOf("www") != -1 ){
	domArray[0] = "";
}

	return domArray.join(".");
}


/*if( GetCookieValue('BusinessUnit') == null ){
	frontierpopup=window.open ('/content/verizonglobalhome/ghp_frontieralert.aspx','Frontier','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=450,height=150');
	frontierpopup.moveTo('450','250');
}*/	

function GetCookieValue(cookie_name)
{ 
	var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	if ( results )
	{
			return ( unescape ( results[1] ) );
	}
	else
			return null;
}

function setCookie(b,d,a)
{
   // alert('value' + d);
    var e=new Date();
    var c=document.domain;
    e.setDate(e.getDate()+a);
    //alert(b+"="+escape(d));
    //alert(newDomainVal);
    document.cookie=b+"="+escape(d)+";path=/;domain="+newDomainVal+((a==null)?";":";expires="+e.toGMTString())
    //  document.cookie=b+"="+escape(d)+";path=/;domain=.verizon.com"+((a==null)?";":";expires="+e.toGMTString())
   //alert(document.cookie);
}
function deleteCookie(a)
{
    if(getCookie(a).length>0)
       {
            //document.cookie=a+"=;path=/;domain=.verizon.com;expires=Thu, 01-Jan-1970 00:00:01 GMT;"
            document.cookie=a+"=;path=/;domain="+newDomainVal+";expires=Thu, 01-Jan-1970 00:00:01 GMT;"
       }
}
function SetBusinessunitcookie(businessunit)
{
    var strbusinessUnit = businessunit;
    //alert(strbusinessUnit);
    if(strbusinessUnit == 'wireless')
    {
       // alert('its wireless');
        deleteCookie('BusinessUnit');
        setCookie('BusinessUnit','wireless',60);
        window.location = "http://www.verizonwireless.com/b2c/index.html"
        return false; 

    }
    else if(strbusinessUnit == 'business')
    {
        //alert('business');
        deleteCookie('BusinessUnit');
        setCookie('BusinessUnit','business',60);
        window.location = '/content/verizonglobalhome/ghp_business.aspx'; 
        return false; 

    }
    else if(strbusinessUnit == 'residential')
    {
         //alert('Residential');
        deleteCookie('BusinessUnit');
        setCookie('BusinessUnit','residential',60);
        window.location = '/'; 
        return false; 
       
    }
}
