/* * @Revision $Revision: 2510 $
  * @Author $Author: sumanth $
  * @Date $Date: 2008-10-17 12:15:20 +0530 (Fri, 17 Oct 2008)$
 */

function GetXmlHttpObject_Repabuse()
{
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 trim_ra(stringTotrim){
	return stringTotrim.replace(/^\s+|\s+$/g,'');
}

function getScrollWidth(){
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
   return w ? w : 0;
}

function getScrollHeight(){
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
   return h ? h : 0;
}

function controlOption(){
	if(document.getElementById('reason').value==4){
		document.getElementById('details').innerHTML="Details&nbsp;*";
		document.getElementById('optional').innerHTML="";
	}
	else{
		document.getElementById('details').innerHTML="Details";
		document.getElementById('optional').innerHTML="(optional)";
	}
}

function ie6BrowserCheck(){
	if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
		var ieversion=new Number(RegExp.$1);
		if(ieversion<7)
			return true;
		else
			return false;
	}
	else
		return false;
}


var sectionid=0;
var abuseid=0;
var realid=0;

function reportThis(sid,aid){
	
	var sinCookieValue = getCookie("SIN2006[SITEMP]");
	var sinCookieValueSet = 0;
    //document.getElementById("kenny").innerHTML = "<img name='capchange_req' src='/news/captcha/CaptchaSecurityImages.php' />";
	
    document.getElementById('reportabusemain12').innerHTML="<div id='reportabusemain'></div><div id='reportabusemain2'><div><div align='right'><a href='javascript:void(0);' title='close' onclick=closePopup('popup1') ><img src='http://www.siliconindia.com/images/x_d.gif' border='0' /></a></div></div><div style='padding-bottom:3px;'> Please let us know if this is violating SiliconIndia's <a href='http://www.siliconindia.com/reportabuse/termsofuse.php' target='_blank' id='msgReply'>terms of use</a></div><div class='Verdanabold' style='padding-left:70px;'>Report abuse as</div><div id='reportabuse1' style='padding-top:10px; padding-bottom:10px;'><div style='float: left; width:60px;'><div align='right' class='VerdanablckAsh12'>Reason *</div></div><div style='margin-left:70px;'><select name='cboabusetype' class='photonewcommunity' id='reason' onchange='controlOption()'><option value=''>Select one</option><option value='1'>Irrelevant</option><option value='2'>Offensive</option><option value='3'>Spam</option><option value='4'>Other</option></select></div></div><div style='float:left; width:60px;margin-left: -6px;' align='right'><div class='VerdanablckAsh12' id='details'>Details</div><div class='Verdana10Ash999' id='optional'>(optional)</div></div><div style='margin-left:70px;'><textarea id='detailsdesc' rows='4' class='photonewcommunity' style='width:420px;'></textarea></div><div id='reportabuse2' style='padding-top:10px; margin-left:25px;'><table width='470' border='0' cellspacing='0' cellpadding='0'><tr><td width='45'>Name *</td><td width='190'><input id='username' type='text' class='photonewcommunity' style='width:170px;'>&nbsp;</td><td width='45'>Email *</td><td width='190'><input id='useremail' type='text' class='photonewcommunity' style='width:170px;' /></td></tr><tr><td colspan='4'></td> </tr></table></div><div id='capcharow'><div style='float:left; width:30px; padding-left:70px; '><div id='kenny'><img name='capchange_req' src='/news/captcha/CaptchaSecurityImages.php' /> </div></div><div style='margin-left:200px;'><div class='Verdana10Ash999' style='padding-bottom:5px;' id='wrongcap'> Type the characters you see in the picture  </div><div><input type='text' class='photonewcommunity' id='capchacode'/></div></div></div><div style='padding-top:15px; padding-left:70px;'><a href='javascript:void(0);' onclick='return submitReport()' class='people' id='submitreport'>Submit</a>&nbsp;<a href='javascript:void(0);' onclick=closePopup('popup1') class='graybtn' id='cancel'>Cancel</a>&nbsp;&nbsp;<span id='response' class='Verdanabold'></span><br><span id='response1' class='Verdanabold'></span></div></div><div id='aftersub' style='display:none;'></div><div class='VerdanablckAsh12' id='aftersub2' style='display:none;'><div><div align='right'><img src='http://www.siliconindia.com/images/x_d.gif' onclick=closePopup('popup2') style='cursor:pointer;'></div></div><div align='center' class='Verdanabold' id='aftersubmsg'></div></div>";



	if(sinCookieValue!=null)
	{

		sinCookieValueSet = 1;
		var arrayOfSinCookieValue = sinCookieValue.split("++");
		realid = arrayOfSinCookieValue[8];
		document.getElementById('reportabuse2').style.display = "none";
		document.getElementById('capcharow').style.display = "none";
		document.getElementById('reportabusemain').style.height="320px";
		document.getElementById('reportabusemain2').style.height="270px";
	}

	/*var cookieValue = getCookie("reportid");
	var reportThis = 0;

	if(cookieValue!=null){
		var arrayOfCookie = cookieValue.split("/");
		var arrayLength = arrayOfCookie.length;

		for(var i=0;i<arrayLength;i++){
	 		if(arrayOfCookie[i]==cookieCompareWith){
	 			reportThis = 1;
	 			break;
	 		}
		}
	}

	if(reportThis==1){
		var scrollHeight = (getScrollHeight()+20);
		document.getElementById('aftersub').style.marginTop=scrollHeight+"px";
		document.getElementById('aftersub2').style.marginTop=(scrollHeight+15)+"px";
		if(sid==1)
			document.getElementById('aftersubmsg').innerHTML = "You have already reported this comment before.";
		else if(sid==2){
			document.getElementById('aftersubmsg').innerHTML = "You have already reported this question before.";
		}
		else if(sid==3){
			document.getElementById('aftersubmsg').innerHTML = "You have already reported this answer before.";
		}
		document.getElementById('aftersub').style.display = "block";
		document.getElementById('aftersub2').style.display = "block";
	}*/
	//else{
		sectionid = sid;
		abuseid = aid;

		var scrollHeight = getScrollHeight();
		document.getElementById('reportabusemain').style.marginTop=scrollHeight+"px";
		document.getElementById('reportabusemain2').style.marginTop=Number(scrollHeight+20)+"px";
        document.images['capchange_req'].src='/news/captcha/CaptchaSecurityImages.php?' + Date.parse(new Date().toString());
		document.getElementById('reportabusemain').style.display='block';
		document.getElementById('reportabusemain2').style.display='block';

		if(sinCookieValue==null){
			if(ie6BrowserCheck()){
				alert("Please enter the reason why you want to report this.");
				document.getElementById('reason').focus();
				return false;
			}
		}
	//}
}

