function isNull(val) { 
	return (val == null); 
}

function setIframeSrc(url) {alert(url);
	document.getElementsByName('testif')[0].src = url;
}
function GetXmlHttpObject() 
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	}else if (window.ActiveXObject){ 
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	} 
	return objXMLHttp
} 

function isUserNameAvailable(username,usertype,groupid) {
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	var url="checkUser.php?username="+username+"&usertype="+usertype+"&groupid="+groupid;
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) 
			document.getElementById("namemsg").innerHTML = xmlHttp.responseText; 
	}; 
	xmlHttp.send(null);
}

function createTags(groupId,tagName) {
	xmlHttp = GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	var url="createTags.php?groupid="+groupId+"&tagname="+tagName;
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) {
			document.getElementById("tagmsg").innerHTML = xmlHttp.responseText;
			document.getElementById("createTag").style.display="none";
			
		}
	}; 
	xmlHttp.send(null);
}

function followMember(userCount,memberName,followStatus) {
	xmlHttp = GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	}
	var userId1 = "userId"+userCount;
	var memberId1 = "memberId"+userCount;
	var groupId1 = "groupId"+userCount;
	var divId = "follow"+userCount;
	var msgId = "followmsg"+userCount;
	
	var userId = document.getElementById(userId1).value;
	var memberId = document.getElementById(memberId1).value;
	var groupId = document.getElementById(groupId1).value;
	
	var url="follow.php?userid="+userId+"&memberid="+memberId+"&membername="+memberName+"&groupid="+groupId+"&followstatus="+followStatus+"&usercount="+userCount;
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) {
			var temp = new Array();
			var followMessage = xmlHttp.responseText;
			temp = followMessage.split('@#');
			document.getElementById('followingCount').innerHTML = temp[0];
			document.getElementById(divId).innerHTML = temp[1];
			document.getElementById(msgId).innerHTML = temp[2];
			document.getElementById('following').innerHTML = temp[3];			
		}	
	}; 
	xmlHttp.send(null);
}

/*function postReply(userId, jwittValue, groupId) {

	
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url="reply.php?userId="+userId+"&jwittValue="+jwittValue+"&groupId="+groupId+"&tagId=0";
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) 
			document.getElementById("displayMicroblogs").innerHTML = xmlHttp.responseText; 
			Dialog.cancelCallback();
	}; 
	xmlHttp.send(null);
	
}*/

/*function deleteMicroblogs(id,groupId,userId) {
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url="deleteUpdate.php?id="+id+"&groupId="+groupId+"&userId="+userId;
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) 
			document.getElementById("displayMicroblogs").innerHTML = xmlHttp.responseText; 
			Dialog.cancelCallback();
	}; 
	xmlHttp.send(null);
}*/

function insertMicroblogs_old(userId, jwittValue, groupId, YoutubeURL, flickrURL, URL,divId) {
		
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url = "addMicroblog.php?userId="+userId+"&jwittValue="+jwittValue+"&groupId="+groupId+"&tagId=0"+"&rss="+rss;
	url += "&YoutubeURL="+YoutubeURL+"&flickrURL="+flickrURL+"&URL="+URL+"&divId="+divId;
	
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		//if (xmlHttp.readyState == 4) 
		    
			//document.getElementById("current_post").innerHTML = xmlHttp.responseText; 
			//Dialog.cancelCallback();
	}; 
	xmlHttp.send(null);
}




/**
 * integer id
 * integer groupId
 * integer userId
 * integer getuserId  //1-flokio account, 0-twitter account
 * integer favorite_type 1-favorite
*/
function favorite(id,groupId,userId,getuserId,favorite_type) {
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url = "favorite.php?id="+id+"&groupId="+groupId+"&userId="+userId+"&getuserId="+getuserId;
	url += "&favorite_type="+favorite_type;
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) 
			document.getElementById("displayMicroblogs").innerHTML = xmlHttp.responseText; 
			Dialog.cancelCallback();
	}; 
	xmlHttp.send(null);
}

function menuActivate(img,src) {
	document.getElementById(img).src = src;
}

