﻿function setFocusNext(e) {
    var cd = 0;
    if (window.event) {
        cd = e.keyCode;
    } else if (e.which) {
        cd = e.which;
    }
    if (cd == 13) {
        return true;
    } else {
        return false;
    }
}

function validateForm() {

    var invalid = " "; // Invalid character is a space
    var minLength = 3; // Minimum length
    var search1 = document.getElementById('txtKeyword').value;
    var location1 = document.getElementById('txtLocation').value;
    // var test = document.searchform.ypsearch.value; 
    // size = test.length
    // check for a value in both fields.
    if (location1 == '' || location1 == null || search1 == null || search1 == '' || search1 == 'Category, Keyword or Brand' || search1 == 0 || search1.length < 3) {
        if (search1 == null || search1 == '' || search1 == 'Category, Keyword or Brand' || search1 == 0 || search1.length < 3) {
            alert('Please enter valid search keyword.');
            document.getElementById('txtKeyword').focus();
        }
        else {
            alert('Please enter valid location.');
            document.getElementById('txtLocation').focus();
        }
        return false;
    } else {
        return true;
    }
}
/*******************For the drop down panel*********************/
$(document).ready(function () {
    $("span.pop").click(function () {
        $("div#panel").animate({
            height: "240px"
        })
		.animate({
		    height: "240px"
		}, "fast");

        $("span.pop").toggle();

    });

    $("span#pophide").click(function () {
        $("div#panel").animate({
            height: "0px"
        });
    });
});

/****************Show or hide element******************/
function showStuff(id) {
    document.getElementById(id).style.display = 'block';
}
function hideStuff(id) {
    document.getElementById(id).style.display = 'none';
}

/**************Banner Ads********************/
function RotateImages(whichHolder, Start) {
    var img = eval("ImageArr" + whichHolder);
    var lnk = eval("links" + whichHolder);
    var b = eval("ImageHolder" + whichHolder);
    var c = eval("anchor" + whichHolder);
    if (Start >= img.length)
        Start = 0;
    b.src = img[Start];
    c.href = lnk[Start];
    window.setTimeout("RotateImages(" + whichHolder + "," + (Start + 1) + ")", 6000);
}
