document.cookie = 'userScreenWidth=' + screen.width;

var StartLeft = parseInt((screen.width/2) - 275);
var StartTop = parseInt((screen.height/2)- 188.5);

 function NewWindows2(url)
{
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight

    swidth = screen.availWidth;
    sheight = screen.availHeight;
    jumpToHere = url ;
    winOptions = 'Height=' + sheight + ', Width=' + swidth +',scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

function setinnerHeight(hdr)
{
var intSubtract

if(hdr == "HdrOut")
    {
    intSubtract = 183
    }
else
    {
    intSubtract = 60
    }
if (window.innerHeight) 
    {
    theHeight=window.innerHeight;
    }
else if (document.documentElement && document.documentElement.clientHeight) 
    {
    theHeight=document.documentElement.clientHeight;
    }
else if (document.body) 
    {
    theHeight=document.body.clientHeight;
    }
    
if(parseInt(theHeight) < parseInt(document.body.scrollHeight))
    {
    theHeight=document.body.scrollHeight + 5;
    }    

document.getElementById("LeftBar").style.height=(theHeight-intSubtract) +'px';
}

function valsearchfrm()
{
if(document.membersearch.State.value=='')
    {
    alert('Please select a State');
    return false;
    }
if(document.membersearch.ZipCode.value=='')
    {
    alert('Please enter your Zip Code');
    document.membersearch.ZipCode.focus()
    return false;
    }
if(document.membersearch.ZipCode.value.length !=5)
    {
    alert('Please enter a valid 5 digit Zip Code');
    document.membersearch.ZipCode.select()
    return false;
    }

var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
sText = document.membersearch.ZipCode.value
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   
 if(IsNumber == false)
    {
      alert('Zip Code must be a 5 digit number');
      return false;
    }

return true;   
}

function valOption2()
{
if(document.newmemberoption3.Domain.value=='')
    {
    alert('Please enter a valid website url');
    document.newmemberoption3.Domain.select();
    return false;
    }
if(document.newmemberoption3.Company.value=='')
    {
    alert('Company is required');
    document.newmemberoption3.Company.select();
    return false;
    }
    
if(document.newmemberoption3.Contact.value=='')
    {
    alert('Contact is required');
    document.newmemberoption3.Contact.select();
    return false;
    }
    
if(document.newmemberoption3.Street.value=='')
    {
    alert('Street is required');
    document.newmemberoption3.Street.select();
    return false;
    }
if(document.newmemberoption3.City.value=='')
    {
    alert('City is required');
    document.newmemberoption3.City.select();
    return false;
    }
if(document.newmemberoption3.State.value=='')
    {
    alert('Please select your State');
    document.newmemberoption3.State.focus();
    return false;
    }
if(document.newmemberoption3.ZipCode.value=='')
    {
    alert('Please enter your Zip Code');
    document.newmemberoption3.ZipCode.focus()
    return false;
    }
if(document.newmemberoption3.ZipCode.value.length !=5)
    {
    alert('Please enter a valid 5 digit Zip Code');
    document.newmemberoption3.ZipCode.select()
    return false;
    }
if(document.newmemberoption3.Email.value=='')
    {
    alert('Email is required');
    document.newmemberoption3.Email.select();
    return false;
    }    
if(document.newmemberoption3.Password.value=='')
    {
    alert('Password is required');
    document.newmemberoption3.Password.select();
    return false;
    }    
if(document.newmemberoption3.Phone.value=='')
    {
    alert('Phone is required');
    document.newmemberoption3.Phone.select();
    return false;
    }    
if(document.newmemberoption3.Comments.value=='')
    {
    alert('The consumer needs to know a little about your company');
    document.newmemberoption3.Comments.select();
    return false;
    }    
if(document.newmemberoption3.KeyWords.value=='')
    {
    alert('You should enter some search words to help the consumer better locate your company');
    document.newmemberoption3.KeyWords.select();
    return false;
    }    

if(confirm('You are about to submit your NRN listing.\nIf all information is correct click OK\nIf you would like to make a change click Cancel'))
    {
    return true;
    }
else
    {
    return false;
    }   
}


function valOption3()
{
if(document.newmemberoption3.Company.value=='')
    {
    alert('Company is required');
    document.newmemberoption3.Company.select();
    return false;
    }
    
if(document.newmemberoption3.Contact.value=='')
    {
    alert('Contact is required');
    document.newmemberoption3.Contact.select();
    return false;
    }
    
if(document.newmemberoption3.Street.value=='')
    {
    alert('Street is required');
    document.newmemberoption3.Street.select();
    return false;
    }
if(document.newmemberoption3.City.value=='')
    {
    alert('City is required');
    document.newmemberoption3.City.select();
    return false;
    }
if(document.newmemberoption3.State.value=='')
    {
    alert('Please select your State');
    document.newmemberoption3.State.focus();
    return false;
    }
if(document.newmemberoption3.ZipCode.value=='')
    {
    alert('Please enter your Zip Code');
    document.newmemberoption3.ZipCode.focus()
    return false;
    }
if(document.newmemberoption3.ZipCode.value.length !=5)
    {
    alert('Please enter a valid 5 digit Zip Code');
    document.newmemberoption3.ZipCode.select()
    return false;
    }
if(document.newmemberoption3.Email.value=='')
    {
    alert('Email is required');
    document.newmemberoption3.Email.select();
    return false;
    }    
if(document.newmemberoption3.Password.value=='')
    {
    alert('Password is required');
    document.newmemberoption3.Password.select();
    return false;
    }    
if(document.newmemberoption3.Phone.value=='')
    {
    alert('Phone is required');
    document.newmemberoption3.Phone.select();
    return false;
    }    
if(document.newmemberoption3.Comments.value=='')
    {
    alert('The consumer needs to know a little about your company');
    document.newmemberoption3.Comments.select();
    return false;
    }    
if(document.newmemberoption3.KeyWords.value=='')
    {
    alert('You should enter some search words to help the consumer better locate your company');
    document.newmemberoption3.KeyWords.select();
    return false;
    }    

if(confirm('You are about to submit your NRN listing.\nIf all information is correct click OK\nIf you would like to make a change click Cancel'))
    {
    return true;
    }
else
    {
    return false;
    }   
}

function getweather()
  {
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight
 
    swidth = screen.availWidth
    sheight = screen.availHeight
 
    jumpToHere = 'http://www.weather.com/weather/local/' + document.weather.local.value + '?from=tabset';;
    winOptions = "outerWidth=" + swidth + ", outerheight=" + sheight + ",scrollbars=yes,resizable=yes";
    //document.location.href='http://www.weather.com/weather/local/' + document.weather.local.value + '?from=tabset';
    popUpWindow = open(jumpToHere, "MyWindow", winOptions);
}

function valOption1()
{
if(document.option1frm.Template(0).checked == false && document.option1frm.Template(1).checked == false && document.option1frm.Template(2).checked == false && document.option1frm.Template(3).checked == false && document.option1frm.Template(4).checked == false && document.option1frm.Template(5).checked == false)
    {
    alert('You have not selected a website template')
    return false;
    }
if(document.option1frm.CurrentEmail.value=='')
    {
    alert('Current Email is Required')
    return false;
    }
if(document.option1frm.SubDomain.value=='')
    {
    alert('Please enter a Company Name for your website')
    return false;
    }
     
if(confirm('You are about to create your new member website,\nonce the setup is done you will be taken to your website\nand you can start adding your content.\nTo continue click OK, To stop now click Cancel'))
    {
    return true;
    }
else
    {
    return false;
    }
}

function MyRollover(x,y)
{
alert(x + ' - ' + y);
if (document.images)
        document.images[x].src ='./images/' + y;
}

function HideDiv(divObj)
{
var CurDiv = document.getElementById(divObj)

CurDiv.style.display = "none"
}

function ShowDiv2(divObj,e)
{
divName ='spanContent';
var CurDiv = document.getElementById(divObj);
if(CurDiv)
    {
    if (document.all)
        { //IS IE 4 or 5 (or 6 beta)
        //document.getElementById(divName).style.width = document.getElementById('divMap').style.width
        document.getElementById(divName).style.display = 'block';
        document.getElementById(divName).innerHTML  = document.getElementById(divObj).innerHTML;
        document.getElementById(divName).style.left = e.x + 'px'; 
        document.getElementById(divName).style.top  = e.y + 'px';
        }
    if (document.layers)
        { //IS NETSCAPE 4 or below
        document.layers[divName].style.display = 'block';
        document.layers[divName].innerHTML  = document.layers[divObj].innerHTML;
        document.layers[divName].style.left = event.x + 'px'; 
        document.layers[divName].style.top  = event.y + 'px';
        }
    if (document.getElementById &&!document.all)
        {
        document.getElementById(divName).style.display = 'block';
        document.getElementById(divName).innerHTML  =  document.getElementById(divObj).innerHTML;
        document.getElementById(divName).style.left = e.pageX + 'px'; 
        document.getElementById(divName).style.top  = e.pageY + 'px'; 
        }
    }
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

if(document.getElementById('divMap').style.width == "552px" )
    {
    var imgHalf = 275
    }
else
    {
    var imgHalf = 225
    }
        
  StartLeft = parseInt((myWidth/2) - parseInt(imgHalf))
  StartTop = myHeight/2
  //window.alert( 'Width = ' + myWidth + ', ' + parseInt((myWidth/2) - parseInt(imgHalf)) );
  //window.alert( 'Height = ' + myHeight );
}
function centerMap()
{
if (document.all)
    { //IS IE 4 or 5 (or 6 beta)
    document.getElementById('divMap').style.left = StartLeft + 'px';
    document.getElementById('divMap').style.display='block'; 
    }
if (document.layers)
    { //IS NETSCAPE 4 or below
    document.layers['divMap'].style.left = StartLeft + 'px';
    document.layers['divMap'].style.display='block'; 
    }
if (document.getElementById &&!document.all)
    {
    document.getElementById('divMap').style.left = StartLeft + 'px';
    document.getElementById('divMap').style.display='block';  
    }
}


function mouseX(evt) {
if (evt.pageX) alert('pageX' + evt.pageX);
else if (evt.clientX)
   alert( 'clientX' +  evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft));
else alert('none');
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function valnewpage()
{

if(document.newpage.pagename.value =='' || document.newpage.pagename.value =='enter page name')
    {
    alert('No page name entered');
    document.newpage.pagename.value='';
    document.newpage.pagename.focus();
    return false;
    }
else
    {
    if(confirm('The page you are about to create will be copied from the template.asp page.\nTo continue click OK, To stop now click Cancel.'))
        {
        return true;
        }
    else
        {
        return false;
        }
    }
}

 function NewWindows(url,intWidth)
{
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight

    swidth = intWidth + 'px';//screen.availWidth
    sheight = '400px';

    if(typeof(intWidth)=='undefined')
       {
           swidth = screen.availWidth + 'px';
           sheight = screen.availHeight + 'px';
       }

        jumpToHere = url ;
    winOptions = 'Height=' + sheight + ', Width=' + swidth +',left=0,top=0,scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

function ShowDiv(divObj)
{
var CurDiv = document.getElementById(divObj)
if(CurDiv.style.display == "block")
    {
    CurDiv.style.display = "none"
    }
else
    {
    var divs = document.getElementsByTagName('div') 
    for (var i=0;i<divs.length;i++)
    { 
    if (divs[i].style.display =='block')
        {
        divs[i].style.display ='none'
        }
    }
    
    hza = document.getElementById(divObj);
    hza.style.display = "block" ;
    }
}

function ShowIframe()
{
var CurFrame = document.getElementById('addonconfig')

CurFrame.style.display = "block"

}

function HideIframe()
{
var CurFrame = document.getElementById('addonconfig')

CurFrame.style.display = "none"

}

function valEmailFrm(frm)
{

var str =  document[frm].Email.value
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)

if(document[frm].Contact.value=='')
  {
   alert('Contact name is required');
   return false;
  }

if(document[frm].Email.value=='')
  {
   alert('Email is required');
   return false;
  }

if (str.indexOf(at)==-1)
            {
           alert("Invalid Email Address")
           return false
            }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
            {
           alert("Invalid Email Address")
           return false
            }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
            {
            alert("Invalid Email Address")
            return false
            }

         if (str.indexOf(at,(lat+1))!=-1)
            {
            alert("Invalid Email Address")
            return false
            }

         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
            {
            alert("Invalid E-mail Address")
            return false
            }

         if (str.indexOf(dot,(lat+2))==-1)
            {
            alert("Invalid Email Address")
            return false
            }
        
         if (str.indexOf(" ")!=-1)
            {
            alert("Invalid Email Address")
            return false
            }

if(document[frm].Subject.value=='')
  {
   alert('Subject is required');
   return false;
  }

if(document[frm].Comments.value=='')
  {
   
if(frm =='frmquestion')
{
var fldmsg ='You have not entered a question'
}
else
{
varcfldmsg ='You have not entered any comments regarding the service your are inquiring about'
}
   alert(fldmsg);
   return false;
  }

if(frm =='frmquestion')
{
msgtxt ='You are about to submit a question to Need Roof Now support.\nTo continue click OK, To stop now click Cancel'
}
else
{
msgtxt ='You are about to submit a service request email to the selected member.\nTo continue click OK, To stop now click Cancel'
}

if(confirm(msgtxt))
    {
    return true;
    }
else
    {
    return false;
    }
}

function valpromo()
{
    if(document.promo.code.value=='' || document.promo.code.value=='enter promo code')
         {
          alert('Please enter a promo code');
          return false;
           }
return true;
}

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

var browserName = whichBrs();

function MyOn(x,y)
{
if (document.images)
        document.images[x].src ='./images/banners/' + y;
else
    {
    alert('error');
    }
}

function MyOff(x,y)
{
if (document.images)
        document.images[x].src ='./images/banners/' + y;

}

function gobanner(x,y)
{
   var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight;

    swidth = screen.availWidth;
    sheight = screen.availHeight;
    jumpToHere = './clickthru.asp?id=' + x + '&traclog=1&url=' + y;
    winOptions = 'Height=' + sheight + ', Width=' + swidth +',scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19083862-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

