// Javascript


//watch videos page functions start here
	function logoutoneindia(){
		
		var loginfrom = document.getElementById("loginfrom").value;
		var filePath = document.getElementById("filePath").value;
		var strmessage = "To logout from "+loginfrom+", You should logout separately from "+loginfrom+".";
		alert(strmessage);
		var url = window.location.href;
		window.location = filePath+"/scripts/comments/comments_logout.php?ref="+url;
	}
	function showLoginOptions(id){
		var x = document.getElementById(id);
		if(x.style.display == 'none'){
			x.style.display = 'block';
		}
		else
			x.style.display = 'none';
	}
	function hideall(){
		document.getElementById('lightboxLink').style.visibility='hidden';
		document.getElementById("bg_fade").style.visibility='visible';
		document.getElementById("bg_fade").style.opacity=0.9;
		document.getElementById('containerDiv').style.display='block';
		document.getElementById('lightboxOn').style.display='none';
	}
	function showall(){
		document.getElementById('lightboxLink').style.visibility='visible';
		document.getElementById("bg_fade").style.visibility='hidden';
		document.getElementById('containerDiv').style.display='none';
		document.getElementById('lightboxOn').style.display='block';
	}

	function getDocHeight() {
		var D = document;
		return Math.max(
			Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
			Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
			Math.max(D.body.clientHeight, D.documentElement.clientHeight)
		);
	}

	function mail2Friend(){
		var f = document.getElementById('mail2frame');
		f.src = "http://thatshindi.oneindia.in/scripts/mail-print/mail2friend.php";
		var ht = getDocHeight()+ 1200;
		document.getElementById('fade').style.height=ht+'px';
		document.getElementById('fade').style.display  = 'block';
		document.getElementById('fixme').style.display = 'block';		
		eventTracker('right-include-email','link', "'"+document.location.href+"'");
	}

	function closeMail2Friend(){
		document.getElementById('fade').style.display  = 'none';
		document.getElementById('fixme').style.display = 'none';
		window.frames['mail2frame'].document.getElementById("uremail").value='';
		window.frames['mail2frame'].document.getElementById("ursfriendsemail").value='';
		window.frames['mail2frame'].document.getElementById("comments").value='';
		window.frames['mail2frame'].document.getElementById("security_code").value='';
		window.frames['mail2frame'].document.getElementById("err_block").innerHTML='';
	}
	
	


			
			
			function addVideo()
			{
				if (document.playlist.pid.value == 0)
				{ 
				  alert('Please select the playlist');
				  return false;
				}
				else
				{
				  document.playlist.action = "/playlist.php?action=savevideo";
				  document.playlist.submit();
				}
			}
//watch_video page functions ends here

// validate search input field
function chkSearch()
{
var txtVal=document.vsearch.key.value;
  var keylength = txtVal.length;
	if (txtVal =="")
	{
		alert('Please enter the keyword !!!');
		return false;
	}
	else if(keylength < 3){
	    
	    alert("Keyword length should be 3 characters");
	    document.vsearch.key.focus();
	    return false;
	}
	else if(keylength > 25){
	    
	    alert("Keyword maximum length should be 25 characters");
	    document.vsearch.key.focus();
	    return false;
	}
	else
	{
		var iChars = "~!#`@$%^&*()=:;'/\_+}?|\{]\/[-><,`";
		
        for (var i = 0; i < txtVal.length; i++) {
                        //starting
									if (iChars.indexOf(txtVal.charAt(i)) != -1) {
                               				alert('Keyword should not contain special characters.');
		                                    return false;
                                   }
				                }
			
		return true;
	}
}
 

 
 function FreezeScreen() {
      var outerPane = document.getElementById('FreezePane');
      if (outerPane) outerPane.className = 'FreezePaneOn';
   }
    function freescreen() {
      var outerPane = document.getElementById('FreezePane');
      if (outerPane) outerPane.className = 'FreezePaneOff';
   }

function showhide(id){
document.getElementById('loginmsg').innerHTML = "";
document.getElementById('regmsg').innerHTML = "";
document.getElementById('username').value = "";
document.getElementById('lpassword').value = "";

  flag = document.getElementById(id);
  if(flag.style.display =="none"){
	flag.style.display ="block";
		FreezeScreen();
  }else{
	flag.style.display ="none";
		freescreen();
 }
} 

