function chk_contactus(frm,isEdit)
{
    if(!notEmpty(frm.txtName,"Name"))
        return false;
    if(!notEmpty(frm.txtContactNo,"Contact no"))
        return false;
    if(!notEmpty(frm.txtEmail,"Email"))
        return false;
    if(!notEmpty(frm.txtLocation,"Location"))
        return false;
    if(!notEmpty(frm.txtSubject,"Subject"))
        return false;
    if(!notEmpty(frm.txtEnquiry,"Enquiry"))
        return false;
    else
        return true;
}

function addimage(frm)
{
    var cur_number = frm.hidTotalImages.value;
    var next_number = parseInt(cur_number) + 1;
//    alert(next_number);
    x = document.getElementById('gallery_items');
    var curhtml = x.innerHTML;
    var sethtml = "<div class=\"frmRow\" id=\"imagediv" + next_number + "\"><div class=\"label\">Gallery image: </div><div class=\"ele\"><input type=\"file\" name=\"flimageitem[]\"></div></div><br>";
//    alert(sethtml);
    x.innerHTML = curhtml + sethtml;
    frm.hidTotalImages.value = next_number;
    return true;
    /*<div class="frmRow" id="imagediv1">
<div class="label">Gallery image: </div>
<div class="ele">
<input type="file" name="flimageitem[]">
</div>
</div>*/
}

function remimage(number_to_remove)
{
    var cur_number = document.frmAddGallery.hidTotalImages.value;
//    var prev_number = parseInt(cur_number) - 1;
    x = document.getElementById('gallery_items');
    var curhtml = x.innerHTML;
    var remhtml = "<div class=\"frmRow\" id=\"imagediv" + number_to_remove + "\"><div class=\"label\">Gallery image: </div><div class=\"ele\"><input type=\"file\" name=\"flimageitem[]\"><input type='button' name='butremove" + number_to_remove + "' value='Remove' onclick = 'return remimage(\"" + number_to_remove + "\")'></div></div><br>";
    alert(remhtml);
    var newhtml = curhtml.replace(remhtml,'t');
    alert(newhtml);
    x.innerHTML = newhtml;
//    document.frmAddGallery.hidTotalImages.value = prev_number;
    return true;
}

function disable_main_image()
{
    x = document.getElementById('imagebar');
//    x.style.display = 'none';
    return true;
}

function show_hide_div(obj, type)
{
    x = document.getElementById(obj);
    if(type == 'show')
    {
        x.style.display = '';
    }
    else
    {
        x.style.display = 'none';
    }
    return true;
}

function show_hide_div2(obj, type,obj1, type1)
{
    x = document.getElementById(obj);
    if(type == 'show')
    {
        x.style.display = '';
    }
    else
    {
        x.style.display = 'none';
    }
    
    y = document.getElementById(obj1);
    if(type1 == 'show')
    {
        y.style.display = '';
    }
    else
    {
        y.style.display = 'none';
    }
    return true;
}

function chk_member_registration(frm,isEdit)
{
    if(!isEdit)
    {
        if(!notEmpty(frm.vEmail,"email address"))
            return false;
        if(!notEmpty(frm.vPassword,"password"))
        return false;
        if(!notEmpty(frm.vConfirmPassword,"confirm password"))
        return false;
        else
        {
            if(frm.vConfirmPassword.value != frm.vPassword.value)
            {
                alert("Passwords don't match");
                frm.vConfirmPassword.focus();
                return false;
            }
        }
    }
    /*if(!notEmpty(frm.vProfession,"profession / occupation"))
    return false;*/
    if(!notEmpty(frm.vFirstName,"first name"))
    return false;
    if(!notEmpty(frm.vLastName,"last name"))
    return false;
    if(!notEmpty(frm.vAddress1,"address-1"))
    return false;
    if(!notEmpty(frm.vSuburb,"suburb"))
    return false;
    if(!notEmpty(frm.vPostCode,"post code"))
    return false;
    else if(!notPhone(frm.vPostCode,"post code"))
    return false;
    /*if(!notEmpty(frm.vBirthdate,"birth date"))
    return false;*/
    if(!notEmpty(frm.vMobile,"mobile"))
    return false;
    else if(!notPhone(frm.vMobile,"mobile"))
    return false;

    if(frm.vHomePhone.value != "")
    {
        if(!notPhone(frm.vHomePhone,"home phone"))
        return false;
    }
    if(frm.vWorkPhone.value != "")
    {
        if(!notPhone(frm.vWorkPhone,"work phone"))
        return false;
    }
    if(!notEmpty(frm.vReferredBy,"referred by 1"))
    return false;
    if(!notEmpty(frm.vReferredBy2,"referred by 2"))
    return false;

    if(!isEdit)
    {
        if(!notChecked(frm.eTerms,"You must agree to terms and conditions before further processing"))
        return false;
    }

    return true;
}