function updateLength(id,display,maxLength,buttonId,followId) {
    var str = document.getElementById(id).value;
    var button = document.getElementById(buttonId);
    var members = document.getElementById(followId);
    
    if(!isNull(members)) members = members.value;
    document.getElementById(display).innerHTML = maxLength - (str.length);
    
    if(!isNull(button)) {
    	
	    if(str.length > maxLength || str.length == 0 || members == 0)
	       button.disabled = true;
	    else 
	       button.disabled = false;
    }
}
      
/*function listOver(listId, state, count) {
	var favoriteImg = "";
	var replyDeleteId = "";
	var favoriteTitle = "";
	document.getElementById(listId).style.background = "#D2DADA";
	if(state) {
		for(i = 1; i <= count; i++) {
			favoriteImg = "favoriteImgId" + i;
			replyDeleteId = "replyDeleteId" + i;
			favoriteTitle = document.getElementById(favoriteImg).title;
			if(favoriteTitle == "favorite this update") 
				document.getElementById(favoriteImg).style.display = "none";
			else
				document.getElementById(favoriteImg).style.display = "block";
				
			document.getElementById(replyDeleteId).style.display = "none";
		}
		favoriteImg = "favoriteImgId" + listId;
		replyDeleteId = "replyDeleteId" + listId;
		favoriteTitle = document.getElementById(favoriteImg).title;
		document.getElementById(favoriteImg).style.display = "block";
		document.getElementById(replyDeleteId).style.display = "block";
	}
}
      
function listOut(listId, state, count) {
	var favoriteImg = "";
	var	replyDeleteId = "";
	var	favoriteTitle = "";
	document.getElementById(listId).style.background = "white";
	if(state) {
		for(i = 1; i <= count; i++) {
			favoriteImg = "favoriteImgId" + i;
			replyDeleteId = "replyDeleteId" + i;
			favoriteTitle = document.getElementById(favoriteImg).title;
			if(favoriteTitle == "favorite this update") 
				document.getElementById(favoriteImg).style.display = "none";
			else
				document.getElementById(favoriteImg).style.display = "block";
					
			document.getElementById(replyDeleteId).style.display = "none";
		}
	}
}*/

function focustext(id) {
	var elementId = document.getElementById(id)
	if(!isNull(elementId)) document.getElementById(id).focus();
	
}

function display_container(id,menu) {
	
	document.getElementById('data_menu').style.backgroundColor="";
	document.getElementById('rss_menu').style.backgroundColor="";
	document.getElementById('color_menu').style.backgroundColor="";
	document.getElementById('image_menu').style.backgroundColor="";
	document.getElementById('data_menu').style.color="#6A6A6A";
	document.getElementById('rss_menu').style.color="#6A6A6A";
	document.getElementById('color_menu').style.color="#6A6A6A";
	document.getElementById('image_menu').style.color="#6A6A6A";
	document.getElementById('data_div').style.display="none";
	document.getElementById('rss_div').style.display="none";
	document.getElementById('color_div').style.display="none";
	document.getElementById('background_image_div').style.display="none";
	if(document.getElementById('approval_menu')) {
		document.getElementById('approval_menu').style.backgroundColor="";
	    document.getElementById('approval_menu').style.color="#6A6A6A";
	    document.getElementById('approval_div').style.display="none";
	}
	document.getElementById(id).style.display="block";
	document.getElementById(menu).style.backgroundColor="#E4E5EA";
	document.getElementById(menu).style.color="#6A6A6A";
}