function showhide1(id){
  flag = document.getElementById(id);
  if(flag.style.display =="none"){
	flag.style.display ="block";
  }else{
	flag.style.display ="none";
 }
} 



function vlogin(){
   document.getElementById('loginmsg').innerHTML = "<img src='/images/login-loader.gif' alt='Loading Login'/><font class='success'>Submitting..</font>";
	username = document.getElementById('username').value;
	password = document.getElementById('lpassword').value;
	//alert(username+'-'+password);
    agent.call('/ajax.php','ajaxauthenticate','logincallback',username,password);
}






function checkVideoFiles(ext) {
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext != 'flv') {
    alert('Please select valid FLV file');
    return false; 
	}
  else
    return true; 
 }

function checkImageFiles(ext) {
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext != 'jpg' && ext != 'gif' || ext != 'png') {
    alert('Please select valid Image file');
    return false; 
	}
  else
    return true; 
 }

function call_vote(id,val){
  agent.call('/ajax.php','vote','votecallback',id ,val);
}

function recent(page){
	document.getElementById('beforeajax').innerHTML = "";
	document.getElementById('recentfiles').innerHTML = "";
	document.getElementById('loadingmsg').innerHTML = "<img src='/images/ajax-loader.gif' alt='Loading Videos'/>";
  agent.call('/ajax.php','ajaxrecentVideos','recentcallback',page);
}

function recenthome(page){
	document.getElementById('beforeajax').innerHTML = "";
	agent.call('/ajax.php','ajaxrecentVideos','recentcallback',page);
}






var temp1;
function category_display(id){
catshowhide(id);
temp1=id;
agent.call('ajax.php','showmaintree','showmaintreecallback',id);
}
// For Category Main Page
function showmaintreecallback(str) {
document.getElementById(temp1).innerHTML = str;
if (str=="")
{
document.getElementById(temp1).innerHTML =  "<font class='error'>Sorry! No Record found.</font>";
}
temp1="";

}
//comments javascript functions start here
  
        var appId = "211979638827811";
        function fbLogin(){
                url = "https://www.facebook.com/dialog/oauth?client_id=" + appId  + "&redirect_uri=http://videos.oneindia.in/src/web/scripts/comments/facebook/response.php&display=popup&response_type=code&fbconnect=1&from_login=1&rcount=1&scope=";
                window.open(url,'Facebook','width=500,height=270');
        }
        
	function twitterLogin(){
                url = "http://videos.oneindia.in/src/web/scripts/comments/twitter/index.php";
                window.open(url,'Twitter','width=500,height=370');
	}
        
        function gmailLogin(){
                url = "http://videos.oneindia.in/src/web/scripts/comments/open/gmail.php";
                window.open(url,'Twitter','width=500,height=450');
	}
        
        function yahooLogin(){
                url = "http://videos.oneindia.in/src/web/scripts/comments/open/yahoo.php";
                window.open(url,'Twitter','width=500,height=450');
	}
      
	  function showLoginOptions(id){
		var x = document.getElementById(id);
		if(x.style.display == 'none'){
			x.style.display = 'block';
		}
		else
			x.style.display = 'none';
	}
	  
	   
var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

d = document;
n = navigator;
na = n.appVersion;
nua = n.userAgent;
win = ( na.indexOf( 'Win' ) != -1 );
mac = ( na.indexOf( 'Mac' ) != -1 );
lin = ( nua.indexOf( 'Linux' ) != -1 );

if ( !d.layers )
{
	dom = ( d.getElementById );
	op = ( nua.indexOf( 'Opera' ) != -1 );
	konq = ( nua.indexOf( 'Konqueror' ) != -1 );
	saf = ( nua.indexOf( 'Safari' ) != -1 );
	moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
	ie = ( d.all && !op );
	ie4 = ( ie && !dom );

	/*
	ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
	Opera will register true in this test if set to identify as IE 5
	*/

	ie5x = ( d.all && dom );
	ie5mac = ( mac && ie5x );
	ie5xwin = ( win && ie5x );
}
function newPopup(url)
{
	var form = document.createElement("form");
	form.method = "GET";
	form.action = url;
	form.target = "_blank";
	document.body.appendChild(form);
	form.submit();
	window.focus();
}

