//Include Common Page JScipts //

function mail()
{
    var nl = (screen.availWidth-500) / 3;
    var nh = (screen.availHeight-500) / 2;
    referfriend = window.open(rootPath + "/refer-to-friend.html","referfriend", "height=365,resize=0,width=500,scrollbars=no,top="+nh+",left="+nl);
}

function ChangeBg1(element)
{
    element.style.backgroundImage = "url('"+rootPath+"/content/images/menubg2.gif')";
    element.style.cursor = "hand";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}

function RechangeBg1(element)
{
    element.style.backgroundImage = "url('"+rootPath+"/content/images/menubg1.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}

var i = 0;
var bannercnt = 0;
var bannerpath = "";
var bannerurl = "";
var links = new Array;
var path = new Array;
function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var j=0;j<vars.length;j++)
    {
        var pair = vars[j].split("=");
        if (pair[0] == variable)
        {
            return pair[1];
        }
    }
}

function setQueryVariable(variable,value)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    var newquery = "";
    for (var j=0;j<vars.length;j++)
    {
        var pair = vars[j].split("=");
        if (pair[0] == variable)
        {
            if(j == 0)
            {
                newquery = pair[0] + "=" + value;
            }
            else
            {
                newquery = newquery + "&" + pair[0] + "=" + value;
            }
        }
        else
        {
            if(j == 0)
            {
                newquery = vars[j];
            }
            else
            {
                newquery = newquery + "&" + vars[j];
            }
        }
    }
    return newquery;
}

function setvariable(bcnt,bpath,burl)
{
    bannercnt	= bcnt
    bannerpath = bpath
    bannerurl = burl
    if(bcnt > 0)
    {
        links = bannerurl.split("|");
        path = bannerpath.split("|");
    }
}

function loadBanner()
{
    var time= new Date();
    hours= time.getHours();
    mins= time.getMinutes();
    secs= time.getSeconds();
    closeTime=hours*3600+mins*60+secs;
    closeTime+=20;
}

function clickLink()
{
    top.location = links[i]
}

function descript()
{
    window.status = description[i]
}

function nothing()
{
    window.status=""
}

function animation(status)
{
    var animate;
    animate = getQueryVariable("animate");
    var urlname = window.location.pathname;
    var url_split = urlname.split("?");
    if (status=="off")
    {
        if (window.location.search.substring(1) != "" )
        {
            if ( animate != null )
            {
                window.location.href = url_split[0] + "?" + setQueryVariable("animate","stop");
            }
            else
            {
                window.location.href=window.location+"&animate=stop";
            }
        }
        else
        {
            window.location.href=window.location+"?animate=stop";
        }
    }
    else
    {
        if (window.location.search.substring(1) != "" )
        {
            if ( animate != null )
            {
                window.location.href = url_split[0] + "?" + setQueryVariable("animate","start");
            }
            else
            {
                window.location.href=window.location+"&animate=start";
            }
        }
        else
        {
            window.location.href=window.location+"?animate=start";
        }
    }
}

function PostNewsLetter()
{
    if(document.frmNewsletter.email.value=="" && document.frmNewsletter.email.value=="Your Email Address")
    {
        alert("Please enter a e-mail address!");
        document.frmNewsletter.email.focus();
        
        return false;
    }
    else
    {
        if(!IsEmailValid(document.frmNewsletter.email))
        {
          return false;
        }
        else
        {
          return true;
        }
    }
}