function parent_container() {
	var color1 = document.getElementById('color1');  //Background Color
	var color2 = document.getElementById('color2');  //Side Bar
	var color4 = document.getElementById('color4');  //Side Bar Text Color
	
	var body = document.getElementById('body');
	var welcome_user = document.getElementById('welcome_user');
	var members = document.getElementById('members');
	var selected = document.getElementById('selected');
	var follow_list = document.getElementById('follow_list');
	var followers = document.getElementById('followers');
	var inner_right = document.getElementById('inner_right');
	var direct_message = document.getElementById('direct_message');
	var favorite_message = document.getElementById('favorite_message');
	var dm = document.getElementById('dm');
	var fm = document.getElementById('fm');
	var mem = document.getElementById('mem');
	var fol = document.getElementById('fol');
	var fol_m = document.getElementById('fol_m');
	var custom_feed_div = document.getElementById('custom_feed_div');
	var custom_feed_link = document.getElementById('custom_feed_link');
	var following_div = document.getElementById('following_div');
	
	if( (!isNull(color1)) && (!isNull(color2)) && (!isNull(color4)) && (!isNull(body)) && (!isNull(welcome_user)) && (!isNull(members)) && (!isNull(selected)) && (!isNull(follow_list)) && (!isNull(followers)) && (!isNull(inner_right)) && (!isNull(direct_message)) && (!isNull(favorite_message)) && (!isNull(dm)) && (!isNull(fm)) && (!isNull(mem)) && (!isNull(fol)) && (!isNull(fol_m)) && (!isNull(custom_feed_div)) && (!isNull(custom_feed_link)) && (!isNull(following_div)) ) {
	
		body.style.backgroundColor = color1.value; 
		welcome_user.style.backgroundColor = color2.value;
		members.style.backgroundColor = color2.value;
		selected.style.backgroundColor = color2.value;
		follow_list.style.backgroundColor = color2.value;
		followers.style.backgroundColor = color2.value;
		direct_message.style.backgroundColor = color2.value;
		favorite_message.style.backgroundColor = color2.value;
		custom_feed_div.style.backgroundColor = color2.value;
		following_div.style.backgroundColor = color2.value;
		inner_right.style.color = color4.value;
		dm.style.color = color4.value;
		fm.style.color = color4.value;
		mem.style.color = color4.value;
		fol.style.color = color4.value;
		fol_m.style.color = color4.value;
	    custom_feed_link.style.color = color4.value;
	}
	
}

function theme_settings(image) {
	document.getElementById('body').style.backgroundImage = image;	
	document.getElementById('themeImg').value = image;	
}

function checkTags() {
	if(document.getElementById("editposttotags").checked) 
		document.getElementById("tags").style.display="block";
	else 
		document.getElementById("tags").style.display="none";
}

function replyDialog(id) {
	Dialog.confirm($(id).innerHTML, {className:"alphacube", width:480, height:200,
	okLabel: "Save", cancelLabel: "Cancel"	})
	
}

/*function deleteUpdate(id,groupId,userId) {
	msg = "do you want to delete this update?";
	if(confirm(msg)) {
		deleteMicroblogs(id,groupId,userId);	
	}
}*/

function viewTagMore() {
	document.getElementById("tagLess").style.display="none";
	document.getElementById("tagMore").style.display="block";
}
function viewTagLess() {
	document.getElementById("tagLess").style.display="block";
	document.getElementById("tagMore").style.display="none";
}

function showTagButton() {
	document.getElementById("createTag").style.display="block";
	document.getElementById("tagmsg").innerHTML ="";
}

/*function URL_Collection() {
	
	var YoutubeURL_text = "Add your youtube URL";
	var FlickrURL_text = "Add your Flickr URL";
	var URL_text = "Add bookmark URL"; 
	
	var YoutubeURL = document.getElementById('YoutubeURL_Input').value;
	var FlickrURL = document.getElementById('FlickrURL_Input').value;
	var URL = document.getElementById('URL_Input').value;
	var Grouptag = document.getElementById('Grouptag_Input').value;
	
	
	
	document.getElementById('YoutubeURL').value = YoutubeURL;
	document.getElementById('FlickrURL').value = FlickrURL;
	document.getElementById('URL').value = URL;
	document.getElementById('Grouptag').value = Grouptag;
	
	var YoutubeURL_Selected = ((YoutubeURL != YoutubeURL_text) && (YoutubeURL != "")) ? "block" : "none" ;
	var FlickrURL_Selected = ((FlickrURL != FlickrURL_text) && (FlickrURL != "")) ? "block" : "none" ;
	var URL_Selected = ((URL != URL_text) && (URL != "")) ? "block" : "none" ;
	var Grouptag_Selected = (Grouptag) ? "block" : "none" ;
	
	document.getElementById('youtube_icon').style.display = YoutubeURL_Selected;
	document.getElementById('flickr_icon').style.display = FlickrURL_Selected;
	document.getElementById('url_icon').style.display = URL_Selected;
	document.getElementById('tag_icon').style.display = Grouptag_Selected;
	
	
	Effect.toggle('feature_div','appear'); 
	return false;
}*/