function closePopup(layerName){
	if(layerName=="popup1"){
		document.getElementById('reportabusemain').style.display='none';
		document.getElementById('reportabusemain2').style.display='none';
	}
	else if(layerName=="popup2"){
		document.getElementById('aftersub').style.display='none';
		document.getElementById('aftersub2').style.display='none';
	}
}

function submitReport(){
	var reason = document.getElementById('reason').value;
	var details = trim_ra(document.getElementById('detailsdesc').value).replace(/&/g, "and");

	if(realid==0){
		var name = trim_ra(document.getElementById('username').value);
		var email = trim_ra(document.getElementById('useremail').value);
		var ccode = trim_ra(document.getElementById('capchacode').value);
	}
	var alphaExp = /^[a-z A-Z]+$/;

	if(reason==""){
		alert("Please select the reason.");
		document.getElementById('reason').focus();
		return false;
	}
	if(reason==4){
		if(details==""){
			alert("Please let us know why you want to report this.");
			document.getElementById('detailsdesc').focus();
			return false;
		}
	}

	if(name=="" && realid==0){
		alert("Enter your name.");
		document.getElementById('username').focus();
		return false;
	}
	if(name!=null && realid==0){
		if(!name.match(alphaExp)){
			alert("Name can have only alphabetical characters.");
			document.getElementById('username').focus();
			return false;
		}
	}

	if(email=="" && realid==0){
		alert("Enter your email.");
		document.getElementById('useremail').focus();
		return false;
	}
	if(email!=null && realid==0){
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
		if (!filter.test(email)){
			alert("Please enter a valid email address!")
			document.getElementById('useremail').focus();
			return false;
		}
	}
	if(ccode=="" && realid==0){
		alert("Type the characters you see in the picture");
		document.getElementById('capchacode').focus();
		return false;
	}
	else{
		if(realid==0)
			var abuseParams = "sectionid="+sectionid+"&abuseid="+abuseid+"&reason="+reason+"&details="+details+"&name="+name+"&email="+email+"&ccode="+ccode;
		else
			var abuseParams = "sectionid="+sectionid+"&abuseid="+abuseid+"&reason="+reason+"&details="+details+"&rid="+realid;

		xmlHttp_abuse=GetXmlHttpObject_Repabuse();
		var url="/reportabuse/submitreport.php";

		xmlHttp_abuse.open("POST",url,true);
		xmlHttp_abuse.onreadystatechange=function (){
			if (xmlHttp_abuse.readyState==4 && xmlHttp_abuse.status == 200){
				if(xmlHttp_abuse.responseText=="RES|1"){
					document.getElementById('response').innerHTML =	"";
					document.getElementById('response1').innerHTML = "Thanks for your co-operation. Admin will review your report.";
					resetForm();
				}
				else if(xmlHttp_abuse.responseText=="ERR|1" || xmlHttp_abuse.responseText=="ERR|2" || xmlHttp_abuse.responseText=="ERR|3"){
					document.getElementById('submitreport').style.visibility = 'visible';
					document.getElementById('cancel').style.visibility = 'visible';
					if(xmlHttp_abuse.responseText!="ERR|1")
						document.getElementById('response').innerHTML =	"Please submit it again.";
					else
						document.getElementById('response').innerHTML = "";

					document.images['capchange_req'].src='/news/captcha/CaptchaSecurityImages.php?' + Date.parse(new Date().toString());
					document.getElementById('wrongcap').style.color = "red";
					document.getElementById('capchacode').value = "";
					document.getElementById('capchacode').focus();
				}
			}
			else{
				document.getElementById('submitreport').style.visibility = 'hidden';
				document.getElementById('cancel').style.visibility = 'hidden';
				document.getElementById('response').innerHTML = "Loading...";
				document.getElementById('wrongcap').style.color = "";
			}
		}
		xmlHttp_abuse.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp_abuse.setRequestHeader("Content-length", abuseParams.length);
		xmlHttp_abuse.setRequestHeader("Connection", "close");
		xmlHttp_abuse.send(abuseParams);
		return false;
	}
}


