﻿// Feedback Form Script -----------------------------------------------------
function Expand()
{
    var BackgroundElement = document.getElementById("GradientLayer");
    
    BackgroundElement.style.height = "100%";
    
    if (document.body.offsetHeight > BackgroundElement.offsetHeight)
    {
        BackgroundElement.style.height = document.body.offsetHeight + "px";
    }
    
    document.getElementById("GradientLayer").style.display = "";
    document.getElementById("FeedbackLayer").style.display = "";
    Animate();
}

function Animate()
{
    var Element = document.getElementById("FeedbackContent");
    
    if (Element.offsetWidth < 402)
    {
        Element.style.width = Element.offsetWidth + 10 + "px";
        setTimeout("Animate()", 0);
    }
    else if (Element.offsetHeight < 330)
    {
        Element.style.height = Element.offsetHeight + 10 + "px";
        setTimeout("Animate()", 0);
    }
    else
    {
        if (Element.offsetHeight > 330)
        {
            Element.style.height = "330px";
        }
        
        if (Element.offsetWidth > 402)
        {
            Element.style.width = "402px";
        }
        GetFeedbackPage();
    }
}

function GetFeedbackPage()
{
    var xmlHttp;
    xmlHttp=GetXmlHttpObject();
    
    if (xmlHttp != null)
    {
        var url = document.URL;
        
        if (url.indexOf("www") > -1)
        {
            url = "http://www.RajasthanEducation.net/common/pop/FeedbackForm.aspx";
        }
        else
        {
            url = "http://www.RajasthanEducation.net/common/pop/FeedbackForm.aspx";
        }
        
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
   		        document.getElementById("FeedbackContent").innerHTML = xmlHttp.responseText;
            }
        }
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}

function OnChanda(Mama)
{
    Mama.style.borderColor = "#CCCCCC";
}

function OffChanda(Mama)
{
    if (Mama.style.borderStyle != "solid")
    {
        Mama.style.borderColor = "#FFFFFF";
    }
}

function OnClickChanda(Mama,DoorKe)
{
    var RateSection = Mama.id;
    RateSection = RateSection.replace("Chanda", "");
    
    for (i = 0; i <=5; i++)
    {
        RateSection = RateSection.replace(i, "");
    }

    for (i = 1; i <= 5; i++)
    {
        document.getElementById(RateSection + "ChandaImg" + i).style.border = "0px";
    }
    
    var ImgElement = document.getElementById(document.getElementById(Mama.id).getElementsByTagName("img").item(0).id);
    ImgElement.style.border = "1px solid #8FA041";
    
    var Rating = Mama.id;
    Rating = Rating.replace(RateSection + "Chanda", "");
    
    document.getElementById("Rating" + DoorKe).value = Rating;
}

function ChangeTab(Element)
{
    var TabNum =  Element.id;
    TabNum = TabNum.replace("Tab","");
    
    Element.style.display = "none";

    for (i = 1; i <=3; i++)
    {
        if (i != TabNum)
        {
            document.getElementById("Tab" + i).style.display = "";
            document.getElementById("ActiveTab" + i).style.display = "none";
            document.getElementById("BoxTab" + i).style.borderColor = "#CCC";
        }
        else
        {
            document.getElementById("ActiveTab" + i).style.display = "";
            document.getElementById("BoxTab" + i).style.borderColor = "#FFF";
        }
    }
    
    document.getElementById("FeedBox").style.display = "";
    document.getElementById("Feedback").focus();
    document.getElementById("Tab").value = TabNum;
    
    document.getElementById("FeedbackContent").style.height = document.getElementById("MainDiv").offsetHeight;
}

