
var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;

function linkRef(yurl ){
var linkref = yurl;
if(confirm("are you sure you want to delete?")){
window.location.href=linkref + '&ref='+location.href;
}
}

function jssubmitmessage(form,subjectfield,messagefield,usernamefield,topicid,action,parentid,spanid,formid,level)
{   

     
	url ='/lib/showmessage.php?subject=' + subjectfield.value + '&message=' + messagefield.value + '&username=' + usernamefield.value + '&topicid='+topicid+'&action='+action+'&parentid='+parentid+'&level='+level;

      // confirm("are you sure you want to delete?");


        if(subjectfield.value=='' &&  parentid=="0")
        {
          confirm("subject field is blank!!");
          return false;
        }


        if(messagefield.value=='')
        {
          confirm("message field is blank!!");
          return false;
        }

        if(usernamefield.value=='')
        {
          confirm("username field is blank!!");
          return false;
        }
       
        
      
	checkitxmlhttp = new myXMLHttpRequest ();      
	checkitxmlhttp.open ("GET", url, true); 
     
      


	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
			 {
				document.getElementById (spanid).innerHTML =  
				responsestring ;
				form.submit.disabled = '';
			}
		}
	}

       var replydisplay=document.getElementById(formid).style.display ? '' : 'none';
  	document.getElementById(formid).style.display = replydisplay;

  checkitxmlhttp.send (null);
  return false;
}


function logout()
{
  url ='/lib/zikkajs.php?action=logout';  
  checkitxmlhttp = new myXMLHttpRequest ();      
  checkitxmlhttp.open ("GET", url, true);
 
  
  linkref='http://newspuri.com/';
  window.location.href=linkref;

    checkitxmlhttp.send (null);  

}

function login(form, emailfield,passwordfield)
{
 

  url ='/lib/zikkajs.php?action=login'+ '&email=' + emailfield.value + '&password=' + passwordfield.value;  
  checkitxmlhttp = new myXMLHttpRequest ();      
  checkitxmlhttp.open ("GET", url, true);



document.getElementById('toplogin-d-wrongemail').style.display = 'none';
document.getElementById('toplogin-d-wrongpassword').style.display = 'none';

  checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
			 {


if(responsestring == '0')
{
				wrongemail ='email id is wrong or not registered';
document.getElementById('toplogin-d-wrongemail').style.display = '';
document.getElementById ('toplogin-d-wrongemail').innerHTML =  
				wrongemail;

} else if(responsestring == '-1')
{
wrongpassword ='password is not matching';
document.getElementById('toplogin-d-wrongpassword').style.display = '';
document.getElementById ('toplogin-d-wrongpassword').innerHTML =  
				wrongpassword;
}
else
{
document.getElementById('topregister').style.display = 'none';
document.getElementById('toplogin').style.display = 'none';
document.getElementById('toplogin-d').style.display = 'none';
document.getElementById('topregister-d').style.display = 'none';
document.getElementById('toplogin-d-wrongemail').style.display = 'none';
document.getElementById('toplogin-d-wrongpassword').style.display = 'none';
document.getElementById('top-welcome').style.display = '';

document.getElementById ('top-welcome').innerHTML =  
				responsestring ;
}




			}
		}
	}





 checkitxmlhttp.send (null);

  return false;
}







function register(form, emailfield,password1field,password2field,usernamefield)
{
 

  url ='/lib/zikkajs.php?action=register'+ '&email=' + emailfield.value + '&password1=' + password1field.value + '&password2=' + password2field.value + '&username=' + usernamefield.value;  
  checkitxmlhttp = new myXMLHttpRequest ();      
  checkitxmlhttp.open ("GET", url, true);



document.getElementById('topregister-d-wrongemail').style.display = 'none';
document.getElementById('topregister-d-wrongpassword').style.display = 'none';
document.getElementById('topregister-d-wrongusername').style.display = 'none';



checkitxmlhttp.onreadystatechange = function () 
{
	if (checkitxmlhttp.readyState == 4) 
       {
		       
        
          responsestring= checkitxmlhttp.responseText;
          var string=responsestring.toString()
          var no=string.search('*');


         if(no==-1)
         {
           document.getElementById('topregister').style.display = 'none';
           document.getElementById('toplogin').style.display = 'none';
           document.getElementById('toplogin-d').style.display = 'none';
           document.getElementById('topregister-d').style.display = 'none';
           document.getElementById('topregister-d-wrongemail').style.display = 'none';
           document.getElementById('topregister-d-wrongpassword').style.display = 'none';
           document.getElementById('topregister-d-wrongusername').style.display = 'none';
           document.getElementById('top-welcome').style.display = '';

           document.getElementById ('top-welcome').innerHTML = responsestring ;

        }
        else
        {

            if(responsestring == '0')
            {
		 wrongemail ='email id is not valid';
               document.getElementById('topregister-d-wrongemail').style.display = '';
               document.getElementById ('topregister-d-wrongemail').innerHTML = wrongemail;

            } else if(responsestring == '0.1')
            {
                 wrongemail ='email already exists';
                 document.getElementById('topregister-d-wrongemail').style.display = '';
                 document.getElementById ('topregister-d-wrongemail').innerHTML =  wrongemail;

            }else if(responsestring == '-1')
            {
                  wrongpassword ='password is less than 5 characters';
                  document.getElementById('topregister-d-wrongpassword').style.display = '';
                  document.getElementById ('topregister-d-wrongpassword').innerHTML = wrongpassword;
            }

            else if(responsestring == '-1.1')
            {
                   wrongpassword ='passwords do not match';
                   document.getElementById('topregister-d-wrongpassword').style.display = '';
                    document.getElementById ('topregister-d-wrongpassword').innerHTML = wrongpassword;
            }
            else if(responsestring == '-2')
            {
                    wrongusername ='username is less than 3 characters';
                    document.getElementById('topregister-d-wrongusername').style.display = '';
                    document.getElementById ('topregister-d-wrongusername').innerHTML =wrongusername;
            }
             //else if(responsestring == '-2.1')
            else
            {
                    wrongusername ='username contains invalid characters';
                    document.getElementById('topregister-d-wrongusername').style.display = '';
                    document.getElementById ('topregister-d-wrongusername').innerHTML =  	wrongusername;
             }

        }


   }
}



 checkitxmlhttp.send (null);

  return false;

}