function resetForm(){
	document.getElementById('reason').value="";
	document.getElementById('detailsdesc').value="";
	document.getElementById('username').value="";
	document.getElementById('useremail').value="";
	document.getElementById('capchacode').value="";
	document.getElementById('wrongcap').style.color = "";
	document.getElementById('submitreport').style.visibility = 'visible';
	document.getElementById('cancel').style.visibility = 'visible';
	setTimeout("document.getElementById('response1').innerHTML ='';closePopup('popup1');",5000);
}

function getCookie(c_name){
	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 null;
}

function layerControl(c){
	if(c=="signin"){
		document.getElementById("newmahi").style.display="block";
		document.getElementById("newmahi2").style.display="block";
	}
	else if(c=="closesignin"){
		document.getElementById("newmahi").style.display="none";
		document.getElementById("newmahi2").style.display="none";
	}
}

function validate_trmuse(){var b=document.getElementById("opt").value;var a=document.getElementById("search11").value;if(a==""||a=="Videos (interest, title, category...)"||a=="Blogs (blogger name, title, category, interest...)"||a=="Members (name, city, interest, company, college, title,..)"||a=="News (interest, title, category...)"||a=="Jobs (location, functional area, experience, industry,..)"||a=="Mentors (mentor name, category, location, company...)"||a=="Communities (name, interest, category...)"||a=="Q&A  (question, answers...)"){alert("Please enter the search string");document.searchfrm.search.focus();return false}if(b=="1"){document.searchfrm.action="/video/coursesearch.php?keyword="+document.searchfrm.search.value}else{if(b=="2"){document.searchfrm.action="/category/searchresult/"}else{if(b=="3"){document.searchfrm.action="/network/membersearch.php"}else{if(b=="4"){document.searchfrm.action="/news/searchnews.php"}else{if(b=="5"){document.searchfrm.keywords.value=document.searchfrm.search.value;document.searchfrm.action="/career/jobsearch.php"}else{if(b=="6"){document.searchfrm.action="/mentorship_new1/mentorship_search.php"}else{if(b=="7"){document.searchfrm.action="http://communities.siliconindia.com/searchresult"}else{if(b=="8"){document.searchfrm.action="/answers/questions_search.php?topic=1"}}}}}}}}document.searchfrm.submit()}