function iePopup()
{
	//alert("inside");
	if (document.getElementById('read-all-link') && (document.getElementById('read-all-link').href != ''))
	{
		document.getElementById('read-all-link').click();
		window.focus();
	}
	else
	{
		setTimeout("iePoupup()", 100);
	}	
	
}
 function getHTTPObject() {
		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");
			}
		}
		return xmlHttp;
	}
	function chkSpecialChar(val)
{
	var iChars = "`~_!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	
	for (var i = 0; i < val.length; i++)
	{
		if (iChars.indexOf(val.charAt(i)) != -1)
		{
			return false;
		}
	}
	return true;
}
function IsNumeric(val)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;	
	for (i = 0; i < val.length && IsNumber == true; i++) 
	{
		Char = val.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);// otherwise, update 'characters left' counter
	else 
		countfield.innerHTML = maxlimit - field.value.length;
}

function createCookie(name,value,seconds)
{
    var date = new Date();
    date.setTime(date.getTime()+(seconds*1000));
    var expires = "; expires="+date.toGMTString();
    document.cookie = name+"="+value+expires+"; path=/";
}
function Ltrim(val)
{
	return val.replace(/^\s+/,"");
}

function Rtrim(val)
{
	return val.replace(/\s+$/,"");
}

function trim(val)
{
	return Ltrim(Rtrim(val));
}
var current_comment_box = '';
 function showCommentsFormNew1(path, aid,comments_file_name, parent_id, theDiv, level_id, pid, wid, article_id,page_type,ip,month_dir,year_dir)
{
	var cmnwebsite = window.location.hostname;
	var type =  document.getElementById("comment_page_type").value;
	if(type == 'readall'){ var value = 'alltemp'; } else { var value = 'temp'; }
	
	var cmntitle = getmetaContents('title');
    var pageURL = "/src/web/scripts/comments/display_write_comment_box_temp.php?type="+value+"&path="+cmnwebsite+path+"&comments_file_name="+comments_file_name+"&aid="+aid+"&ip="+ip+"&month_dir="+month_dir+"&year_dir="+year_dir+"&parent_id="+parent_id+"&theDiv="+theDiv+"&level_id="+level_id+"&pid="+pid+"&wid="+wid+"&cmnwebsite="+cmnwebsite+"&cmntitle="+cmntitle+"&art_id="+article_id+"&page_type="+page_type;
	
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					theFormTxt = req.responseText;
					//alert(theFormTxt);
					//alert(current_comment_box);
					if (current_comment_box != '' && document.getElementById(current_comment_box))
					{
						document.getElementById(current_comment_box).innerHTML = '';
						document.getElementById(current_comment_box).style.display = 'none';
					}
					if (current_comment_box != '')
					{
						//alert(document.getElementById(current_comment_box).innerHTML);
					}
					document.getElementById(theDiv).style.display = 'block';
					document.getElementById(theDiv).innerHTML = theFormTxt;
					current_comment_box = theDiv;
					//alert(current_comment_box);
					//window.setTimeout("onLoad()", 600);
					setTimeout("onLoad()", 100);
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
	);
	document.getElementById('newCommentFormDiv').style.display = 'none';
	return false;
}
       function getallcomments(year,month,page,article_id,comments_file_name,month_dir,year_dir) {
				    request = getHTTPObject();
					request.onreadystatechange = function () {
						if(request.readyState == 4) {
							theFormTxt = request.responseText;
												
					document.getElementById("actual-comments-div").innerHTML = theFormTxt;
                               
						}
					}
					
					var pageURL = "/src/web/scripts/comments/showallcommentsnew.php?comments_file_name="+comments_file_name+"&month_dir="+month_dir+"&year_dir="+year_dir+"&aid="+article_id+"&month="+month+"&year="+year+"&page="+page;
					request.open("GET", "/src/web/scripts/comments/showallcommentsnew.php?comments_file_name="+comments_file_name+"&month_dir="+month_dir+"&year_dir="+year_dir+"&aid="+article_id+"&month="+month+"&year="+year+"&page="+page, true);
					request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					request.setRequestHeader("Expires", "Wed, 31 Dec 1980 00:00:00 GMT");
					request.send(null);
					return false;
             }            
 function addComments(){
      theForm = document.forms['frm'];
	
    var iChars = "~!#`@$%^&*()=:;'/\_+}?|\{][-><,`"; 
	var err='', response;
	var author = trim(theForm.cmnAuthor.value);
	if(theForm.cmnemail){
	var cmnemail = trim(theForm.cmnemail.value); }
	if(theForm.scode){
	var scode = trim(theForm.scode.value); }
	var comment = trim(theForm.cmnComment.value);
	var page_type = theForm.page_type.value;
	var month = theForm.month.value;
	var year = theForm.year.value;
	var article_id = theForm.article_id.value;
	var domain = theForm.website.value;
	
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(comment == ""){
		err ='Comment cannot be blank.';
		theForm.cmnComment.focus();
		alert(err);
		return false;
	}
	else if(comment!="") {
                cerr = '';
                for (var i = 0; i < comment.length; i++) {
                        //starting
						if(i==0){
								if (iChars.indexOf(comment.charAt(i)) != -1) {
                                cerr = "Your comment should not start with special characters.";
								
                                  }
						
						}
						
						//ending
                }
                if(cerr){
		alert(cerr);
		theForm.cmnComment.focus();
		return false;
	}
        }
	if(author == ""){
		err ='Please enter your name.';
		alert(err);
		theForm.cmnAuthor.focus();
		return false;
		
	} else if(!chkSpecialChar(author)){
		err ='Name should not have special characters.';
		alert(err);
		theForm.cmnAuthor.focus();
		return false;
	}
	if(cmnemail == ""){
		err ='Please enter your Emailid.';
		alert(err);
		theForm.cmnemail.focus();
		return false;
		
	}else if(reg.test(cmnemail) == false) {
		if(theForm.cmnemail){
       alert('Invalid Email Address');
       theForm.cmnemail.focus();
      return false; }
   }

	if(theForm.scode){
	if(scode == ""){
		err ='Please answer the simple math question.';
		alert(err);
		theForm.scode.focus();
		return false;
		
	} 	
	}
	
	
	
		
		
	var theDiv = 'DisplayAllComments';
	var path = document.getElementById("path").value;
	var aid = theForm.aid.value;
	var pid = theForm.pid.value;
	var container_id = theForm.container_id.value;
	var newpath = path.replace(/\//g, "_");
        document.getElementById("postcommentdisable").innerHTML = '<img src="/images/ajax-loader.gif" alt="Processing..."/>';	    
      var status = AjaxRequest.submit(
		theForm
		,{
			'onSuccess':function(req)
			{
				
			  var response = trim(req.responseText);
			  
			    		var patt1=/mysql_connect/g;
					var dberror = response.search(patt1);
				if(response == 'captcha_error')
			  {
			  	    	showCommentAlert_comments('Please fill in the correct answer for security question.');
					getCaptchaJSON();
					document.getElementById("postcommentdisable").innerHTML = '<input type="image" name="submit" value="Add this Comment" src="/images/postCommentsBtn.gif"><input type="hidden" name="submit" id="submit" value="Add this Comment">';
					  document.frm.captcha.focus();
					
			  }  else if(response == 'ip_blocked') {
					 showCommentAlert_comments("You have been blocked");
					  closeDiv(container_id);
				     createCookie('oneIndia-comments', '1', 300);
					 document.getElementById('newCommentFormDiv').innerHTML = " ";
					 return false;
					 }  else if(response == 'databaseerror') {
					 alert("Server is busy Please try after some time");
					  
					 } else if(response == 'abusewords') {
					 showCommentAlert_comments('Your comment has been added.\nIt will appear in few minutes.');
				     closeDiv(container_id);
				     createCookie('oneIndia-comments', '1', 300);
					 document.getElementById('newCommentFormDiv').innerHTML = " ";
					return false;
					 }
					 else if(response == 'guest') {
					 showCommentAlert_comments('Your comment is under moderation.\nIt will appear in few minutes.');
				     	 closeDiv(container_id);
					 if(document.getElementById('author').value == ''){
					setTimeout("location.reload(true);",0); }
					document.getElementById('newCommentFormDiv').innerHTML = " ";
					 }
					 
					 else if(response == '') {
					 showCommentAlert_comments("Server is busy Please try after some time");
					  document.getElementById('newCommentFormDiv').innerHTML = " ";
					return false;
					 } else if(response == 'Login') {
					 showCommentAlert_comments("Login to post comments");
					 closeDiv(container_id);
					 setTimeout("location.reload(true);",0);
					 return false;
					 } else if(dberror > 0 && response != 'captcha_error') {
					 showCommentAlert_comments("Server is busy Please try after some time");
					 document.getElementById('newCommentFormDiv').innerHTML = " ";
					return false;
					 } else {
					 document.getElementById("actual-comments-div").innerHTML  = response;
					 var type =  document.getElementById("comment_page_type").value;
						if(type == 'readall')
						{
						       alert("Your comment has been added");
						}
						else {
						       showCommentAlert('/comment/' + year + '/' + month + '/' + getContentId() + '.html');
						       }
				     
			         document.getElementById('newCommentFormDiv').innerHTML = " ";
			  
					 }
	    }
			,'onError':function(req)
			{
			  alert("onerrorfunction:"+req);
				hideLoader(submit_obj, cancel_obj, loader_obj);
				//alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			}
		}
	);
	return false;
	
 }
 window.center = function()
{
var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};
var _x = 0;
var _y = 0;
var offsetX = 0;
var offsetY = 0;
//IE
if(!window.pageYOffset)
{
//strict mode
if(!(document.documentElement.scrollTop == 0))
{
offsetY = document.documentElement.scrollTop;
offsetX = document.documentElement.scrollLeft;
}
//quirks mode
else
{
offsetY = document.body.scrollTop;
offsetX = document.body.scrollLeft;
}
}
//w3c
else
{
offsetX = window.pageXOffset;
offsetY = window.pageYOffset;
}
_x = ((this.size().width-hWnd.width)/2)+offsetX;
_y = ((this.size().height-hWnd.height)/2)+offsetY-115;
return{x:_x,y:_y};
}

 function getContentId()
{
	if (document.getElementById('article_info_form'))
	{
		return document.getElementById('article_info_form').content_id.value;
	}
}
window.size = function()
{
var w = 0;
var h = 0;
//IE
if(!window.innerWidth)
{
//strict mode
if(!(document.documentElement.clientWidth == 0))
{
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
}
//quirks mode
else
{
w = document.body.clientWidth;
h = document.body.clientHeight;
}
}
//w3c
else
{
w = window.innerWidth;
h = window.innerHeight;
}
return {width:w,height:h};
}
 var comment_alert_tab = new Image();
comment_alert_tab.src = '/img/comments/alert.jpg';
var comment_alert_icon = new Image();
comment_alert_icon.src = '/img/comments/alert-icon.jpg';
function showCommentAlert(url)
{
	var point = window.center({width:270,height:115});
	var div = document.createElement("div");
	div.setAttribute('id',"alertDiv");
	div.style.verticalAlign="middle";
	div.style.textAlign="center";
	div.style.background ="#ece9d8";
	div.style.position = "absolute";
	div.style.top = point.y + "px";
	div.style.left = point.x + "px";
	div.style.width = "270px";
	div.style.display = "none";
	div.style.height = "115px";
	div.style.padding="0px";
	div.style.font = "normal 12px arial,verdana";
	div.innerHTML = '<img id="alert-tab-img" src="/img/comments/alert.jpg" border="0" /><div id="info-box" style="margin-top: -5px;height: 86px;padding: 0px;border: solid 2px #0047df;width: 266px;"><div id="alert-icon-div" style="float: left;"><img id="alert-icon-img" src="/img/comments/alert-icon.jpg" border="0" style="float: left;padding-top: 10px;padding-bottom: 5px;padding-right:10px;padding-left: 10px;"  /></div><div id="comment-alert-msg-div" style="float: left;padding-top:20px;font: normal 12px arial;">Your comment has been added.</div><div id="alert-form-div" style="padding-top: 50px;*padding-top: 25px;"><form><input type="button" style="width: 73px;height: 23px;font: normal 11px arial;" name="alert_ok" value="OK" onclick="callPopup(' + "'" + url + "'" + ');" /></form></div></div>';
	document.body.appendChild(div);
	document.getElementById('alert-tab-img').src = comment_alert_tab.src;
	document.getElementById('alert-icon-img').src = comment_alert_icon.src;
	document.body.setAttribute('onClick', "callPopup(" + "'" + url + "'" + ");");
	document.getElementById("alertDiv").style.display="block";
}
function showCommentAlert_comments(message)
{
	var point = window.center({width:270,height:115});
	var div = document.createElement("div");
	div.setAttribute('id',"alertDiv");
	div.style.verticalAlign="middle";
	div.style.textAlign="center";
	div.style.background ="#ece9d8";
	div.style.position = "absolute";
	div.style.top = point.y + "px";
	div.style.left = point.x + "px";
	div.style.width = "270px";
	div.style.display = "none";
	div.style.height = "115px";
	div.style.padding="0px";
	div.style.font = "normal 12px arial,verdana";
	div.innerHTML = '<img id="alert-tab-img" src="/img/comments/alert.jpg" border="0" /><div id="info-box" style="margin-top: -5px;height: 86px;padding: 0px;border: solid 2px #0047df;width: 266px;"><div id="alert-icon-div" style="float: left;"><img id="alert-icon-img" src="/img/comments/alert-icon.jpg" border="0" style="float: left;padding-top: 10px;padding-bottom: 5px;padding-right:10px;padding-left: 10px;"  /></div><div id="comment-alert-msg-div" style="padding-top:10px;font: normal 12px arial;">'+message+'</div><div id="alert-form-div" style="padding-top: 19px;*padding-top: 25px;"><form><input type="button" style="width: 73px;height: 23px;font: normal 11px arial;" name="alert_ok" value="OK" onclick="callPopup_comments();" /></form></div></div>';
	document.body.appendChild(div);
	document.getElementById('alert-tab-img').src = comment_alert_tab.src;
	document.getElementById('alert-icon-img').src = comment_alert_icon.src;
	document.getElementById("alertDiv").style.display="block";
}
function callPopup_comments()
{
	
	//alert(document.getElementById("alertDiv"));
	var divobj = document.getElementById("alertDiv");
	//alert(divobj);
	document.body.removeChild(divobj);
	
	return false;
}
function callPopup(url)
{
	if (ie)
	{
		iePopup();
	}
	else
	{
		newPopup(url);
	}
	//alert(document.getElementById("alertDiv"));
	var divobj = document.getElementById("alertDiv");
	//alert(divobj);
	document.body.removeChild(divobj);
	document.body.setAttribute('onClick', "");
	return false;
}
function gettextCounter(field,maxlimit)
{
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	}
	else {
		var str_length = maxlimit - field.value.length;
		document.getElementById("charcount2").innerHTML  = "Characters left:"+str_length;
		
	}
}


 

 function getmetaContents(mn)
{
	var m = document.getElementsByTagName('meta');
	var metaTitle = '';
	for(var i in m)
	{
		if(m[i].name == mn)
		{
			metaTitle = m[i].content;
		}
	}
	if((metaTitle == '') || (metaTitle == 'undefined'))
	{
		metaTitle = document.title;
	}
	return metaTitle;
}
 