function AssignTickets(frm, memid, frmchange)
{
    var d1 = eval("frmchange.txtticketday1_" + memid + ".value");
    var d2 = eval("frmchange.txtticketday2_" + memid + ".value");
    var d3 = eval("frmchange.txtticketday3_" + memid + ".value");
    var d4 = eval("frmchange.txtticketday4_" + memid + ".value");
    var d5 = eval("frmchange.txtticketday5_" + memid + ".value");
    var notes = eval("frmchange.txtnote_" + memid + ".value");
    
    frm.hidmemberid.value = memid;
    frm.hidtickets_d1.value = d1;
    frm.hidtickets_d2.value = d2;
    frm.hidtickets_d3.value = d3;
    frm.hidtickets_d4.value = d4;
    frm.hidtickets_d5.value = d5;
    frm.hidnotes.value = notes;
    frm.submit();
    return true;
}

function AssignDiwaliTickets(frm, memid, frmchange)
{
    var d1 = eval("frmchange.txtticketday1_" + memid + ".value");
    var d2 = eval("frmchange.txtticketday2_" + memid + ".value");
    var notes = eval("frmchange.txtnote_" + memid + ".value");
    
    frm.hidmemberid.value = memid;
    frm.hidtickets_d1.value = d1;
    frm.hidtickets_d2.value = d2;
    frm.hidnotes.value = notes;
    frm.submit();
    return true;
}

function chkMultiStatusChange(frm)
{
    var NoOfRecords = frm.hidNoOfRecords.value;
    var isSel = 0;
    if(!frm.slChange.value)
    return false;

    for(i=0;i<NoOfRecords;i++)
    {
        comObj = eval("frm.chk_" + i);
        if(comObj.checked == true)
        {
            isSel = 1;
        }
    }
    if(!isSel)
    {
        alert("Please select atleast one record to change the status");
        frm.slChange.value = '';
        return false;
    }
    frm.submit();
    return true;
//txtShortDesc, chk_, hidNoOfPrices, flImage, slStatus
}

function trOver(passid)
{
    obj = document.getElementById(passid);

    rows = document.getElementById(passid).getElementsByTagName("td");
    for(i=0;i<rows.length;i++)
    {
        tdobj = rows[i];
        tdobj.style.background='#D2DAFF';
    }
    return true;
}

function trOut(passid)
{
    obj = document.getElementById(passid);
    rows = document.getElementById(passid).getElementsByTagName("td");
    for(i=0;i<rows.length;i++)
    {
        tdobj = rows[i];
        if(tdobj.className == 'shortTD')
        tdobj.style.background='#F0F0F0';
        else
        tdobj.style.background='';
    }
    return true;
}

function chkCheckListBoxes(frm,isUn)
{
    var NoOfRecords = frm.hidNoOfRecords.value;
    var isSel = 0;

    for(i=0;i<NoOfRecords;i++)
    {
        comObj = eval("frm.chk_" + i);
        if(isUn)
        comObj.checked = false;
        else
        comObj.checked = true;
    }
    return true;
}

function chkLogin(frm)
{
    if(!notEmpty(frm.UserName,"User Name"))
    return false;
    if(!notEmpty(frm.Pwd,"Password"))
    return false;
    else
    {
    //document.frmLoginFrm.submit();
    return true;
    }
}