function optionvalue(a){switch(a){case"1":document.getElementById("search11").value="Videos (interest, title, category...)";break;case"2":document.getElementById("search11").value="Blogs (blogger name, title, category, interest...)";break;case"3":document.getElementById("search11").value="Members (name, city, interest, company, college, title,..)";break;case"4":document.getElementById("search11").value="News (interest, title, category...)";break;case"5":document.getElementById("search11").value="Jobs (location, functional area, experience, industry,..)";break;case"6":document.getElementById("search11").value="Mentors (mentor name, category, location, company...)";break;case"7":document.getElementById("search11").value="Communities (name, interest, category...)";break;case"8":document.getElementById("search11").value="Q&A  (question, answers...)";break}}function hide(){if(document.getElementById("opt").value=="1"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="2"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="3"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="4"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="5"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="6"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="7"){document.getElementById("search11").value=""}else{if(document.getElementById("opt").value=="8"){document.getElementById("search11").value=""}}}}}}}}}

function loginvalidation_Repabuse(){if(document.loginform.email.value==""){alert("Please enter your e-mail id");document.loginform.email.focus();return false}else{if(document.loginform.email.value!=""){str=document.loginform.email.value;var a=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(!a.test(str)){alert("Please input a valid email address!");document.loginform.email.focus();return false}}}if(trim_ra(document.loginform.password.value)==""){alert("Please enter your password");document.loginform.password.focus();return false}else{var b="e="+document.loginform.email.value+"&p="+document.loginform.password.value+"&cvalue="+document.loginform.checkbox.checked;xmlHttp2=GetXmlHttpObject_Repabuse();url="/reportabuse/log.php";xmlHttp2.open("POST",url,true);xmlHttp2.onreadystatechange=function(){if(xmlHttp2.readyState==4&&xmlHttp2.status==200){var c=trim_ra(xmlHttp2.responseText);if(c=="RES|1"){document.getElementById("abhijit").innerHTML="Your emailid or password not matched, please try again";document.getElementById("loginsubmit").value="Submit";document.loginform.password.value="";document.loginform.password.focus();document.getElementById("loginsubmit").disabled=false;}else{window.location=c}return false}else{document.getElementById("loginsubmit").value="Processing";document.getElementById("loginsubmit").disabled=true;}};xmlHttp2.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHttp2.setRequestHeader("Content-length",b.length);xmlHttp2.setRequestHeader("Connection","close");xmlHttp2.send(b);return false}}

function show(){if(document.getElementById("opt").value=="1"){document.getElementById("search11").value="Videos (interest, title, category...)"}else{if(document.getElementById("opt").value=="2"){document.getElementById("search11").value="Blogs (blogger name, title, category, interest...)"}else{if(document.getElementById("opt").value=="3"){document.getElementById("search11").value="Members (name, city, interest, company, college, title,..)"}else{if(document.getElementById("opt").value=="4"){document.getElementById("search11").value="News (interest, title, category...)"}else{if(document.getElementById("opt").value=="5"){document.getElementById("search11").value="Jobs (location, functional area, experience, industry,..)"}else{if(document.getElementById("opt").value=="6"){document.getElementById("search11").value="Mentors (mentor name, category, location, company...)"}else{if(document.getElementById("opt").value=="7"){document.getElementById("search11").value="Communities (name, interest, category...)"}else{if(document.getElementById("opt").value=="8"){document.getElementById("search11").value="Q&A  (question, answers...)"}}}}}}}}}
