

var cookieVal;
var SurveysCount = "0";

var SurveyID = [];
var Height = [];
var ID;
var URL;
var i = -1;


if( getCookie("RotatorCounter")== "")
{
    cookieVal = -1;
}
else
{
    cookieVal = getCookie("RotatorCounter");
}


if (SurveysCount != 0)
{
    if (cookieVal == -1 || (cookieVal < SurveysCount - 1))
    {
        cookieVal++;
        
        CheckSurveyVoted(cookieVal);
    }
    else
    {
        cookieVal = 0;
        CheckSurveyVoted(cookieVal);
    }
}

function CheckSurveyVoted(cookie)
{
    ID = SurveyID[cookie];

    if ( getCookie(ID) == "")
    {
        
        URL = "http://www.jeeran.com/surveys/polls/pollwidgetinitial.aspx?rnd=10&lang=e" + "&surveyid=" + ID + "&height=" + Height[cookie];
        setCookie("RotatorCounter",cookie,365,'www.jeeran.com','www.jeeran.com/surveys/');
    }
    else
    {
        if (i < SurveysCount - 1)
        {
            
            
            CheckSurveyVoted(++i);
        }
        else
        {
            
            
            if (getCookie("RotatorCounter") == "")
            {
                cookie = -1;
            }
            else
            {
                cookie = getCookie("RotatorCounter");
            }


            
            
            if (SurveysCount != 0)
            {
                if (cookie == -1 || (cookie < SurveysCount - 1))
                {
                    cookie++;
                }
                else
                {
                    cookie = 0;
                }

                ID = SurveyID[cookie][""];
                
                URL = "http://www.jeeran.com/surveys/polls/pollwidgetinitial.aspx?rnd=10&lang=e" + "&surveyid=" + ID + "&height=" + Height[cookie];
                JeeranBL.JeeranFunctions.Cookies.PopulateCookie("RotatorCounter", cookie.ToString());
                setCookie("RotatorCounter","'+cookie+'",365,'www.jeeran.com','www.jeeran.com/surveys/');
            }

        }
        
}
}


function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
      {   
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
      } 
    }
    return "";
}

function setCookie(c_name,value,expiredays,path,domain)  
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); +
    ( ( path==null ) ? "" : ";path=" + path  ) + 
    ( ( domain==null ) ?  "": ";domain=" + domain );
}


document.write('<script language="javascript" src="'+URL+'"></script>');
