var val = "";
if(document.domain == "indiaeducation.net" || document.domain == "www.indiaeducation.net")
{l_cl = "<div style='display: none; width: 42px; height: 40px; background:transparent  url(http://s4i.indiaeducation.net/search/images/close-x.png) no-repeat scroll ' alt='Close' class='Closepanelimg' onclick='CloseLoginPanel_common()' title='Close' id='CloseLocationImg'></div>";}
else
{l_cl = "<img src='http://s4i.indiaeducation.net/search/images/close-x.png' alt='Close' class='Closepanelimg' onclick='CloseLoginPanel_common()' title='Close' id='CloseLocationImg' style='display:none;' />";}
var logintext = "<link href='http://indiaeducation.net/common/css/login.css' rel='stylesheet' type='text/css' />";
logintext = logintext + "<div id='Gradient_Login' style='background-image: url(http://s4i.indiaeducation.net/search/images/bac.gif);'></div>";
logintext = logintext + "<div id='Login' class='Login' style='position:fixed;'><center><div class='Closepanel'>"+l_cl+"";
logintext = logintext + "<img src='http://indiaeducation.net/img/transparent.png' style='cursor: pointer;float: right;position:absolute;margin-left:27px;margin-top:319px;' onclick='CWL_common()' id='Img1' />";
logintext = logintext + "<iframe id='Loginframe' name='Loginframe' src='http://indiaeducation.net/common/login.aspx?url=" + document.location.href + "' class='iframe' scrolling='no' frameborder='0'></iframe></div></center></div><form id='v3_form' name='v3_form' method='post' action='http://indiaeducation.net/common/login.aspx?url=" + document.location.href + "' target='Loginframe'><input id='v3' name='v3' type='hidden'></form>";
document.write(logintext);
var popupStatus_common = 0;
function loadPopup_common(Layer_common) {
document.getElementById("Login").style.display = "block";
document.getElementById("Gradient_Login").style.display = "block";
document.getElementById("Gradient_Login").className = "BackInner_Login";
}
function disablePopup_common(Layer_common) {
document.getElementById("Login").style.display = "none";
document.getElementById("Gradient_Login").style.display = "none";
document.getElementById("Gradient_Login").className = "";
}
function centerPopup_common(Layer_common) { 
    var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var ScreenHeight = screen.height;
	var ScreenWidth = screen.width;
	var popupHeight = 600;
	var popupWidth = 1300;	
	var TopPos = Math.round((parseInt(screen.height) * 15) / 100);
	var LeftPos = Math.round((parseInt(screen.width) * 30) / 100);
	var TopHeight = Math.round((parseInt(windowHeight / 2.3) - parseInt(popupHeight / 2.3)));
	var LeftWidth = Math.round((parseInt(windowWidth / 2.3) - parseInt(popupWidth / 2.3)));
	var left = (screen.width / 2) - (popupWidth / 2);
	var top = (screen.height / 2) - (popupHeight / 2);
    document.getElementById(Layer_common).style.top = top + "px";
    document.getElementById("CloseLocationImg").style.display = "block";
}
function CloseLoginPanel_common() {
    disablePopup_common("Login");
}
function CWL_common() {
    disablePopup_common("Login");
}
function common_login() {
        centerPopup_common('Login');
        loadPopup_common('Login');
    }
    function common_login_state(v) {
        document.v3_form.v3.value = v;
        document.v3_form.submit();
        setTimeout("centerPopup_common('Login')", 500);
        setTimeout("loadPopup_common('Login')", 500);
    }
    function common_login_state_alert(v) {
        document.v3_form.v3.value = v;
        document.v3_form.submit();
        alert('You need to Login first.');
        setTimeout("centerPopup_common('Login')", 500);
        setTimeout("loadPopup_common('Login')", 500);
    }
 function Logout() {
     window.location.href = "http://indiaeducation.net/common/Edupallogout.aspx?logout=" + location.href;
 }
 function Session_Logout()
 {
 window.location.href = "http://indiaeducation.net/Logout.aspx?url=" + location.href;
}
function setstate(value) {
    var expiredays = "1";
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = "StateValue=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
}
function getstate() {
    var c_name = "StateValue";
    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 querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
return "";
    }
}