function validate()
{
    var TheForm = document.getElementById("FeedForm");

    if (((TheForm.Subscribe.checked == true) || (TheForm.MailingList.checked == true)) && (TheForm.Email.value.length == 0))
    {
        alert("Please Enter Your Email!");
        return (false);
    }
    
    if (TheForm.Email.value == "")
    {
        alert("Please Ener Your Email Address!");
        return (false);
    }
    
    if (TheForm.Email.value !="") {
    var email = TheForm.Email.value;
    var count=0;
    var dot=0;
    var len=email.length-1;
    var error=false;
    var loc=email.indexOf("@");

    if ((email.charAt(0)=='@')||(email.charAt(len)=='@')||(email.charAt(0)=='.')||(email.charAt(len)=='.'))  //First or last characters cannot be @ 0r .
      { error=true; }

    for(var i=0;i<email.length;i++)
      { if (email.charAt(i)=='@')//checks to see if there are more than one @s
                    { count++; }
    }

    if ((count>1)||(count==0))//there are no or more than one @s
      { error=true; }

    for(var j=loc;j<email.length;j++) {
      if (email.charAt(j)=='.')
           { dot++; }
    }

    if (dot==0) { error=true; }

    if ((email.charAt(loc-1)=='.')||(email.charAt(loc+1)=='.'))
      { error=true;   }

    for(var k=0;k<email.length;k++) {
     if (email.charAt(k)==' ')//checks to see if there are more than one @s
          { error=true; }
    }

    if (error==true) {
      alert('Incorrect e-mail address');
      TheForm.Email.focus();
    return (false); }
    }
    
    if (CheckData(TheForm) == false)
    {
        alert("Feedback is required! You must either give rating or enter some details!");
        return (false);
    }
    
    if ((TheForm.CodeNumberTextBox.value == "Enter Code") || (TheForm.CodeNumberTextBox.value == ""))
    {
        alert("Please enter the text code shown on the left bottom, in the text box just to it's ritht!");
        TheForm.CodeNumberTextBox.focus();
        return (false);
    }

    document.getElementById("FeedProgressImg").style.display = "";
    PostFeedback();

    return (false);
}

function CheckData(TheForm)
{
    var TheName;
    
    if ((TheForm.Rating1.value.length == 0) && (TheForm.Rating2.value.length == 0) && (TheForm.Rating3.value.length == 0) && (TheForm.Rating4.value.length == 0) && (TheForm.Feedback.value.length == 0))
    {
        return (false);
    }
    
    return (true);
}

function PostFeedback()
{
    var Form = document.getElementById("FeedForm")

    var xmlHttp;
    xmlHttp = GetXmlHttpObject();
    
    if (xmlHttp != null)
    {
        var url = document.URL;
        
        if (url.indexOf("www") > -1)
        {
            url = "http://www.RajasthanEducation.net/common/pop/FeedbackForm.aspx";
        }
        else
        {
            url = "http://www.RajasthanEducation.net/common/pop/FeedbackForm.aspx";
        }
        
        url = url + "?FullName=" + Form.FullName.value;
        url = url + "&Email=" + Form.Email.value;
        url = url + "&City=" + Form.FullName.value;
        url = url + "&Subscribe=" + Form.Subscribe.value;
        url = url + "&MailingList=" + Form.MailingList.value;
        url = url + "&Feedback=" + Form.Feedback.value;
        url = url + "&Rating1=" + Form.Rating1.value;
        url = url + "&Rating2=" + Form.Rating2.value;
        url = url + "&Rating3=" + Form.Rating3.value;
        url = url + "&Rating4=" + Form.Rating4.value;
        url = url + "&Tab=" + Form.Tab.value;
        url = url + "&CodeNumberTextBox=" + Form.CodeNumberTextBox.value;
        url = url + "&Perform=PostFeed";
        
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState==4)
            {
                if (xmlHttp.responseText == "Please Enter The Correct Captcha Code!")
                {
                    document.getElementById("FeedProgressImg").style.display="none";
                    alert(xmlHttp.responseText);
                }
                else
                {
                    document.getElementById("FeedbackContent").innerHTML = xmlHttp.responseText;
                }
            }
        }
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}

function RestoreFeedback()
{
    document.getElementById("GradientLayer").style.display="none";
    document.getElementById("FeedbackLayer").style.display="none";
    document.getElementById("FeedbackContent").innerHTML = "";
    document.getElementById("FeedbackContent").style.height = "25px";
    document.getElementById("FeedbackContent").style.width = "25px";
}

