//////Change the Catgory
function loadXMLString(txt) {
	try{ //Internet Explorer
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(txt);
		return(xmlDoc);  
	}catch(e){
		try {//Firefox, Mozilla, Opera, etc.
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(txt,"text/xml");
			return(xmlDoc);
		}catch(e) {alert(e.message)}
	}
	return(null);
}
function change(){
	document.frm.cat.value= document.frm.cat_id.value ;
}

	/////Eof -Chage Category
	var count = "500";   //Example: var count = "175";
	function limiter(){
		var tex = document.frm_ask.comment.value;
		var len = tex.length;
		var cc = tex;
		//alert(cc);
		if(len > count)	{
			tex = tex.substring(0,count);
			document.frm_ask.comment.value =tex;
			return false;
		}
		document.frm_ask.limit.value = count-len;	//	document.frm_ask.comment_que.value=cc;
	}
	//document.frm_ask.limit.value = count
	////Function FOr Ask.tpl Created On 12:10:09
	var count_ask = "500";   //Example: var count = "175";
	function limiter_ask(){
		var tex_ask = document.frm_ask.comment.value;
		var len_ask = tex_ask.length;
		var cc_ask = tex_ask;	//alert(cc_ask);
		if(len_ask > count)	{
			tex_ask = tex_ask.substring(0,count_ask);
			document.frm_ask.comment.value =tex_ask;	return false;
		}
		document.frm_ask.limit.value = count-len_ask;
	}
	////
	function hideshowans1() {
		if(document.getElementById('seeans1').style.display=='block') {
			document.getElementById('seeans1').style.display='none';
			var str="<div><a href='#enquient' onclick='hideshowans1()'>Attach a file</a></div>";
			hideans1.innerHTML=str;
		}else{
			var str="<div><a href='#enquient' onclick='hideshowans1()'>Attach a file</a></div>";
			document.getElementById('seeans1').style.display='block';
			hideans1.innerHTML=str;     
		}
	}
///////////////////Next ///////////////////
var counting = "1000";   //Example: var count = "175";
	function checkl(){
		var tex = document.frm_ask.detail.value;
		var len = tex.length;
		if(len > counting)	{
			tex = tex.substring(0,counting);
			document.frm_ask.detail.value =tex;
			return false;
		}
		document.frm_ask.dlimit.value = counting-len;
	}
	//document.frm_ask.dlimit.value = counting
///////////End///////////////////////////
function hidebutton(){
	document.getElementById("submitButton").style.display='none';
	document.getElementById("showLoading").style.display='block';
}

function fnext(form){
	with(form){
		task.value='ask';
		title.value=comment.value;
		qa_detail=detail.value;
		queryString = "&title="+title.value+"&qa_detail="+qa_detail;
		//url=AJAX_SITE_REQUEST_QNA_URL+"abuse_check.php?abuse=abuse" + queryString;
		$.ajax({	method: "get",
					url: AJAX_SITE_REQUEST_QNA_URL+"abuse_check.php",
					data: queryString ,
					beforeSend: function(){ $("#showLoading").show("fast");}, //show loading just when link is clicked
					complete: function(){ $("#showLoading").hide("fast");}, //stop showing loading when the process is complete
					success: function(html){ //so, if data is retrieved, store it in html
						if(html.indexOf("^^")!=-1 && html.length < 3){
							abuseNormal	=	'';
							abuseSevere	=	'';
						}else if(html.indexOf("^^")!=-1 && html.length > 2){
							abuseArr	=	html.split("^^");
							abuseNormal	=	abuseArr[0];
							abuseSevere	=	'';
						}else{
							abuseArr	=	html.split("^");
							abuseNormal	=	abuseArr[0];
							abuseSevere	=	abuseArr[1];
						}
						canContinue	=	true;
						abnormal		=	false;						
						absevere		=	false;												
						if(abuseNormal.length > 0){
							abnormal		=	true;						
						}
						if(abuseSevere.length > 0){
							canContinue	=	false;
							absevere		=	true;
						}	
						
						if(canContinue){
							if(abnormal){
								answer		=	'';
								answer1		=	'';
								//answer	=	confirm("Question or its details contains following abusing words \n \t "+ abuseNormal +"\n. Press cancel button to rectify them. \n If you don't rectify them they will be displayed as **** in your posting.");
								
								jConfirm("As per our terms of service, use of abusive term(s) is not permitted to be posted.<br />Your submission contains the following abusive term(s): <b>"+ abuseNormal +"</b><br />Click Cancel to rectify your post before submitting onsite.<br />If you do not wish to change these terms, they would be displayed as **** in your final posting onsite.", 'Sawaal Posting Error!',function(r){
																									 if(r==true)
																										 {
																											hidebutton();
																											form.submit();
																										 }else{
																											 
																										 }
																									 });								
								
								/*if(answer==false){
									document.getElementById("PostedQuestionTitleEditMode").style.display	=	'block';
									document.getElementById("PostedQuestionTitleView").style.display	=	'none';
									return false;
								}*/
//								alert(answer1);
//								return false;
							}else{
								hidebutton();
								form.submit();
							}
						}else{
							abuseSevere	=	abuseSevere.replace("^","");
							if(abnormal){
								temp			=	abuseSevere
								abuseSevere		=	abuseNormal + "," + temp
							}
							jAlert(" Question or its details contains following severe abusing words <br> &nbsp;&nbsp;&raquo; "+ abuseSevere +"<br> &nbsp;&nbsp;&nbsp;Please rectify them to continue.")
							return false;
						}
						
					}
		});
		// alert(url); return false;
		// reqfrmaskpg.value=file_name.value;	// Attachment not in use 
		// form.submit();
		// $("#btnsubmit").hide();
	}
	//alert(form.task.value);
}
function checklogin(){
	jAlert("You must first login Or register for email this question");
	window.location.href="index.php?action=user&task=login";
}
function login_chk(){
	jAlert('You must first login Or register for rating this question');	//window.location.href="index.php?action=user&task=login";
}

function search_ques(){
		var text=document.frmSearch.qaSearch.value;	//alert(text);
		window.location.href= SITE_URL + "search_index.php?action=search&s="+text+"&flag=sawaal";	//window.location.href="index.php?action=question&task=srh_qans&txt="+text;
	      
}