function feature_click() {
	var add_feature1 = "" ;
	var add_feature = document.getElementById('add_feature').innerHTML; 
	
	document.getElementById('YoutubeURL_Input').value = "Add your youtube URL";
	document.getElementById('FlickrURL_Input').value = "Add your Flickr URL";
	document.getElementById('URL_Input').value = "Add bookmark URL";
	
	document.getElementById('YoutubeURL_Input').style.color = "grey";
	document.getElementById('FlickrURL_Input').style.color = "grey";
	document.getElementById('URL_Input').style.color = "grey";
	
	add_feature1 = (add_feature == "+") ? "-" : "+";
	/*
	if(add_feature == "+")
		add_feature1 = "-";
	else
		add_feature1 = "+";*/
		
	
	document.getElementById('add_feature').innerHTML = add_feature1;
	Effect.toggle('feature_div','slide'); 
	return false;
}

function text_static_cnt(id,actTxt) {
	var id_text = document.getElementById(id).value;
	if(id_text == actTxt) {
		document.getElementById(id).value = "";
		document.getElementById(id).style.color = "black";
	}
}

var i = 0;
//userId, groupId
function new_updates123() {
	var i; i++;
	var divId = "current_post" + i;
	var container = document.getElementById('container').innerHTML;
	var jwittValue = document.getElementById('jwitt').value;
	
	/*
	var personImg = document.getElementById('PersonImg').value;
	
	var YoutubeURL = document.getElementById('YoutubeURL').value;
	var flickrURL = document.getElementById('FlickrURL').value;
	var URL = document.getElementById('URL').value;*/
	
	document.getElementById('container').innerHTML = document.getElementById('current_post').innerHTML + container;
	
 	/*	
	var currentPost = "<div id='" + divId +"' style='display:none;width:100%;background:white;margin-top:25px;border-bottom:1px solid black;height:83px'>";
	currentPost += "<div style='float:left;width:10%;margin-top:10px;margin-left:5px;height:70px'><img src='" + personImg + "'></div>";
	currentPost += "<div style='float:left;width:78%;5px;height:70px;font-family:arial;font-size:12px;margin:10px;'>";
	currentPost += "<label style='color:green;font-weight:bold;'>vkshihab</label>&nbsp;&nbsp;" + jwittValue + "</div>";
	currentPost += "<div style='float:left;width:5%;height:70px'>";
	currentPost += "<div style='float:left;width:100%;margin-top:2px;'></div>";
	currentPost += "<div style='float:left;width:100%;margin-top:2px;'></div>";
	currentPost += "</div></div>";*/
	
	/*
	var currentPost = "<div class="timeline_posts">
       <div class="user_image">
       <img src="images2/1.jpg" />
       </div>
       <div class="user_posts">
       <a href="#">Rajkumar :</a>
       This is a test content.This is a test content.This is a test content.This is a test content.This is a test content.This is a test content.
       </div>
       <div class="options">
       <img src="images2/favorite.gif">
       <img src="images2/reply.gif">
       <img src="images2/utube.gif">
       </div>
       </div>"; */
       
    var currentPost =  "<div id='" + divId +"' class='timeline_posts' style='display:none;'>";
    currentPost += "<div class='user_image'>";
    currentPost += "<img src='images2/1.jpg'>";
    currentPost += "</div>";
    
    currentPost += "<div class='user_posts'>";
    currentPost += "<a href='#'>Rajkumar :</a>" + jwittValue;
    currentPost += "</div>";
	
	currentPost += "<div class='options'>";
    currentPost += "<img src='images2/favorite.gif'>";
    currentPost += "<img src='images2/reply.gif'>";
    currentPost += "<img src='images2/utube.gif'>";
    currentPost += "</div></div>";
	
	
	document.getElementById('current_post').innerHTML = currentPost;
	Effect.toggle(divId,'slide'); 
	
	//insertMicroblogs(userId, jwittValue, groupId, YoutubeURL, flickrURL, URL, divId);
	
	return false;
}

function feedback() {
	var feedspan = document.getElementById('feedback_span');
	var pos = document.getElementById('feedback_form').style.left;
	if(!isNull(feedspan)) feedspan.innerHTML = "";
	if(pos == "-289px") {
		document.getElementById('feedback_handle').src = "./images2/feedback.png";
        document.getElementById('feedback_form').style.left = "0px";
	}
	//stat = 'close';
	if(pos == "0px") {
		document.getElementById('feedback_form').style.left = "-289px";
	    document.getElementById('feedback_handle').src = "./images2/feedback_hover.png";
	}
}