//AJAX Function for finding client XML HTTP Object
//------------------------------------------------
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  
if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    
return xmlHttp;
}
//----------------------------------------------------------------------------
//--------------------------------------------------------//
function ChangeImage()
{
    var TheImage = document.getElementById("CaptchaImage");
    
    if (TheImage.src == "http://www.RajasthanEducation.net/captcha/feed_captcha.aspx")
    {
        TheImage.src = "http://www.RajasthanEducation.net/captcha/feed_changecaptcha.aspx";
    }
    else
    {
        TheImage.src = "http://www.RajasthanEducation.net/captcha/feed_captcha.aspx";
    }
}
//-------------------------------------------------------//
// Feedback Form Script Ends ---------------------------//
// Group Logo Script ----------------------------------//
function popup1(programName, width, height)
    {
        var temp = "menubar=yes,toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
        displayWindow = window.open(programName, "displayWindow", temp);
    }
    
    function Bookmark()
    {
        var url = document.URL;
        var title = document.title;
    
        if (window.sidebar) // Mozilla Firefox Bookmark 
        { 
            window.sidebar.addPanel(title, url,"");
        } 
        else if( window.external ) // IE Favorite
        { 
            window.external.AddFavorite( url, title); 
        }
        else
        {
            alert("This browser is not supported! Please press Ctrl+D to bookmark this page.");
        }
    }
    
    function PrintArticle()
    {
        var url = document.getElementById('ctl00_GroupGogo1_CurrentURL').value;
        window.open("http://www.RajasthanEducation.net/common/pop/print.aspx?url=" + url, "myWindow", "height=700, width=731, menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
    }
        
    function popmail(url)
    { 
        window.open("http://www.RajasthanEducation.net/common/pop/Mailto.aspx?url=" + url, "myWindow", "height=700, width=731,menubar=no,toolbar=no,location=no,status=yes,scrollbars=yes,resizable=no");
    }
    
    function ChangeFontSize(Order)
    {
        var TheElement = document.getElementById("ctl00_ContentPlaceHolder1_Content");
        var FontSize = TheElement.style.fontSize;
            
        if ((FontSize == null) || (FontSize == ""))
        {
            if (Order == "Decrease")
            {
                TheElement.style.fontSize = "11px";
            }
            else
            {
                TheElement.style.fontSize = "13px";
            }
        }
        else
        {
            FontSize = parseInt(FontSize.replace("px", ""));
            
            if (Order == "Decrease")
            {
                TheElement.style.fontSize = FontSize - 1 + "px";
            }
            else
            {
                TheElement.style.fontSize = FontSize + 1 + "px";
            }
        }
    }
// Group Logo Script Ends -------------------------------------//
function validform(theForm)
{
    if (theForm.user.value == "")
    {
        alert("Please Enter Username!");
        theForm.user.focus();
        return (false);
    }
    
    if (theForm.pwd.value == "")
    {
        alert("Please Enter Password!");
        theForm.pwd.focus();
        return (false);
    }
    return (true);
}

function st2bottom(tbottom) {

    for (bottomi = 1; bottomi<=8; bottomi++) {
        tsbottom = document.getElementById('ttbottom' + bottomi);
        trbottom = document.getElementById('ddbottom' + bottomi);
        tabottom = document.getElementById('aabottom' + bottomi);
        if (tbottom == bottomi) {
            tsbottom.className = "tbmain2bottom1";
            tabottom.className = "srchlinksel2bottomb";
            tsbottom.style.borderBottom = "1px solid #A0C9E7";
            trbottom.style["display"] = "block";
            trbottom.style["visibility"] = "visible";
            
        }
        else {
            tsbottom.className = "tb2bottom1";
            tabottom.className = "srchlink2bottomb";
            tsbottom.style.borderBottom = "1px solid #73AEDB";
            trbottom.style["display"] = "none";
            trbottom.style["visibility"] = "hidden";
        }

    }
}
//---Google adds---------------------------------------------------------------------------------//
function positioneredu()
{
    document.getElementById('elemente2').style.left = document.getElementById('elemente1').offsetLeft -137 + "px";
    document.getElementById('elemente2').style.top = document.getElementById('elemente1').offsetTop + "px";
    document.getElementById('elemente2').style.display = '';
}

function positioner()
{
    document.getElementById('element2').style.left = document.getElementById('element1').offsetLeft -137 + "px";
    document.getElementById('element2').style.top = document.getElementById('element1').offsetTop + "px";
    document.getElementById('element2').style.display = '';
}

function positionerspeech()
{
    document.getElementById('elements2').style.left = document.getElementById('elements1').offsetLeft -137 + "px";
    document.getElementById('elements2').style.top = document.getElementById('elements1').offsetTop + "px";
    document.getElementById('elements2').style.display = '';
}



function positioner4()
{
    document.getElementById('element12').style.left = document.getElementById('element11').offsetLeft -137 + "px";
    document.getElementById('element12').style.top = document.getElementById('element11').offsetTop + "px";
    document.getElementById('element12').style.display = '';
}

function positioner2()
{
    document.getElementById('element20').style.left = document.getElementById('element10').offsetLeft -137 + "px";
    document.getElementById('element20').style.top = document.getElementById('element10').offsetTop + "px";
    document.getElementById('element20').style.display = '';
}

function positioner3()
{
    document.getElementById('element200').style.left = document.getElementById('element100').offsetLeft -137 + "px";
    document.getElementById('element200').style.top = document.getElementById('element100').offsetTop + "px";
    document.getElementById('element200').style.display = '';
}
//---Google adds ends---------------------------------------------------------------------------------//