function chkQuickSearchTwo(frm)
{
    if(!notSelected(frm.slOpt,"Option"))
        return false;
    if(!notEmpty(frm.keyword,"Search Keyword"))
        return false;
    else
        return true;
}

function blank_username(val)
{
    if(val == 'username')
    document.frm_quick_login.txtName.value = '';
    return true;
}

function blank_password(val)
{
    if(val == 'password')
    document.frm_quick_login.txtPassword.value = '';
    return true;
}

function chk_change_password(frm)
{
    if(!notEmpty(frm.vOldPassword,"old password"))
        return false;
    if(!notEmpty(frm.vPassword,"new password"))
        return false;
    if(!notEmpty(frm.vConfirmPassword,"confim password"))
        return false;
}

function chk_forgot_password(frm)
{
    if(!notEmpty(frm.vEmail,"email address"))
        return false;
}

function chk_frontlogin(frm)
{
    if(!notEmpty(frm.txtName,"username"))
        return false;
    if(!notEmpty(frm.txtPassword,"password"))
        return false;
    else
        return true;
}

function interFrmSubmit()
{
    frm = document.paypal_form;
    //alert(frm);
    frm.submit();
    return false;
}

function showMenu(comId)
{
    x = document.getElementById(comId);

    chkmouseover(comId);
        //alert(document.forms.length);
        for(i=0;i<document.forms.length;i++)
        {
            var theForm = document.forms[0];
            //alert(theForm.elements.length);
            for(p=0;p<theForm.elements.length;p++)
            {
                //alert(theForm.elements[p].type);
                if(theForm.elements[p].type == 'select-one')
                theForm.elements[p].style.display = 'none';
            }
        }

    return true;
}

function hideMenu(comId)
{
    x = document.getElementById(comId);

    chkmouseout(comId);
        //alert(document.forms.length);
        for(i=0;i<document.forms.length;i++)
        {
            var theForm = document.forms[0];
            for(p=0;p<theForm.elements.length;p++)
            {
                if(theForm.elements[p].type == 'select-one')
                theForm.elements[p].style.display = '';
            }
        }

    return true;
}

////////////////////////////////////////////////////////////////////
// menu functions
////////////////////////////////////////////////////////////////////

function chkmouseover(passobj)
{
    x = document.getElementById(passobj);
    curX = findPosX(x);
    curY = findPosY(x);
    //alert("curX " + curX);
    //alert("curY " + curY);

    y = document.getElementById('menu' + passobj);

    y.style.display = '';

    if(passobj == 'catmenu' || passobj == 'supportmenu' || passobj == 'actcatmenu' || passobj == 'actsupportmenu')
    {
        if(navigator.appName == 'Microsoft Internet Explorer')
        {
            y.style.top = curY + 108;
            y.style.left = curX - 222;
        }
        else
        {
            y.style.top = (curY + 1) + "px";
            y.style.left = (curX - 222) + "px";
        }
    }
    else
    {
        if(navigator.appName == 'Microsoft Internet Explorer')
        {
            y.style.top = curY + 49;
            y.style.left = curX - 1;
        }
        else
        {
            y.style.top = (curY + 49) + "px";
            y.style.left = (curX + 0) + "px";
        }
    }
    //alert(y.style.top);
    //alert(y.style.left);
}

function chkmouseout(passobj)
{
    y = document.getElementById('menu' + passobj);

    y.style.display = 'none';
}

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function screenWidth()
{
    if (self.innerWidth)
    {
        frameWidth = self.innerWidth;
        frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
        frameWidth = document.documentElement.clientWidth;
        frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        frameWidth = document.body.clientWidth;
        frameHeight = document.body.clientHeight;
    }
    return frameWidth;
}


function screenHeight()
{
    if (self.innerWidth)
    {
        frameWidth = self.innerWidth;
        frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
        frameWidth = document.documentElement.clientWidth;
        frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        frameWidth = document.body.clientWidth;
        frameHeight = document.body.clientHeight;
    }
    return frameHeight;
}