function change_src(id,src,nullsrc) {
	if(!src) {
		src = nullsrc;
	}
    document.getElementById(id).src = src;	
}

function login_type(type) {
	
	/*var color_default = '#E0FFFF';
	var color_selected = '#CFECEC';*/
	
	var Twitter = document.getElementById('Twitter');
	var Flokio = document.getElementById('Flokio');
	var OpenID = document.getElementById('OpenID');
	var Facebook = document.getElementById('Facebook');
	
	var TwitterLogin = document.getElementById('TwitterLogin');
	var FlokioLogin = document.getElementById('FlokioLogin');
	var OpenIDLogin = document.getElementById('OpenIDLogin');
	var FacebookLogin = document.getElementById('FacebookLogin');
	
	/*Twitter.style.background = color_default;
	Flokio.style.background = color_default;
	OpenID.style.background = color_default;
	Facebook.style.background = color_default;*/
	
	TwitterLogin.style.display = 'none';
	FlokioLogin.style.display = 'none';
	OpenIDLogin.style.display = 'none';
	FacebookLogin.style.display = 'none';
	
	if(type == "Twitter") {
		//Twitter.style.background = color_selected;
		TwitterLogin.style.display = 'block';
	}
	else if(type == "Flokio") {
		//Flokio.style.background = color_selected;
		FlokioLogin.style.display = 'block';
	}
	else if(type == "OpenID") {
		//OpenID.style.background = color_selected;
		OpenIDLogin.style.display = 'block';
	}
	else if(type == "Facebook") {
		//Facebook.style.background = color_selected;
		FacebookLogin.style.display = 'block';
	}
}

function updateTwitter(tUsername,tPassword,feedUrl) {
	alert(tUsername);
	if(tUsername == 0) openDialogBox('loginDiv',325,235);
	 
	var i; i++;
	var divId = "current_post" + i;
	var container = document.getElementById('container').innerHTML;
	var jwittValue = document.getElementById('jwitt').value;
	
	/*
	var personImg = document.getElementById('PersonImg').value;
	
	var YoutubeURL = document.getElementById('YoutubeURL').value;
	var flickrURL = document.getElementById('FlickrURL').value;
	var URL = document.getElementById('URL').value;*/
	
	/*document.getElementById('container').innerHTML = document.getElementById('current_post').innerHTML + container;*/
	
 	/*	
	var currentPost = "<div id='" + divId +"' style='display:none;width:100%;background:white;margin-top:25px;border-bottom:1px solid black;height:83px'>";
	currentPost += "<div style='float:left;width:10%;margin-top:10px;margin-left:5px;height:70px'><img src='" + personImg + "'></div>";
	currentPost += "<div style='float:left;width:78%;5px;height:70px;font-family:arial;font-size:12px;margin:10px;'>";
	currentPost += "<label style='color:green;font-weight:bold;'>vkshihab</label>&nbsp;&nbsp;" + jwittValue + "</div>";
	currentPost += "<div style='float:left;width:5%;height:70px'>";
	currentPost += "<div style='float:left;width:100%;margin-top:2px;'></div>";
	currentPost += "<div style='float:left;width:100%;margin-top:2px;'></div>";
	currentPost += "</div></div>";
	
	/*
	var currentPost = "<div class="timeline_posts">
       <div class="user_image">
       <img src="images2/1.jpg" />
       </div>
       <div class="user_posts">
       <a href="#">Rajkumar :</a>
       This is a test content.This is a test content.This is a test content.This is a test content.This is a test content.This is a test content.
       </div>
       <div class="options">
       <img src="images2/favorite.gif">
       <img src="images2/reply.gif">
       <img src="images2/utube.gif">
       </div>
       </div>"; */
       
    /*var currentPost =  "<div id='" + divId +"' class='timeline_posts' style='display:none;'>";
    currentPost += "<div class='user_image'>";
    currentPost += "<img src='images2/1.jpg'>";
    currentPost += "</div>";
    
    currentPost += "<div class='user_posts'>";
    currentPost += "<a href='#'>Rajkumar :</a>" + jwittValue;
    currentPost += "</div>";
	
	currentPost += "<div class='options'>";
    currentPost += "<img src='images2/favorite.gif'>";
    currentPost += "<img src='images2/reply.gif'>";
    currentPost += "<img src='images2/utube.gif'>";
    currentPost += "</div></div>";
	
	
	document.getElementById('current_post').innerHTML = currentPost;
	Effect.toggle(divId,'slide'); */
	
	insertTwitts(tUsername,tPassword,jwittValue,feedUrl);
	
	return false;
}