function closeDiv(id)
{
document.getElementById(id).innerHTML='';
}
function showLoader(submit_obj,cancel_obj,loader_obj)
{
	submit_obj.style.display = 'none';
	cancel_obj.style.display = 'none';
	loader_obj.style.display = '';
}
function hideLoader(submit_obj,cancel_obj,loader_obj)
{
	loader_obj.style.display = 'none';
	submit_obj.style.display = '';
	cancel_obj.style.display = '';	
}


function setTopReadAllLink()
{
	if(document.getElementById('read-all-comments')) {
		var str = document.getElementById('read-all-comments').innerHTML;
		}else { var str = ''; };
	var post_str = document.getElementById('bottom-post-comment').innerHTML;
	var total_str = str + '&nbsp; &nbsp;' + post_str;
	if (document.getElementById('content_comments') && document.getElementById('bottom-post-comment'))
	{
		document.getElementById('content_comments').innerHTML = total_str;
	}
}
 
//comments javascript functions ends here

//slider javascripts code starts
/****************************************************************************
Accessible News Slider
https://github.com/rip747/Yahoo-style-news-slider-for-jQuery

Authors:
Brian Reindel
http://blog.reindel.com

Andrea Ferracani
http://www.micc.unifi.it/ferracani

Maintainer:
Anthony Petruzzi
http://rip747.github.com/

License:
Unrestricted. This script is free for both personal and commercial use.
*****************************************************************************/
(function( $ ){
	$.fn.accessNews = function(settings){
	
		var defaults = {
			// title for the display
			title: "",
			// subtitle for the display
			subtitle: "",
			// number of slides to advance when paginating
			slideBy: 5,
			// the speed for the pagination
			speed: "normal",
			// slideshow interval
			slideShowInterval: 5000000000,
			// delay before slide show begins
			slideShowDelay: 5000000000,
			// theme
			theme: "default",
			// allow the pagination to wrap continuously instead of stopping when the beginning or end is reached 
			continuousPaging : true,
			// selector for the story title
			contentTitle: "h3",
			// selector for the story subtitle
			contentSubTitle: "abbr",
			// selector for the story description
			contentDescription: "p",
			// function to call when the slider first initializes
			onLoad: null,
			// function to call when the slider is done being created
			onComplete: null
		};
		
		return this.each(function(){
			
			settings = jQuery.extend(defaults, settings);
			var _this = jQuery(this);
			var stories = _this.children();
			var intervalId;
			var _storyIndictor;
			var _storyIndictors;
			
			var container = {
				_wrapper: "<div class=\"jqans-wrapper " + settings.theme + "\"></div>",
				_container: "<div class=\"jqans-container\"></div>",
				_headline: jQuery("<div class='jqans-headline'></div>").html(["<p><strong>", settings.title, "</strong> ", settings.subtitle, "</p>"].join("")),
				_content: jQuery("<div class='jqans-content'></div>"),
				_stories: "<div class=\"jqans-stories\"></div>",
				_first: jQuery(stories[0]),
				
				init: function(){
				
					if (settings.onLoad)
					{
						settings.onLoad.call($(this));
					}
				
					// wrap the ul with our div class and assigned theme
					_this.wrap(this._wrapper);
					// our container where we show the image and news item
					_this.before(this._container);
					// set the width of the container
					var width = (stories.length * this._first.outerWidth(true));
					_this.css("width", width);

					if (settings.title.length)
					{
						this.append(this._headline);
					}
					this.append(this._content);
					
					// create the selector indictor
					this.selector(width);
					
					this.set(0);
					
					// pagination setup
					pagination.init();
					
					// slideshow setup
					slideshow.init();
					
					_this.wrap(this._stories);
					
					if (settings.onComplete)
					{
						settings.onComplete.call($(this));
					}

				},
				
				selector: function(width){
					var s = "";
					for(var i = 1; i <= stories.length; i++){
						s += "<li><div/></li>";
					}
					var o = jQuery("<div class=\"jqans-stories-selector\" style=\"width: 660px;padding-top: 3px;\"></div>");
					o.append("<ul>"+ s +"</ul>");
					_storyIndictor = jQuery(o.find("ul"));
					_storyIndictors = _storyIndictor.children();
					o.css("width", width);
					_this.before(o);
				},
				
				append: function(content){
					this.get().append(content);
				},
				
				// returns the main container
				get: function(){
					return _this.parents("div.jqans-wrapper").find('div.jqans-container');
				},
				 set: function(position){
					var container = this.get();
					var story = jQuery(stories[position]);
					var storyIndictor = jQuery(_storyIndictors[position]);
					var _content = jQuery("div.jqans-content", container);
					var img = jQuery('<img width="660" height="250" align="left"></img>');
					var para = jQuery('<div style="position:absolute;top:195px;background:#000000;width:640px;opacity:0.8;color:#ffffff;height:50px;padding:5px 10px;"></div>');
					var title = jQuery(settings.contentTitle + " a", story).attr('title') || jQuery(settings.contentTitle, story).html();
					img.attr('src', jQuery('img', story).attr('longdesc') || jQuery('img', story).attr('src'));
					para.html("<h1>" + title + "</h1>" + "<p>" + jQuery(settings.contentDescription, story).html() + "</p>");
					_content.empty();
					_content.append(img);
					_content.append(para);
					stories.removeClass('selected');
					story.addClass('selected');
					_storyIndictors.removeClass('selected');
					storyIndictor.addClass('selected');
				}
				
			};
			
			var pagination = {
			
				loaded: false,
				_animating: false,
				_totalPages: 0,
				_currentPage: 1,
				_storyWidth: 0,
				_slideByWidth: 0,

				init: function(){
					if (stories.length > settings.slideBy) {
						this._totalPages = Math.ceil(stories.length / settings.slideBy);
						this._storyWidth = 132;//jQuery(stories[0]).outerWidth(true);
						this._slideByWidth = this._storyWidth * settings.slideBy;
						this._slideByWidth = this._storyWidth * settings.slideBy;
						this.draw();
						this.loaded = true;
					}
				},
				
				draw: function(){
				
					var _viewAll = jQuery("<div class=\"jqans-pagination\"></div>").html(["<div class=\"jqans-pagination-count\"><span class=\"jqans-pagination-count-start\">1</span> - <span class=\"jqans-pagination-count-end\">", settings.slideBy, "</span> of <span class=\"jqans-pagination-count-total\">", stories.length, "</span> total</div><div class=\"jqans-pagination-controls\"><span class=\"jqans-pagination-controls-back\"><a href=\"#\" title=\"Back\">&lt;&lt; Back</a></span><span class=\"jqans-pagination-controls-next\"><a href=\"#\" title=\"Next\">Next &gt;&gt;</a></span></div>"].join(""));
					_this.after(_viewAll);
					
					var _next = jQuery(".jqans-pagination-controls-next > a", _viewAll);
					var _back = jQuery(".jqans-pagination-controls-back > a", _viewAll);
					
					_next.click(function(){
						
						var page = pagination._currentPage + 1;
						pagination.to(page);
						return false;
						
					});
					
					_back.click(function(){
						
						var page = pagination._currentPage - 1;
						pagination.to(page);
						return false;
						
					});

				},
				
				to: function(page){

					if(this._animating){
						return;
					}
					
					// we're animating! 
					this._animating = true;
					
					var viewAll = _this.parent("div").next(".jqans-pagination");
					var startAt = jQuery(".jqans-pagination-count-start", viewAll);
					var endAt = jQuery(".jqans-pagination-count-end", viewAll);
					
					if(page > this._totalPages)
					{
						page =  settings.continuousPaging ? 1 : this._totalPages;
					}
					
					if (page < 1)
					{
						page =  settings.continuousPaging ? this._totalPages : 1;
					}

					var _startAt = (page * settings.slideBy) - settings.slideBy;
					var _endAt = (page * settings.slideBy);
					if (_endAt > stories.length)
					{
						_endAt = stories.length;
					}
					var _left = parseInt(_this.css("left"));
					var _offset = (page * this._slideByWidth) - this._slideByWidth; 
					startAt.html(_startAt + 1);
					endAt.html(_endAt);
					
					_left = (_offset * -1);
						
					_this.animate({
						left: _left
					}, settings.speed);
					
					_storyIndictor.animate({
						left: _left
					}, settings.speed);
					
					// when paginating set the active story to the first
					// story on the page
					container.set(_startAt);

					this._currentPage = page;
					
					// no more animating :(
					this._animating = false;
						
				}

			};
			
			var slideshow = {
				
				init: function(){
					this.attach();
					this.off();
					intervalId = setTimeout(function(){
						slideshow.on();
					}, settings.slideShowDelay);
				},
				
				on: function(){
					this.off();
					intervalId = setInterval(function(){
						slideshow.slide();
					}, settings.slideShowInterval);
				},
				
				off: function(){
					clearInterval(intervalId);
				},
				
				slide: function(){
				
					//currently selected story
					var current = jQuery("li.selected", _this);
					// the next story 
					var next = current.next("li");
					// page number
					var page = 0;
					
					if (!next.length)
					{
						next = jQuery(stories[0]);
						page = 1;
					}
					
					var storyIndex = stories.index(next);
					
					if (pagination.loaded) {

						var storyMod = (storyIndex) % settings.slideBy;
						
						if (storyMod === 0) {
							page = (Math.ceil(storyIndex / settings.slideBy)) + 1;
						}
						
						if (page > 0) {
							pagination.to(page);
						}
					}
					
					container.set(storyIndex);
					
				},
				
				attach: function(){
					
					var that = jQuery(_this).parent("div.jqans-wrapper");
					that.hover(function(){
						// pause the slideshow on hover
						slideshow.off();
					}, function (){
						// resume slideshow on mouseout
						slideshow.on();
					});
					
				}
				
			};
			
			//setup the container
			container.init();
			// append hover every to each element to update container content
			stories.hover(function(){
				// set container contect to hovered li
				container.set(stories.index(this));
			}, function(){
				// do nothing
			});

		});
	};
})( jQuery );

//slider javascripts code ends here



