﻿// JScript File
function shopgrid_load()
{
tbl1=document.getElementById('gvShoppingCart');
        if(tbl1!=null)
        {
            for(var i=1;i<tbl1.rows.length;i++)
              {
                if(tbl1.rows[i].cells[5] == null) continue;
                var anchor = tbl1.rows[i].cells[5].getElementsByTagName('a');
                if(anchor.length>0) anchor[0].onclick=Confirmation;
                
              }
        }
}
function Confirmation()
{
    return confirm('Are you sure want to remove?');
}
function ItemValue(e)
{
var txtElement=e.srcElement

    // Internet Explorer   
   
    if (e.srcElement)
    {
        txtElement = e.srcElement;
    }    
    // Netscape and Firefox
    else if (e.target)
    {
        txtElement = e.target;
    }
if(txtElement.value=="" || txtElement.value=="0")
txtElement.value="1";
}
function findMyText() 
{
// var temp=new Array();
// var userval=document.getElementById('txtSearch').value;
//temp = userval.split(' ');
//for (j=0;j<temp.length;j++)
//{
//replaceText(temp[j].toString());
//}
}
function replaceText(needle)
{
var SearchText = document.getElementById("SearchDiv").innerHTML;
    
     var match = new RegExp(needle, "ig");     
     var replaced = "";
     
          var boldText = "<div style=\"background-color: yellow; display: inline; font-weight: bold;\">" + needle + "</div>";
          replaced = SearchText.replace(match, boldText);
     
     document.getElementById("SearchDiv").innerHTML = replaced;
}
function postBackByObject(mEvent)
{

    var o;
    // Internet Explorer   
   
    if (mEvent.srcElement)
    {
        o = mEvent.srcElement;
    }    
    // Netscape and Firefox
    else if (mEvent.target)
    {
        o = mEvent.target;
    }
    
    if (o.tagName == "INPUT" && o.type == "checkbox")
    {
       __doPostBack("","");
    } 

    if (o.tagName == "IMG" && o.alt=="Check")
    {

       __doPostBack("tvAttribute","");
      
    } 


}
function itemStatus()
{
var isvalid=false;
var status=document.getElementById("hidItemStatus").value;
if(status=="True")
isvalid=true;
if(status=="true")
isvalid=true;
return isvalid;

}

function contactus()
{
var isvalid = true;
document.getElementById('lblMSG').innerHTML='';
var Validate = new Array('txtCustName','txtCustEmail','txtContactNo','txtComment');
if(!RequiredFieldWithBorder(Validate))
{
    isvalid = false;
}  

if(isvalid==true)
{
    if(!EmailCheck('txtCustEmail'))
    {
        isvalid = false;
    }   
}
if(isvalid==true)
{
    if(!ValidateUKPhoneNumber('txtContactNo'))
    {
        isvalid = false;
    }
       
}
return isvalid;
}
function resetcontactus()
{
var isvalid = false;
document.getElementById('lblMSG').innerHTML='';

document.getElementById('txtCustName').value='';
document.getElementById('txtCustEmail').value='';
document.getElementById('txtContactNo').value='';
document.getElementById('txtComment').value='';
ClearBorder('txtCustName');
ClearBorder('txtCustEmail');
ClearBorder('txtContactNo');
ClearBorder('txtComment');
return isvalid;
}
function EmailCheck(Id)
{
	try
	{
		var reg1 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		var reg2 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		
		Value = trimAll(document.getElementById(Id).value)
		

		if(Value != '')
		{
		if(! reg1.test(document.getElementById(Id).value) || reg2.test(document.getElementById(Id).value))
		{
			CreateBorder(Id);
			return false
		}
		}
		ClearBorder(Id);
		return true
	}
	catch(e)
	{
		alert(e.toString())
		alert(e.message.toString())
		alert('8')
		return false 
	}
}
function SetInProgressPosition(ctlname,divwidth)

{

    try

    {

        var div=document.getElementById(ctlname);        

        div.style.top=250+document.documentElement.scrollTop + 'px';

        try

        {

        // to handle IE issues

        div.style.left=((document.documentElement.clientWidth/2)-(divwidth/2)) + 'px';

        }

        catch(e)

        {

        div.style.left=((window.innerWidth/2)-(divwidth/2)) + 'px';

        }

    }

    catch(e)

    {

        alert('SetInProgressPosition ' + e.message);

    }

}
