﻿ 
   function ClientValidateTextBoxNoHttp(source, arguments)
   { 
     arguments.IsValid = !/http:\/\//.test(arguments.Value);
   }
 


function MoveToNextNumericTextBox(e,size,thisTextBoxID, nextTextBoxID)
{
    var keynum
    if(window.event) // IE
        keynum = e.keyCode;
    else if(e.which) // Netscape/Firefox/Opera
        keynum = e.which;
    var isNumber = false;
    if (keynum >= 48 && keynum <= 57 ) isNumber = true;
    if (keynum >= 96 && keynum <= 105 ) isNumber = true;
    if (!isNumber)
        return;
    var thisTextBox = document.getElementById(thisTextBoxID);
    var nextTextBox = document.getElementById(nextTextBoxID);
    if (/[0-9]+/.test(thisTextBox.value) && (thisTextBox.value.length == size))
        {
            nextTextBox.focus();
            nextTextBox.select();
        }
}

function MainMenuRollOver(tdID)
{
    var td = document.getElementById(tdID);
    if (!(/-over/.test(td.style.backgroundImage)))
    {    
        var newSrc = td.style.backgroundImage.replace(/\.jpg/,"-over.jpg");
        td.style.backgroundImage = newSrc;
    }
}

function MainMenuRollOut(tdID)
{
    var td = document.getElementById(tdID);
    if ((/-over/.test(td.style.backgroundImage)))
    {    
        var newSrc = td.style.backgroundImage.replace(/-over/,"");
        td.style.backgroundImage = newSrc;
    }
}

function cstvSearch(source,args)
{
    args.IsValid = true;
    var txtSearch =  document.getElementById(source.controltovalidate);
    //change this in aspx.cs also....
    if (txtSearch.value == 'Enter Search Phrase')
    {
        txtSearch.select();
        txtSearch.focus();
        args.IsValid = false;
        return;
    }
    if (txtSearch.value == '')
    {
        txtSearch.value = 'Enter Search Phrase';
        txtSearch.focus();
        txtSearch.select();
        args.IsValid = false;
    }
}

function txtSearch_Click(clientID)
{
    var txtSearch = document.getElementById(clientID);
    txtSearch.style.color = 'red';
    if (txtSearch.value == 'Enter Search Phrase')
        txtSearch.value = '';
}

function popGPhoto(id,hull)
{ 
     galleryWindow = window.open("/Gallery/GalleryPopUp.aspx?id="+ id + "&hullID=" + hull,"gallery","height=500,width=620,status=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
     galleryWindow.focus();
}

function popHullCompare(hullCatID)
{ 
 hullCompareWindow = window.open("/HullCompare.aspx?hullCatID="+ hullCatID ,"hullCompare","height=500,width=620,status=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
 hullCompareWindow.focus();
}

function popManufacturerWarranty(productID) 
{
    hullCompareWindow = window.open("/Cart/ManufacturerWarranty.aspx?productID=" + productID, "hullCompare", "height=500,width=620,status=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
    hullCompareWindow.focus();
}

function popManufacturerWarranty(productID, hull) {
    hullCompareWindow = window.open("/Cart/ManufacturerWarranty.aspx?productID=" + productID+"&hull=" + hull, "hullCompare", "height=500,width=620,status=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
    hullCompareWindow.focus();
}


function popPage(url,pHeight,pWidth)
{ 
    var height = (pHeight == null) ? 250 : pHeight;
    var width = (pWidth == null) ? 500 : pWidth ;
    var popPage = window.open(url,"popPage","height=" + height + ",width=" + width + ",status=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
    popPage.focus();
}

function popVP(model)
{ 
 VPWindow = window.open("/vp/"+model+".aspx","ViewPoint3D","height=550,width=740,status=yes,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=yes,top=100,left=100");
 VPWindow.focus();
}

function displayBlock(id)
{
    var el = document.getElementById(id);
    el.style.display ='block';
}


function TextAreaMaxLength(text,maxLength) 
{ 
	if (text.value.length > maxLength){
		text.value = text.value.substring(0,maxLength);
	}

}

function scrollToOrderArea() {
    var orderArea = document.getElementById('OrderArea');
    var pos = findPos(orderArea);
    scrollTo(pos[0], pos[1]);
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return [curleft, curtop];
}