var cssmenuids=["cssmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-1 //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
            ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
        var spanref=document.createElement("span")
            spanref.className="arrowdiv"
            spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"
            ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
        ultags[t].parentNode.onmouseover=function(){
                    this.style.zIndex=100
        this.getElementsByTagName("ul")[0].style.visibility="visible"
                    this.getElementsByTagName("ul")[0].style.zIndex=0
        }
        ultags[t].parentNode.onmouseout=function(){
                    this.style.zIndex=0
                    this.getElementsByTagName("ul")[0].style.visibility="hidden"
                    this.getElementsByTagName("ul")[0].style.zIndex=100
        }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu2)

function valSupport()
{
document.frmCCP.ssl_merchant_id.value='541629';
document.frmCCP.ssl_pin.value='G0HMUQ';
document.frmCCP.ssl_user_id.value='webpage';
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();
//alert(browserName);

var strvalcode
var strvalcodeLC

function GenerateSpam() {
 var imgName
    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0 browsers");
        return true;
    }

    var length=5;
    var sPassword = "";
    var sPasswordLC = "";

    var noPunction = true //(document.register.punc.checked);
    var randomLength = false // (document.register.rLen.checked);

    if (randomLength) {
        length = Math.random();

        length = parseInt(length * 100);
        length = (length % 7) + 6
    }


    for (i=0; i < length; i++) {

        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

        sPassword = sPassword + String.fromCharCode(numI).toUpperCase() ;
        sPasswordLC = sPasswordLC + String.fromCharCode(numI).toLowerCase() ;
        imgName = 'img' + i
        //alert(imgName);
        document.images[imgName].src ='./images/spam-filter/' + String.fromCharCode(numI) + '.gif';
    }
    strvalcode = sPassword;
    strvalcodeLC = sPasswordLC;
    return true;
}

function getRandomNum() {

    // between 0 - 1
    var rndNum = Math.random()

    // rndNum from 0 - 1000
    rndNum = parseInt(rndNum * 1000);

    // rndNum from 33 - 127
    rndNum = (rndNum % 94) + 33;

    return rndNum;
}

function checkPunc(num) {

    if ((num >=33) && (num <=47)) { return true; }
    if ((num >=58) && (num <=64)) { return true; }
    if ((num >=91) && (num <=96)) { return true; }
    if ((num >=123) && (num <=126)) { return true; }

    return false;
}

