var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var thisdate = now.getDate();
var day = now.getDay();
var dayarr = new Array("Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday","Sunday");
var month = now.getMonth();
var montharr = new Array("Jan'","Feb'","Mar'", "Apr'","May","Jun'","Jul'","Aug'","Sep'","Oct'","Nov'","Dec'");
var year = now.getFullYear();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
//document.clock.face.value = "DATE : "+dayarr[day]+"  "+thisdate+"-"+montharr[(month)]+"-"+year.toString()+"    TIME: "+timeValue;
face.innerHTML = thisdate+"-"+montharr[(month)]+"-"+year.toString()+"  :  "+timeValue;

timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}

function showBrands(inForm,val)
{
	for(var x=0;x<inForm.brand.length;x++)
	{
		eval("inForm.brand.options[x]=" + "new Option()");
	}
	brandArray = eval("arr_"+val);
	for (var i=0; i < brandArray.length; i++) {
			eval("inForm.brand.options[i]=" + "new Option" + brandArray[i]);
		}
}

function showDetails2(inForm,val,zone)
{
    if(val=='' && val!='--')
    {
        pr = inForm.product.options[inForm.product.selectedIndex].value;
        location.href = "../search.php?cat="+pr;
    }
	else if(val=='--')
		alert("No Product selected");
	else
	{
		location.href = val+"/description.html";
	}
}
function showURL(link,zone) {
	//alert(document.frm1.zone1.options[document.frm1.zone1.selectedIndex].value);
	frmid = eval("document.frm"+zone+".zone"+zone);
	//zoneid = eval("zone"+zone);
	zonevalue = 1;
	//location.href = link+"&zone="+zonevalue;
	location.href = link;
}
function showDetails(inForm,val)
{
    if(val=='' && val!='--')
    {
        pr = inForm.product.options[inForm.product.selectedIndex].value;
        location.href = "search.php?cat="+pr;
    }
    else if(val=='--')
        alert("No Product selected");
    else
    {
        location.href = "cart/description.html?II="+val;
    }
}

function validate(field)
{
    errors = "";
    count=1;
    if(field.name.value=="")
    {
     	errors+=count+". Name is required.\n";
        count++;
    }
    if(field.email.value=="" || field.email.value.indexOf('@')==-1 || field.email.value.indexOf('.')==-1)
    {
        errors+=count+". First email entry is invalid.\n";
        count++;
    }
    if(field.email2.value=="" || field.email2.value.indexOf('@')==-1 || field.email2.value.indexOf('.')==-1)
    {
        errors+=count+". Second email entry is invalid.\n";
        count++;
    }
    if(field.email.value!=field.email2.value)
    {
        errors+=count+". The emails entered does not match.\n";
        count++;
    }
    if(field.address.value=="")
    {
         errors+=count+". Address is required.\n";
         count++;
    }
    if(field.phone.value=="")
    {
         errors+=count+". Phone is required.\n";
         count++;
    }
    if(field.password.value=="")
    {
         errors+=count+". First password entry is invalid.\n";
         count++;
    }
    if(field.password2.value=="")
    {
         errors+=count+". Second password entry is invalid.\n";
         count++;
    }
    if(field.password.value!=field.password2.value)
    {
         errors+=count+". Passwords entered does not match.\n";
         count++;
    }
    if(errors.length>1)
    {
     	errtxt = "The following errors need to be corrected!!\n";
        errtxt+= "............................................................\n";
        errtxt+=errors;
        alert(errtxt);
        return false;
    }
    return true;
}
function chkpwd(fields)
{

    if(fields.EId.value=="" || fields.EId.value.indexOf('@')==-1 || fields.EId.value.indexOf('.')==-1)
    {
        alert("Please enter a valid email id");
        fields.EId.focus();
        return false;
    }

    return true;
}