﻿
/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
    jQuery('#mycarousel-bt-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-bt-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
    left_rightHeight();
};

function jscrolls()
{   
    // Ride the carousel...
        jQuery(document).ready(function() {
            jQuery('#mycarousel').jcarousel({
            scroll: 3,
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
            });
        });
        
        jQuery(document).ready(function() {
            jQuery('#mycarousel-bt').jcarousel({
            scroll: 3,
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
            });
        });
}

function jscrolls_Photo()
{   
    // Ride the carousel...
        jQuery(document).ready(function() {
            jQuery('#mycarousel_photo').jcarousel({
            scroll: 1,
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
            });
        });
}

function changeTextBG(e,id)
{   
    document.getElementById(id).className = "txtBoxBG_imgColor";
}

function changeTextAreaBG(e,id)
{
    document.getElementById(id).className = "txtAreaBG_imgColor";
}

function changeCaptchaBG(e,id)
{
    document.getElementById(id).className = "txtJCAP_imgColor";
}

function removeTextBG(id)
{   
    if(document.getElementById(id).value == "")
        document.getElementById(id).className = "txtBoxBG_img";
}
function removeTextAreaBG(id)
{   
    if(document.getElementById(id).value == "")
        document.getElementById(id).className = "txtAreaBG_img";
}
function removeCaptchaBG(id)
{   
    if(document.getElementById(id).value == "")
        document.getElementById(id).className = "txtJCAP_img";
}


function hide_showLayer(count)
{
    if(document.getElementById("img" + count) != null)
    {
        document.getElementById("showDiv"+count).innerHTML = "<img src=\"/Images/open-icon.jpg\" alt=\"Show\" title=\"Show\" class=\"width9 height9 border0 padrt6\" />Show";
        document.getElementById("hideData"+count).style.display = 'none';
    }
    else
    {
        document.getElementById("showDiv"+count).innerHTML = "<img id=\"img"+ count +"\" src=\"/Images/hide-icon.jpg\" alt=\"Hide\" title=\"Hide\" class=\"width9 height3 border0 padrt10 marbt2\" />Hide";
        document.getElementById("hideData"+count).style.display = 'block';
    }
    left_rightHeight();
}

function show_FirstLayer()
{
    for(var i = 0; i < 100; i++)
    {
        if(document.getElementById("showDiv" + i) != null)
        {
            document.getElementById("showDiv"+ i).innerHTML = "<img id=\"img"+ i +"\" src=\"/Images/hide-icon.jpg\" alt=\"Hide\" title=\"Hide\" class=\"width9 height3 border0 padrt10 marbt2\" />Hide";
            document.getElementById("hideData"+ i).style.display = 'block';
            break;
        }
    }
}
function checkForm(rowNo)
{
    
    for (var i = 1; i < rowNo; i++)
    {   
        if(document.getElementById("chkFormText"+ i) != null)
        {   
            if(document.getElementById("chkFormText" + i).value == "")
            {   
            
                alert("All fields marked with an * are mandatory.");
                return;
            }
        }
        else if (document.getElementById("chkFormArea"+ i) != null)
        {
            if(document.getElementById("chkFormArea" + i).value == "")
            {   
                alert("All fields marked with an * are mandatory");
                return;
            }
        }
        else if(document.getElementById("Email") != null)
        {
            if(validateEmail(document.getElementById("Email").value) == false)
            {   
                alert("Please enter a valid email id.");
                return;
            }
        }
    }
    if(jcap() == true)
    {
        document.form1.submit();
    }
}

function clearForm(rowNo)
{   
    for (var i = 1; i < rowNo; i++)
    {   
        if(document.getElementById("chkFormText"+ i) != null)
        {
            document.getElementById("chkFormText" + i).value = "";
            document.getElementById("chkFormText" + i).className = "txtBoxBG_img";
        }
        if(document.getElementById("chkFormText_"+ i) != null)
        {
            document.getElementById("chkFormText_" + i).value = "";
            document.getElementById("chkFormText_" + i).className = "txtBoxBG_img";
        }
        if(document.getElementById("chkFormArea"+ i) != null)
        {
            document.getElementById("chkFormArea" + i).value = "";
            document.getElementById("chkFormArea" + i).className = "txtAreaBG_img";
        }
        if(document.getElementById("chkFormArea_"+ i) != null)
        {
            document.getElementById("chkFormArea_" + i).value = "";
            document.getElementById("chkFormArea_" + i).className = "txtAreaBG_img";
        }
        if(document.getElementById("chkFormArea_"+ i) != null)
        {
            document.getElementById("Email").value = "";
            document.getElementById("Email").className = "txtAreaBG_img";
        }
    }
    window.location
}

function validateEmail(id)
{
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return reg.test(id); 
}