function insertTwitts(tUsername,tPassword, jwittValue,feedUrl) {
	
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url = "addTwitts.php?tUsername="+tUsername+"&tPassword="+tPassword+"&message="+jwittValue+"&feedurl="+feedUrl;
		
	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) 
		    alert(xmlHttp.responseText);
			//document.getElementById("current_post").innerHTML = xmlHttp.responseText; 
			//Dialog.cancelCallback();
	}; 
	xmlHttp.send(null);
}

function openDialogBox(id, width, height) {
	Dialog.confirm($(id).innerHTML, {
	className:"alphacube", width:width, height:height,
	okLabel: "Save", cancelLabel: "Cancel"})	
}

function FlokioLogin(user, pass, page, responseContainer) {
    document.getElementById(responseContainer).innerHTML = "<img src=\"./images/progress.gif\">";
    var userId = document.getElementById(user).value;
    var password = document.getElementById(pass).value;
    
    var params = "userId="+userId+"&password="+password;
	
	if(userId) {
	
		xmlHttp=GetXmlHttpObject() 
		if (xmlHttp == null)
		{ 
			alert ("Browser does not support HTTP Request")
			return 
		} 
		
		var url = page;
		var msg = "";
		if(page == 'FlokioLogin.php')
			msg = "Invalid Flokio account, Please try again...";
		else	
			msg = "Invalid Twitter account, Please try again...";
		
		xmlHttp.open("POST",url,true)
		
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		
		
		xmlHttp.onreadystatechange = function () { 
			if (xmlHttp.readyState == 4) {
				var response = xmlHttp.responseText;
				if (response.length > 1)
				  	window.location.href = "index.php";
				else
					document.getElementById(responseContainer).innerHTML = msg;
			}
		}; 
		xmlHttp.send(params);
	}
}

function twitterLogin(user, pass, page, responseContainer) {
    document.getElementById(responseContainer).innerHTML = "<img src=\"./images/progress.gif\">";
    var userId = document.getElementById(user).value;
    var password = document.getElementById(pass).value;
    
    var params = "userId="+userId+"&password="+password;
	
	if(userId) {
	
		xmlHttp=GetXmlHttpObject() 
		if (xmlHttp == null)
		{ 
			alert ("Browser does not support HTTP Request")
			return 
		} 
		
		var url = page;
		var msg = "";
		
		msg = "Invalid Twitter account, Please try again...";
		
		xmlHttp.open("POST",url,true)
		
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		
		
		xmlHttp.onreadystatechange = function () { 
			if (xmlHttp.readyState == 4) {
				var response = xmlHttp.responseText;
				
				if (response.length > 1)
				  	window.location.href = "twittHome.php";
				else
					document.getElementById(responseContainer).innerHTML = msg;
			}
		}; 
		xmlHttp.send(params);
	}
}

function OpenId_Login() {
	
	var id = document.getElementById('openid_identifier').value;
	document.getElementById('invalid3').innerHTML = "<img src=\"./images/progress.gif\">";
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp == null)
	{ 
		alert ("Browser does not support HTTP Request")
		return 
	} 
	
	var url = 'openid/examples/consumer/try_auth.php?openid_identifier='+id;
	var msg = "";

	xmlHttp.open("GET",url,true)
	xmlHttp.onreadystatechange = function () { 
		if (xmlHttp.readyState == 4) {
			document.getElementById('get_error').innerHTML = xmlHttp.responseText;
			var get_error = document.getElementById('openid_error');
			if(!isNull(get_error)) 
				document.getElementById('invalid3').innerHTML = get_error.innerHTML;
			else 
				window.location.href =	url; 
		}
	}; 
	xmlHttp.send(null);
	
}

