﻿// JScript File               
//validation for Allow numeric only..
var domain = "http://www.mahalist.com";
var defaultText = "Search Keyword";
function OnFocusTXT()
{ 
   if (document.getElementById("Txt_SearchKey").value == defaultText)
   {
      document.getElementById("Txt_SearchKey").className = "normal";
      document.getElementById("Txt_SearchKey").value = "";
   }
}

function OnBlurTXT()
{
   var textValue = document.getElementById("Txt_SearchKey").value;

   if (textValue == defaultText || textValue.length == 0)
   {
      document.getElementById("Txt_SearchKey").className = "watermark";
      document.getElementById("Txt_SearchKey").value = defaultText;
   }
   else
      document.getElementById("Txt_SearchKey").className = "normal";
}
function MLSearch()
{
    var key = document.getElementById("Txt_SearchKey").value;
    var Obj = document.getElementById("Sel_Cat");
    var cat = Obj.options[Obj.selectedIndex].value;
    var bool = true;
    if(key == null || key == "" || key == '' || key == defaultText)
    {
        alert("Please input search keyword");
        bool = false;
    }
    if(cat == "Select Category" || cat == null || cat == "")
    {
        alert("Please Select a Category");
        bool = false;
    }
    if(bool)   
        window.location = domain + "/Search/" + cat + "/" + key;
}
function RedHome()
{
    window.location = domain + "/Default.aspx";
}
function AllowNumeric()
{
	if(event.keyCode < 45 || event.keyCode > 57)
		event.returnValue = false;
}

//validation for Email..
function ValidEmail(str) 
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str.value))
    {
        return (true);
    }
    var objMsg = document.getElementById("DivJMsg");
    objMsg.style.display = 'block';
    objMsg.innerHTML ="<hr /><a class=\"MsgsErr\"><h4>Invalid E-mail Address! Please re-enter.</h4></a><hr />";
    str.value="";
    str.focus();
    return (false);
}
function SiteUsr()
{
    var objMsg = document.getElementById("DivJMsg");
    objMsg.style.display = 'block';
    objMsg.innerHTML ="<hr /><a class=\"MsgsErr\"><h4>you need choose a city. are you want redirect to City selection page.</h4></a><input type=\"button\" value=\"Yes\" onclick=\"document.location.href='" +domain + "/SelectCity'\"/>&#09;<input type=\"button\" value=\"NO\" onclick=\"NODivJMsg();\"/><hr />";   
}
function SelectCity()
{
    var objMsg = document.getElementById("DivJMsg");
    objMsg.style.display = 'block';
    objMsg.innerHTML ="<hr /><a class=\"MsgsErr\"><h4>Please Select City.</h4></a><hr />";
}
function NODivJMsg()
{
    var objMsg = document.getElementById("DivJMsg");
    objMsg.innerHTML = '';
    objMsg.style.display = 'none';   
}
//descrip