function viewVideo(enc)
{
    window.open("/VideoPopup.aspx?enc="+ enc +"","preview","width=490,height=315,left=450%,top=150%,resizable=no");
}

function left_rightHeight()
{
    var contentHeight = "";
    if(document.getElementById("Content") != null)
    {
        document.getElementById("leftImage").style.height = ""; 
        document.getElementById("rigthImage").style.height = ""; 
        
        contentHeight = document.getElementById("Content").clientHeight;
        //document.getElementById("hdnheightcontent").innerHTML=contentHeight;
       // alert(contentHeight);
        document.getElementById("leftImage").style.height = parseInt(contentHeight) + 1 + 'px'; 
        document.getElementById("rigthImage").style.height = parseInt(contentHeight) + 1 + 'px'; 
        //document.getElementById("hdnheight").value=parseInt(contentHeight) + 1 + 'px';
    }
}



function chekcOption()
{
    if(document.getElementById("rbtnAns1").checked == false && document.getElementById("rbtnAns2").checked == false && document.getElementById("rbtnAns3").checked == false)
    {
        alert('Please select one Option');
        return;
    }
}

function searchResult()
{   
    if(document.getElementById("txtSearch") != null)
    {
        if(document.getElementById("txtSearch").value == "")
            alert('Please enter text to search');
        else
        {
            window.location = "/SearchResult.aspx?stext=" + document.getElementById("txtSearch").value;
            return false;
        }
    }
}

function search_Result(e)
{
    if (e.keyCode == 13)
    {
        searchResult();
        return false;
    }
}
function Showdiv(objhid,totalcount)
{
    var i=0;
    var id="";
  
    for( i=1; i<=totalcount;i++)
    {
        id=(document.getElementById("divpub"+i).id);        
        if(id!=objhid)
         document.getElementById(id).style.display = 'none';
        else
         document.getElementById(objhid).style.display = 'block';
    }
}

function chkSearch()
{
    if(document.getElementById("txtSearch") != null)
    {
        if(document.getElementById("txtSearch").value == "Search")
            document.getElementById("txtSearch").value = "";
    }
}

function chkEmail()
{
    if(document.getElementById("txtName") != null)
    {
        if(document.getElementById("txtName").value == "" || document.getElementById("txtEmail").value == "")
        {
            alert("Please enter your name and Eamil id.");
            return
        }
        if(validateEmail(document.getElementById("txtEmail").value) == false)
        {
            alert("Please enter your valid Eamil id.");
            return
        }
        if(document.getElementById("txtEmail1").value == "" && document.getElementById("txtEmail2").value == "" && document.getElementById("txtEmail3").value == "" && document.getElementById("txtEmail4").value == "" && document.getElementById("txtEmail5").value == "")
        {
            alert("Please enter atleast one Eamil id.");
            return
        }
        if(document.getElementById("txtEmail1").value != "")
        {
            if(validateEmail(document.getElementById("txtEmail1").value) == false)
            {
                alert("Please enter valid Eamil id.");
                return
            }
        }
        if(document.getElementById("txtEmail2").value != "")
        {
            if(validateEmail(document.getElementById("txtEmail2").value) == false)
            {
                alert("Please enter valid Eamil id.");
                return
            }
        }
        if(document.getElementById("txtEmail3").value != "")
        {
            if(validateEmail(document.getElementById("txtEmail3").value) == false)
            {
                alert("Please enter valid Eamil id.");
                return
            }
        }
        if(document.getElementById("txtEmail4").value != "")
        {
            if(validateEmail(document.getElementById("txtEmail4").value) == false)
            {
                alert("Please enter valid Eamil id.");
                return
            }
        }
        if(document.getElementById("txtEmail5").value != "")
        {
            if(validateEmail(document.getElementById("txtEmail5").value) == false)
            {
                alert("Please enter valid Eamil id.");
                return
            }
        }
        if(document.getElementById("txtName1").value != "" && document.getElementById("txtEmail1").value == "")
        {
            alert("Please enter Eamil id.");
            return
        }
        if(document.getElementById("txtName2").value != "" && document.getElementById("txtEmail2").value == "")
        {
            alert("Please enter Eamil id.");
            return
        }
        if(document.getElementById("txtName3").value != "" && document.getElementById("txtEmail3").value == "")
        {
            alert("Please enter Eamil id.");
            return
        }
        if(document.getElementById("txtName4").value != "" && document.getElementById("txtEmail4").value == "")
        {
            alert("Please enter Eamil id.");
            return
        }
        if(document.getElementById("txtName5").value != "" && document.getElementById("txtEmail5").value == "")
        {
            alert("Please enter Eamil id.");
            return
        }
        document.getElementById('btnSend').click();
    }
}