function myVoid()
{;}

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 = 'outerHeight=' + sheight + ', outerWidth=' + swidth +',scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

 function gobanner2(y)
{
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight

    swidth = screen.availWidth;
    sheight = screen.availHeight;
    jumpToHere = y ;
    winOptions = 'outerHeight=' + sheight + ', outerWidth=' + swidth +',scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

function showhide(layer_ref)
{

if (document.all)
    { //IS IE 4 or 5 (or 6 beta)
    state = document.all[layer_ref].style.display;

    if (state == 'block')
        {
        state = 'none';
        }
    else
        {
        state = 'block';
        }

    eval("document.all." + layer_ref + ".style.display = state");
    }
if (document.layers)
    { //IS NETSCAPE 4 or below

    state = document.layers[layer_ref].display;

    if (state == 'block')
        {
        state = 'none';
        }
    else
        {
        state = 'block';
        }
    document.layers[layer_ref].display = state;
    }
if (document.getElementById &&!document.all)
    {
    hza = document.getElementById(layer_ref);
    state = hza.style.display;

    if (state == 'block')
        {
        state = 'none';
        }
    else
        {
        state = 'block';
        }
    hza.style.display = state;
    }
}

 function NewWindows(url)
{
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight

    swidth = screen.availWidth;
    sheight = screen.availHeight;
    jumpToHere = url ;
    winOptions = 'outerHeight=' + sheight + ', outerWidth=' + swidth +',scrollbars=yes,resizable=yes';
    popUpWindow = open(jumpToHere, "NewWindow", winOptions);
 }

function LTrim( value ) {
    
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");
    
}

// Removes ending whitespaces
function RTrim( value ) {
    
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");
    
}

 function ValFrmSubmit(frm)
{
//alert(frm);
var fldName;
var rflds = document[frm].IsRequired.value;
var separator = ',';
var stringArray = rflds.split(separator);
var str

for ( i = 0; i < stringArray.length; ++i )
    {
    fldName = stringArray[i];
    //alert(fldName);
    str = document[frm][fldName].value;
    LTrim(RTrim(str))
    if(str.length == 0)
    //if(document[frm][fldName].value =='')
        {
        alert(fldName + ' is a required field.');
        document[frm][fldName].value='';
        document[frm][fldName].focus();
        return false;
        }
    }

if(eval(frm + "." + "chrono_verification"))
    {
    if(document[frm].chrono_verification.value != strvalcode && document[frm].chrono_verification.value != strvalcodeLC)
        {
        //alert(strvalcode + ' - ' + strvalcodeLC);
        alert('Invaid spam verification code');
        return false;
        }
    }
if(confirm('You are about to submit the current form.\nTo continue click OK\nTo stop now click Cancel.'))
    {
    return true;
    }
else
    {
    return false;
    }
}


function distLocator(x)
{
    var jumpToHere;
    var winOptions;
    var popUpWindow;
    var swidth;
    var sheight

    swidth = screen.availWidth
    sheight = screen.availHeight
    jumpToHere = x;
    winOptions = "outerWidth=" + swidth + ", outerheight=" + sheight + ",scrollbars=yes,resizable=yes,status=no";
    popUpWindow = open(jumpToHere, "Dist_Locator", winOptions);
 }


function detach_chat_room()
{
    var jumpToHere;
    var winOptions;
    var ChatWindow;
    var swidth = "400";
    var sheight = "500";
    jumpToHere = "./rcs_chat.asp?detach=y";
    winOptions = "Width=" + swidth + ", height=" + sheight + ",scrollbars=yes,resizable=yes,status=0,addressbar=0";
    ChatWindow = open(jumpToHere, "RCS_Chat", winOptions);
 }

function resizeIframeToFitContent(iframe) 
{
    // This function resizes an IFrame object
    // to fit its content.
    // The IFrame tag must have a unique ID attribute.
    iframe.height = document.frames[iframe.id].document.body.scrollHeight;
    
}

function msgWarning()
{
if(confirm('You are about to submit your request for a Roofers Exchange subscription.\nFrom here you will be taken to our secure area where you will be required to post\na credit card payment of $24.99 for a one year subscription.\nTo continue click OK, To stop now click Cancel.'))
    {
    return true;
    }
else    
    {
    return false;
    }
}

function valrcsprofile()
{
if(document.rcsprofile.Company.value=='')
    {
    alert('Company is required');
    document.rcsprofile.Company.select();
    return false;
    }
if(document.rcsprofile.Contact.value=='')
    {
    alert('Contact is required');
    document.rcsprofile.Contact.select();
    return false;
    }
if(document.rcsprofile.Street.value=='')
    {
    alert('Street is required');
    document.rcsprofile.Street.select();
    return false;
    }
if(document.rcsprofile.City.value=='')
    {
    alert('City is required');
    document.rcsprofile.City.select();
    return false;
    }
if(document.rcsprofile.State.value=='')
    {
    alert('State is required');
    document.rcsprofile.State.select();
    return false;
    }
if(document.rcsprofile.Zip.value=='')
    {
    alert('Zip Code is required');
    document.rcsprofile.Zip.select();
    return false;
    }
if(document.rcsprofile.EmailAddress.value=='')
    {
    alert('Email Address is required');
    document.rcsprofile.EmailAddress.select();
    return false;
    }
if(document.rcsprofile.AreaCode.value=='' || document.rcsprofile.AreaCode.value.length !=3)
    {
    alert('Area code is required');
    document.rcsprofile.AreaCode.select();
    return false;
    }

if(document.rcsprofile.Phone1.value=='' || document.rcsprofile.Phone1.value.length !=3)
    {
    alert('Phone is required');
    document.rcsprofile.Phone1.select();
    return false;
    }
if(document.rcsprofile.Phone2.value=='' || document.rcsprofile.Phone2.value.length !=4)
    {
    alert('Phone is required');
    document.rcsprofile.Phone2.select();
    return false;
    }

return true;
}  

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-7120216-1");
pageTracker._trackPageview();
} catch(err) {}