function shohidpol(val1) {
    document.getElementById("poll1btn").onclick = function() { };
    document.getElementById("poll2btn").onclick = function() { };
    if (val1 == 2) {
        $("#spoll1").fadeOut('fast');
        setTimeout("$('#spoll2').fadeIn('slow'); $('#poll2btn').html('VOTE NOW'); $('#poll1btn').html('VIEW POLL');", 400);
        document.getElementById("poll1btn").onclick = function() { shohidpol(1) };
        document.getElementById("poll2btn").onclick = function() { pollvote("poll2"); };
    }
    if (val1 == 1) {
        $("#spoll2").fadeOut('fast');
        setTimeout("$('#spoll1').fadeIn('slow'); $('#poll1btn').html('VOTE NOW'); $('#poll2btn').html('VIEW POLL');", 400);
        document.getElementById("poll2btn").onclick = function() { shohidpol(2) };
        document.getElementById("poll1btn").onclick = function() { pollvote("poll1"); };
    }
}
var vst; var vid;
function reswidvot(val1) {
    vst = val1.split('-');vid = val1;
    pollvote('poll' + vst[0]);
}
function pollvote(obj) {
    var perf; var opt; var val1;
    if (vst != undefined) { perf = "res";val1 = vid;vid = undefined;  vst = undefined; }
    else {
        var opt = document.getElementsByName(obj);
        for (var i = 0; i < opt.length; i++) {
            if (opt[i].checked == true) {
                val1 = opt[i].value; break;
            }
        }
        if (val1 == undefined) {
            alert('Please select POLL option'); return false;
        }
        perf = "vot";
    }
    if (perf == "vot") {
        document.getElementById(obj + 'btn').innerHTML = "<img src='http://edupal.in/img/load.gif' />";
        document.getElementById(obj + 'btn').onclick = function() { }
    }
    else { if (obj == "poll1") document.getElementById('resp1').innerHTML = "<img src='http://edupal.in/img/load.gif' />"; else document.getElementById('resp2').innerHTML = "<img src='http://edupal.in/img/load.gif' />"; }
   
    var xmlHttp;
    xmlHttp = GetXmlHttpObject();  
    var url = "vpoll.aspx?vid=" + val1 + "&type="+obj+"&Perform="+perf;
    if (xmlHttp != null) {
        //alert(url);
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                document.getElementById(obj + 'btn').innerHTML = "VOTE NOW";
                var resp = xmlHttp.responseText;
                var pdata = resp.split('<>');
                if (pdata[0] == "fail") { alert("Server is not responding properly. Please try again latter."); return false; }
                if (pdata[0] == "duplicate") { alert("Please cast your vote only one time for a POLL."); return false; }
                if (pdata[0] == "success") {
                    if (perf == "vot") alert("Thank you. Your vote accepted.");
                    
                    if (obj == "poll1") {
                        $("#spoll1").empty(); $("#sortpol1").empty();
                        $("#spoll1").html(pdata[2]);
                        $("#spoll1c").html(pdata[1]); 
                        document.getElementById('sortpol1').style.display = "none";
                        document.getElementById('spoll1').style.display = "block";
                        document.getElementById('mbtnpoll1').style.display = "block";
                        if (perf == "vot") document.getElementById("poll1btn").onclick = function() { alert('Please cast your vote only one time for a POLL.'); };
                        else document.getElementById("poll1btn").onclick = function() { pollvote(obj); };
                    }
                    else {
                        $("#spoll2").empty(); $("#sortpol2").empty();
                        $("#spoll2").html(pdata[2]);
                        $("#spoll2c").html(pdata[1]);
                        document.getElementById('sortpol2').style.display = "none";
                        document.getElementById('spoll2').style.display = "block";
                        document.getElementById('mbtnpoll2').style.display = "block";
                        if (perf == "vot") document.getElementById("poll2btn").onclick = function() { alert('Please cast your vote only one time for a POLL.'); };
                        else document.getElementById("poll2btn").onclick = function() { pollvote(obj); };
                    }
                }

                // alert(resp);
            }
        }

        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }

}