function Show_Menu(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style;
    nav.display='block';
    if (screen.width=="1440")
    {
        document.getElementById('div_block').style.right="350px";
        document.getElementById('div_block').style.top="225px";
    }
    else
    {
        document.getElementById('div_block').style.right="150px";
        document.getElementById('div_block').style.top="225px";
    }
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    element.style.cursor = "hand";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function ShowColor1(element)
{
    nav=document.getElementById('Product_Drop').style
    nav.display='block';
    var site=navigator.appName.replace(" ","").toLowerCase();
    if(site=="microsoftinternet explorer")
    {
        if (screen.width=="1440")
        {
            document.getElementById('div_block_drop').style.right="14.64%";
            document.getElementById('div_block_drop').style.top="35%";
        }
        else
        {
            document.getElementById('div_block_drop').style.right="29.8%";
            document.getElementById('div_block_drop').style.top="44%";
        }
    }
    else if(site=="opera")
    {
        if (screen.width=="1440")
        {
            document.getElementById('div_block_drop').style.right="14.1%";
            document.getElementById('div_block_drop').style.top="33.7%";
        }
        else
        {
            document.getElementById('div_block_drop').style.right="29.9%";
            document.getElementById('div_block_drop').style.top="48%";
        }
    }
    else
    {
        if (screen.width=="1440")
        {
            document.getElementById('div_block_drop').style.right="14.1%";
            document.getElementById('div_block_drop').style.top="38%";
        }
        else
        {
            document.getElementById('div_block_drop').style.right="29.9%";
            document.getElementById('div_block_drop').style.top="48%";
        }
    }
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function Show_Menu1(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style
    nav.display='block';
    element=document.getElementById('about_menu');
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function Hide_Menu1(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style
    nav.display='none';
    element=document.getElementById('about_menu');
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg1.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function Hide_Menu(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style
    nav.display='none';
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg1.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function ShowColor(element)
{
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function hideColor(element)
{
    element.style.background = "#F5F5F5";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function hideColor1(element)
{
    nav=document.getElementById('Product_Drop').style
    nav.display='none';
    element.style.background = "#F5F5F5";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function Show_Menu_Drop(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style
    nav.display='block';
    element=document.getElementById('about_menu');
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function Hide_Menu_Drop(element,ThisObj)
{
    nav=document.getElementById(ThisObj).style
    nav.display='none';
    document.getElementById('Product_Drop').style.display="none";
    element=document.getElementById('about_menu');
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg1.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function show_menu_drop(element)
{
    document.getElementById('Product_Drop').style.display="block";
    element.style.backgroundImage = "url('"+ rootPath + "/Content/images/menubg2.gif')";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#FFFFFF";
}
function Hide_menu_drop(element)
{
    document.getElementById('Product_Drop').style.display="block";
    element.style.background = "#F5F5F5";
    if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#000000";
}
function goback()
{
    document.frmviewproducts.submit();
}
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag)
{
    if ((!highlightStartTag) || (!highlightEndTag))
    {
        highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
        highlightEndTag = "</font>";
    }
    var newText = "";
    var i = -1;
    var lcSearchTerm = searchTerm.toLowerCase();
    var lcBodyText = bodyText.toLowerCase();
    while (bodyText.length > 0)
    {
        i = lcBodyText.indexOf(lcSearchTerm, i+1);
        if (i < 0)
        {
            newText += bodyText;
            bodyText = "";
        }
        else
        {
            if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i))
            {
                if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i))
                {
                    newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
                    bodyText = bodyText.substr(i + searchTerm.length);
                    lcBodyText = bodyText.toLowerCase();
                    i = -1;
                }
            }
        }
    }
    return newText;
}
function highlightSearchTerms(searchText, treatAsPhrase, searchType1, warnOnFailure, highlightStartTag, highlightEndTag)
{
    if (!document.getElementById("resultsDiv") || typeof(document.getElementById("resultsDiv").innerHTML) == "undefined")
    {
        if (warnOnFailure)
        {
            alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
        }
        return false;
    }
    var bodyText = document.getElementById("resultsDiv").innerHTML;
    for (var i = 0; i < searchArray.length; i++)
    {
        bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
    }
    document.getElementById("resultsDiv").innerHTML = bodyText;
    return true;
}
function searchPrompt(defaultText,treatAsPhrase, searchType, textColor, bgColor)
{
    if (!defaultText)
    {
        defaultText = "";
    }
    if ((!textColor) || (!bgColor))
    {
        highlightStartTag = "";
        highlightEndTag = "";
    }
    else
    {
        highlightStartTag = "<font style='color:" + textColor + "; background-color:" + bgColor + ";'>";
        highlightEndTag = "</font>";
    }
    searchText = '';
    return highlightSearchTerms(searchText, treatAsPhrase, searchType, true, highlightStartTag, highlightEndTag);
}
Event.onDOMReady(
function()
{
    if(res != '')
    {
        var pcontent = document.getElementById("resultsDiv");
        if(pcontent != null)
        {
            var pagecontent = document.getElementById("resultsDiv").innerHTML;
            searchPrompt('the page', false, 'search', 'white', '#FF6600');
        }
        else
        {
            searchArray = new Array("");
        }
    }
    else
    {
        searchArray = new Array("");
    }
}
);
function navigate(articleId, index, seourl)
{
    document.frmPaging.index.value = index;
    document.frmPaging.articleId.value = articleId;
    document.frmPaging.target = "_self";
    document.frmPaging.action = rootPath + "/article/"+seourl+".html";
    document.frmPaging.submit();
}
function gotoresultpage()
{
    document.frmPaging.target = "_self";
    document.frmPaging.action = rootPath + "/search-results.html";
    document.frmPaging.submit();
}
function callprint(id)
{
    if(id != "")
    {
        var left1 = (screen.availWidth-700) / 2;
        var top1 = (screen.availHeight-700) / 2;
        myWin = window.open(rootPath + '/print-news/' + id + '.html', "printnews", "height=600,resize=0,width=780,scrollbars=yes,status=yes,top="+top1+",left="+left1);
    }
}
function gotoPage(pageNo)
{
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/trends-hot-topics.html";
    document.frmArticle.pageNo.value = pageNo;
    document.frmArticle.submit();
}

function expand(moreopt,id)
{
    if(moreopt.innerText == ' collapse ')
    {
        document.getElementById(''+id+'').style.display='none';
        moreopt.innerText = ' expand ';
    }
    else
    {
        document.getElementById(''+id+'').style.display='block';
        moreopt.innerText = ' collapse ';
    }
}

function showSubTypes(id,details)
{
    if(document.getElementById(''+id+'').style.display == 'none')
    {
        document.getElementById(''+id+'').style.display='block';
    }
    else
    {
        document.getElementById(''+id+'').style.display='none';
    }
}

function gotoPage(pageNo)
{
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/News/Business.html";
    document.frmArticle.pageNo.value = pageNo;
    document.frmArticle.submit();
}
function GotoSearch()
{
    document.getElementById('s_year').value ="";
    document.getElementById('s_month').value ="";
    document.getElementById('sortBy').value ="";
    document.getElementById('sortDirection').value ="";
    document.getElementById('FreeText').value ="FreeText";
    window.location="#frmsearch";
    document.getElementById('FreeText').focus();
}
function GotoSearchforchange()
{
    window.location="#frmsearch";
    document.getElementById('FreeText').focus();
}

function expand(moreopt,id)
{
    if(moreopt.innerText == ' collapse ')
    {
        document.getElementById(''+id+'').style.display='none';
        moreopt.innerText = ' expand ';
    }
    else
    {
        document.getElementById(''+id+'').style.display='block';
        moreopt.innerText = ' collapse ';
    }
}

function srch()
{
    if(document.getElementById('FreeText').value=='FreeText')
    {
        document.getElementById('FreeText').value='';
    }
    if(document.getElementById('FreeText').value!=''&& document.getElementById('FreeText').value!='FreeText')
    {
        document.frmsearch.action = rootPath + "/search-results.html";
        document.frmsearch.submit();
    }
    else if(document.getElementById('s_year').value!=0 && document.getElementById('s_year').value!="")
    {
        document.frmsearch.action = rootPath + "/search-results.html";
        document.frmsearch.submit();
    }
    else if(document.getElementById('s_month').value!=0)
    {
        document.frmsearch.action = rootPath + "/search-results.html";
        document.frmsearch.submit();
    }
    else if(CheckSelect('marketDetails'))
    {
        document.frmsearch.action = rootPath + "/search-results.html";
        document.frmsearch.submit();
    }
    else if(CheckSelect('typeDetails'))
    {
        document.frmsearch.action = rootPath + "/search-results.html";
        document.frmsearch.submit();
    }
    else
    {
        alert('Please select atleast one criteria to search');
        document.getElementById('FreeText').focus();
        return;
    }
}
function CheckSelect(id)
{
    var table = document.getElementById(''+ id +'');
    allNodes = table.getElementsByTagName('input');
    for(i = 0; i < allNodes.length; i++)
    {
        if(allNodes[i].checked)
        {
            return true;
            break;
        }
    }
    return false;
}
function validateyear()
{
    if(document.getElementById('s_year').value!=0 && document.getElementById('s_year').value!="")
    {
    }
    else
    {
        alert("Please Select Year First..");
        document.getElementById('s_month').value=0;
        document.getElementById('s_year').focus();
    }
}
function gotoPage(pageNo)
{
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/supplier-profile.html";
    document.frmArticle.pageNo.value = pageNo;
    document.frmArticle.submit();
}
function gotoSupplierPage(supplier, SupplierId,index,typeid)
{
    document.frmArticle.SupplierId.value = SupplierId;
    document.frmArticle.index.value = index;
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/supplier-profile/" + supplier + ".html";
    var nl = (screen.availWidth-500) / 2;
    var nh = (screen.availHeight-500) / 2;
    document.frmArticle.submit();
}

function Update_Profile(id)
{
    var nl = (screen.availWidth-600) / 2;
    var nh = (screen.availHeight-500) / 2;
    window.open(rootPath +"/supplier-profile/"+ id + "/update.html" ,"eurowin", "height=200,resize=0,width=400,scrollbars=yes,top="+nh+",left="+nl);
}

function gotocompany(id)
{
    if(id != 0)
    {
        document.frmArticle.companyid.value=id;
        document.frmArticle.pageNo.value=1;
        document.frmArticle.action = rootPath + "/supplier-profile.html";
        document.frmArticle.submit();
    }
}
function showall()
{
    document.frmArticle.action = rootPath + "/supplier-profile.html";
    document.frmArticle.pageNo.value=1;
    document.frmArticle.companyid.value="";
    document.frmArticle.submit();
}
function validateinfo()
{
    if(document.frmcontactinfo.cmpname.value == "" )
    {
        alert ("Please Enter the Company Name!");
        document.frmcontactinfo.cmpname.focus();
    }
    else if(document.frmcontactinfo.fname.value == "")
    {
        alert("Please Enter the First Name!");
        document.frmcontactinfo.fname.focus();
    }
    else if(document.frmcontactinfo.lastname.value == "")
    {
        alert("Please Enter the Last Name!");
        document.frmcontactinfo.lastname.focus();
    }
    else if(document.frmcontactinfo.job_title.value == "")
    {
        alert("Please Enter the Job Title!");
        document.frmcontactinfo.job_title.focus();
    }
    else if(document.frmcontactinfo.industry_sector.value == "")
    {
        alert("Please Enter the Industry Sector!");
        document.frmcontactinfo.industry_sector.focus();
    }
    else if(document.frmcontactinfo.address.value == "")
    {
        alert("Please Enter the Address!");
        document.frmcontactinfo.address.focus();
    }
    else if(document.frmcontactinfo.city.value == "")
    {
        alert("Please Enter the City!");
        document.frmcontactinfo.city.focus();
    }
    else if(document.frmcontactinfo.phone.value == "")
    {
        alert("Please Enter the Phone Number!");
        document.frmcontactinfo.phone.focus();
    }
    else if(document.frmcontactinfo.zip.value == "")
    {
        alert("Please Enter the Zip/Postal Code!");
        document.frmcontactinfo.zip.focus();
    }
    else if(document.frmcontactinfo.state.value == "")
    {
        alert("Please Enter the State/Province!");
        document.frmcontactinfo.state.focus();
    }
    else if(document.frmcontactinfo.email.value == "")
    {
        alert("Please Enter the Email!");
        document.frmcontactinfo.email.focus();
    }
    else
    {
        if(!isNumeric(document.frmcontactinfo.zip,'Enter the Valid Zip/Postal Code'))
        {
            return false;
        }
        if(!isNumeric(document.frmcontactinfo.phone,'Enter the Valid Phone Number'))
        {
            return false;
        }
        if(!isNumeric(document.frmcontactinfo.fax,'Enter the Valid Fax Number'))
        {
            return false;
        }
        if(!IsEmailValid(document.frmcontactinfo.email))
        return false;
        document.frmcontactinfo.action= "advertiserinfo.rails";
        document.frmcontactinfo.register.value ="true";
        document.frmcontactinfo.submit();
    }
}
function isNumeric(elem, helperMsg)
{
    var value=elem.value;
    var Chars = "0123456789-+ ";
    for (var i = 0; i < value.length; i++)
    {
        if (Chars.indexOf(value.charAt(i)) == -1)
        {
            alert(helperMsg);
            elem.focus();
            return false;
        }
    }
    return true;
}
function gotoevent(year)
{
    document.frmArticle.year.value=year;
    document.frmArticle.month.value="";
    document.frmArticle.submit();
}

function goToYear(year)
{
    document.frmArticle.year.value = year;
    document.frmArticle.month.value = "";
    document.frmArticle.pageNo.value = 1;
    document.frmArticle.submit();
}

function goToMonth(year, month)
{
    document.frmArticle.year.value = year;
    document.frmArticle.month.value = month;
    document.frmArticle.pageNo.value = 1;
    document.frmArticle.submit();
}

function valregister()
{
    if(CheckValidate())
    {
        document.frmadvertiser.action='advertise.html';
        document.frmadvertiser.submit();
    }
}
function CheckValidate()
{
    if(document.frmadvertiser.fname.value=="")
    {
        alert("Please! Enter the Name field");
        document.frmadvertiser.fname.focus();
        return false;
    }
    else if(document.frmadvertiser.faddress1.value=="")
    {
        alert("Please! Enter the address field");
        document.frmadvertiser.faddress1.focus();
        return false;
    }
    else if(document.frmadvertiser.fcity.value=="")
    {
        alert("Please! Enter the City field");
        document.frmadvertiser.fcity.focus();
        return false;
    }
    else if(document.frmadvertiser.fcountry.value==0)
    {
        alert("Please! Select the Country!");
        document.frmadvertiser.fcountry.focus();
        return false;
    }
    else if(document.frmadvertiser.fphone.value=="")
    {
        alert("Please! Enter the Phone Number");
        document.frmadvertiser.fphone.focus();
        return false;
    }
    else if(document.frmadvertiser.fmail.value=="")
    {
        alert("Please enter a e-mail address!");
        document.frmadvertiser.fmail.focus();
        return false;
    }
    else if(document.frmadvertiser.fcompany.value=="")
    {
        alert("Please! Enter the Company Name");
        document.frmadvertiser.fcompany.focus();
        return false;
    }
    else if(document.frmadvertiser.fcaddress1.value=="")
    {
        alert("Please! Enter the Company Address");
        document.frmadvertiser.fcaddress1.focus();
        return false;
    }
    else if(document.frmadvertiser.fcmail.value=="" || document.frmadvertiser.fcmail.value!="")
    {
        if(chkmail())
        {
            return chkFcmailmail();
        }
        return false;
    }
}
function chkFcmailmail()
{
    if (document.frmadvertiser.fcmail.value == "")
    {
        alert("Please enter a e-mail address!");
        document.frmadvertiser.fcmail.focus();
        return false;
    }
    else if(!IsEmailValid(document.frmadvertiser.fcmail))
    return false;
    else
    {
        return true;
    }
}
function chkmail()
{
    if(!IsEmailValid(document.frmadvertiser.fmail))
    return false;
    else
    {
        return true;
    }
}
function Submit()
{
    if(document.supplier.Cname.value=="")
    {
        alert("Please! enter the Company Name ");
        document.supplier.Cname.focus();
    }
    else if(document.supplier.Caddress.value=="")
    {
        alert("Please! enter the Company Address ");
        document.supplier.Caddress.focus();
    }
    else if(document.supplier.City.value=="")
    {
        alert("Please! enter the City ");
        document.supplier.City.focus();
    }
    else if(document.supplier.country.value=="" && document.supplier.country.value=="-- Select Country--")
    {
        alert("Please! Select the Country ");
        document.supplier.country.focus();
    }
    else
    {
        if(document.supplier.Cmail.value == "")
        {
            alert("Please enter Company E-Mail ID")
            document.supplier.Cmail.focus();
            return;
        }
        if(!IsEmailValid(document.supplier.Cmail))
        {
            return false;
        }
        document.supplier.action="SupplierFeedbackThanks.rails?sendmail=+send";
        document.supplier.submit();
    }
}
function winclose()
{
    window.close();
}
function seltype()
{
    for (i=0, n=document.frmsubscription.typ.length; i<n; i++)
    {
        if (document.frmsubscription.typ[i].checked)
        {
            document.frmsubscription.typ1.value = document.frmsubscription.typ[i].value;
            break;
        }
    }
}
function chkdate(val1)
{
    if(document.frmsubscription.CardType.checked==true)
    {
        if(val1!="")
        {
            var strSeparatorArray = new Array("-"," ","/",".");
            var strDateArray;
            for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
            {
                if (val1.indexOf(strSeparatorArray[intElementNr]) != -1)
                {
                    strDateArray = val1.split(strSeparatorArray[intElementNr]);
                }
            }
            if((strDateArray=="") || (strDateArray=="undefined"))
            {
                alert("Please enter the date in given format!");
                document.frmsubscription.ExpirDate.focus();
                return false;
            }
            else
            {
                if(strDateArray.length==2)
                {
                    if(isNaN(strDateArray[0]))
                    {
                        alert("Please enter the Month in numbers.");
                        document.frmsubscription.ExpirDate.focus();
                        return false;
                    }
                    else
                    {
                        document.frmsubscription.ExpirDate.value=strDateArray[0]+"/"+strDateArray[1];
                        return true;
                    }
                }
                else
                {
                    alert("Please enter the date in given format!");
                    document.frmsubscription.ExpirDate.focus();
                    return false;
                }
            }
        }
        else
        {
            alert("Please enter the Date!.");
            document.frmsubscription.ExpirDate.focus();
            return false;
        }
    }
}
function subscription()
{

    if(document.frmsubscription.company_name.value == "")
    {
        alert("Please Enter the Company Name");
        document.frmsubscription.company_name.focus();
        return;
    }
    else if(document.frmsubscription.reader_name.value == "")
    {
        alert("Please Enter the Name");
        document.frmsubscription.reader_name.focus();
        return;
    }
    else if(document.frmsubscription.job_title.value == "")
    {
        alert("Please Enter the Job Title");
        document.frmsubscription.job_title.focus();
        return;
    }
    else if(document.frmsubscription.reader_address.value == "")
    {
        alert("Please Enter the Address");
        document.frmsubscription.reader_address.focus();
        return;
    }
    else if(document.frmsubscription.reader_city.value == "")
    {
        alert("Please Enter the City");
        document.frmsubscription.reader_city.focus();
        return;
    }
    else if(document.frmsubscription.post_code.value == "")
    {
        alert("Please Enter the Post Code");
        document.frmsubscription.post_code.focus();
        return;
    }
     else if(document.frmsubscription.post_code.length > 10)
    {
        alert("Please Enter the vaild Post Code");
        document.frmsubscription.post_code.focus();
        return;
    }    
    else if(document.frmsubscription.country.value == "" || document.frmsubscription.country.value == "0")
    {
        alert("Please Select the Country");
        document.frmsubscription.country.focus();
        return;
    }
    else if(document.frmsubscription.country_code.value == "")
    {
        alert("Please Enter the Country Code");
        document.frmsubscription.country_code.focus();
        return;
    }
    else if(document.frmsubscription.country_code.value.length > 5)
    {
        alert("Please enter the valid country code");
        document.frmsubscription.country_code.focus();
        return;
    }
    else if(document.frmsubscription.reader_Fax.value == "")
    {
        alert("Please Enter the Fax Number");
        document.frmsubscription.reader_Fax.focus();
        return;
    }
    else if(document.frmsubscription.areacode.value.length > 24)
    {
        alert("Please enter the valid area code");
        document.frmsubscription.country_code.focus();
        return;
    }
    else if(document.frmsubscription.reader_email.value == "")
    {
        alert("Please Enter the Email");
        document.frmsubscription.reader_email.focus();
        return;
    }    
    else if(document.frmsubscription.industry.value == "0" && document.frmsubscription.Reader_Other_Ind.value == "" )
    {
        alert("Please Select or Enter the Industry");
        document.frmsubscription.industry.focus();
        return;
    }
    else if(document.frmsubscription.functionname.value == "0" && document.frmsubscription.Reader_Other_Function.value == "" )
    {
        alert("Please Select or Enter the Function");
        document.frmsubscription.functionname.focus();
        return;
    }
    else
    {
        var transaction_type = "";
        var len = document.frmsubscription.Method_subscrib.length;
        for(i=0; i< len ; i++)
        {
            var rdb = document.frmsubscription.Method_subscrib;
            if(rdb[i].checked)
            {
                transaction_type = rdb[i].value;
            }
        }
        if (transaction_type == "card")
        {
            if (document.frmsubscription.CardNum.value == '')
            {
                alert("Please enter the Card Number!");
                document.frmsubscription.CardNum.focus();
                return false;
            }
            if (document.frmsubscription.ExpirDate.value == '')
            {
                alert("Please enter the Date!");
                document.frmsubscription.ExpirDate.focus();
                return false;
            }
        }
        if(document.frmsubscription.reader_email.value != "")
        {
            if(!IsEmailValid(document.frmsubscription.reader_email))
            return false;
        }
        document.frmsubscription.hdsave.value = "Save";
        document.frmsubscription.action = rootPath + "/twofi-subscription-thanks.html";
        document.frmsubscription.submit();
    }
}

function selectallcategory(obj)
{
$(":checkbox").each(function()
{
    this.checked = obj.checked;
}
);
}
function callSectorsubmit()
{
    var count = 0;
$(":checkbox").each(function()
{
    if(this.checked)
    count++;
}
);
if(count > 0 || document.getElementById("i_selectedItems").value != "")
{
    document.frmArticle.action = rootPath + "/home/productbysector.rails";
    document.frmArticle.submit();
}
else
{
    alert('Please select any sector.');
}
}

function valmail()
{
    if(document.getElementById('r_senderEmail').value == "")
    {
        alert("Please enter your E-Mail ID")
        document.getElementById('r_senderEmail').focus();
        return;
    }
    
    if(!IsEmailValid(document.getElementById('r_senderEmail')))
    {
        return false;
    }
    
    if(document.getElementById('r_receiverEmail').value == "")
    {
        alert("Please enter Recipients E-Mail ID")
        document.getElementById('r_receiverEmail').focus();
        return;
    }
    
    if(!IsEmailValid(document.getElementById('r_receiverEmail')))
    {
        return false;
    }
    
    document.fmail.action = rootPath + "/process-refer-to-friend.html";
    document.fmail.submit();
}

function winclose()
{
    window.close();
}

function checkmail1()
{
    if (document.formEmail.email.value == "")
    {
        alert("Please enter a e-mail address!");
        document.formEmail.email.focus();
        return;
    }
    if(!IsEmailValid(document.formEmail.email))
    return false;
    if(document.formEmail.jobFunction.value=="" && document.formEmail.Other1.value == "")
    {
        alert("Please Select the Job Function");
        document.formEmail.jobFunction.focus();
        return false;
    }
    if(document.formEmail.activity.value=="")
    {
        alert("Please Select the Activity Profile");
        document.formEmail.activity.focus();
        return false;
    }
    if(document.formEmail.jobFunction.value=="Other")
    {
        if(document.formEmail.Other1.value=="")
        {
            alert("Enter Job Function As you have selected Other")
            document.formEmail.Other1.focus();
            return;
        }
    }
    if(document.formEmail.activity.value=="Other")
    {
        if(document.formEmail.Other2.value=="")
        {
            alert("Enter Activity As you have selected Other")
            document.formEmail.Other2.focus();
            return;
        }
    }
    if((document.formEmail.email.value!="")&&(document.formEmail.jobFunction.value!="" || document.formEmail.Other1.value!="")&&(document.formEmail.activity.value!="" || document.formEmail.Other2.value!=""))
    {
        document.formEmail.action = rootPath +  "/newsletter-subscription/subscribe.html"
        document.formEmail.submit();
    }
}
function checkmail2()
{
    if (document.formEmail.email.value == "")
    {
        alert("Please enter a e-mail address!");
        document.formEmail.email.focus();
        return true;
    }
    if(!IsEmailValid(document.formEmail.email))
    {
        return false;
    }
    else
    {
        a=confirm("Are you sure want to unsubscribe?");
        if(a)
        {
            document.formEmail.action = rootPath + "/newsletter-subscription/unsubscribe.html";
            document.formEmail.submit();
        }
    }
}
function selJob()
{
    if(document.formEmail.jobFunction.value=="Other")
    {
        alert("Enter Job Function Below")
        document.formEmail.Other1.disabled=false;
        document.formEmail.Other1.focus();
    }
    else
    {
        document.formEmail.Other1.disabled=true;
    }
}
function selActivity()
{
    if(document.formEmail.activity.value=="Other")
    {
        alert("Enter Activity Profile Below")
        document.formEmail.Other2.disabled=false;
        document.formEmail.Other2.focus();
    }
    else
    {
        document.formEmail.Other2.disabled=true;
    }
}
function IsEmailValid(Temp)
{
    var AtSym = Temp.value.indexOf('@');
    var Period = Temp.value.lastIndexOf('.');
    var Space = Temp.value.indexOf(' ')
    var Length = Temp.value.length - 1 // Array is from 0 to length-1
    if ((AtSym < 1) || // '@' cannot be in first position
    (Period <= AtSym+1) || // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) || // Must be atleast one valid char after '.'
    (Space != -1)) // No empty spaces permitted
    {
        alert('Enter a valid e-mail address!')
        Temp.focus()
        return false;
    }
    return true;
}
function openregisterhits(id,url)
{
    url = escape(url);
    window.open(rootPath + "/home/registerhits.rails?bannerId=" + id + "&destinationurl="+ url); 
}
function selectallarticle(obj)
{
$(":checkbox").each(function()
{
    this.checked = obj.checked;
}
);
}
function submitForm(action)
{
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/home/"+ action;
    document.frmArticle.submit();
}
function gotoPage(pageNo,action)
{
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath +"/"+ action;
    document.frmArticle.pageNo.value = pageNo;
    document.frmArticle.submit();
}
function callsubmit(action)
{
    document.frmArticle.target = "_self";
    document.frmArticle.SortBy.value = document.getElementById('sortfield').value;
    document.frmArticle.SortDirection.value = document.getElementById('sortorder').value;
    document.frmArticle.action = rootPath +"/"+ action;
    document.frmArticle.submit();
}
function gotoArticlePage(index, seourl)
{
    document.frmArticle.index.value = index;
    document.frmArticle.target = "_self";
    document.frmArticle.action = rootPath + "/article/"+seourl+".html";
    document.frmArticle.submit();
}
function callNews(formId, actionUrl)
{
    document.getElementById(formId).action = actionUrl;
    document.getElementById(formId).submit();
    return false;
}