// JavaScript Document 
/*Show Hide div for Javascripts Begin */
function slideChange(a)
							{
						  var e=document.getElementById(a);
						  for (i=1;i<=9;i++)
							{
							if (document.getElementById("slide"+i).style.display="none")
							   {
							   document.getElementById("slide"+i).style.display="none";							   
							   }							 
							} 
						  document.getElementById(a).style.display="none";
						  return true;
						 }
						 
/*Show Hide div Javascripts Ends*/

function slideChangeall(a)
							{
						  var e=document.getElementById(a);
						  for (i=1;i<=9;i++)
							{
							if (document.getElementById("slide"+i).style.display="block")
							   {
							   document.getElementById("slide"+i).style.display="block";							  
							   }							 
							} 
						  document.getElementById(a).style.display="block";
						  
						  return true;
						 }
						 
		 

/******************************************
* Scrollable content script II-  Dynamic Drive (www.dynamicdrive.com)
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/


//specify speed of scroll (greater=faster)
var speed=5

iens6 = document.all||document.getElementById
firefox = document.getElementById && !document.all
 
var crossobj;
var contentwidth;
 
function movedown(a){

if (document.getElementById(a) != null )
{
crossobj=document.getElementById(a) 
if (iens6){
contentwidth=crossobj.offsetWidth 
}
if (firefox){
contentwidth=crossobj.offsetWidth + 0
}
}
if (iens6&&parseInt(crossobj.style.left)>=(contentwidth*(-1)+10))  /* IE Fix */
crossobj.style.left=parseInt(crossobj.style.left)-speed+"px"
movedownvar=setTimeout("movedown('a')",50)
}

function moveup(a){
if (document.getElementById(a) != null )
{
crossobj=document.getElementById(a) 
contentwidth=crossobj.offsetWidth
}
if (iens6&&parseInt(crossobj.style.left)<=0)
crossobj.style.left=parseInt(crossobj.style.left)+speed+"px"
moveupvar=setTimeout("moveup('a')",20)
}
/*Features template right side tab script*/
function getDocObj(id)
{
	return document.getElementById(id);
}

function showhideContent(imgdiv, postdiv, textspan)
{
	var imgObj = getDocObj(imgdiv);
    var postObj = getDocObj(postdiv);
    var textObj = getDocObj(textspan);
	for(i = 1; i<=6; i++)
	{
        txtid = "post"+i
        getDocObj("text"+i).style.color='black';
		if(postdiv != txtid)
		{
			document.getElementById(txtid).style.display = 'none';
			getDocObj("img"+i).src = 'http://www.manageengine.com/products/opmanager/images/plus.gif';
		}
    }

	if(postObj.style.display == 'none')
    {
        textObj.style.color='blue';
		postObj.style.display = 'block';
		imgObj.src = 'http://www.manageengine.com/products/opmanager/images/minus.gif';
		return;
	}
	else
    {
        textObj.style.color='black';
		postObj.style.display = 'none';
		imgObj.src = 'http://www.manageengine.com/products/opmanager/images/plus.gif';
	}
}
function facebooklink(url)
{
	window.open("http://www.facebook.com/home.php?#!/group.php?gid=217927928896&ref=ts");
}
function gotoURL(selectedVal)
{
    var myArray = [];
    myArray[0] = "http://demo.opmanager.com/map/MapView.do?viewId=USAIDC_bview.netmap&selectedView=TrafficMap&sortByOption=&fromPage=Map";
    myArray[1] = "http://demo.opmanager.com/devices/intfdata.do?interfacename=IF-192.168.118.39-2";
    myArray[2] = "http://demo.opmanager.com/overview.do?selectedTab=Maps&operation=NetFlowDashBoard";
    myArray[3] = "http://demo.opmanager.com/overview.do?selectedTab=Maps&period=16&operation=RttDashboard&isFromHome=yes";
    myArray[4] = "http://demo.opmanager.com/devices/objectdetails.do?name=192.168.118.39&requestid=SNAPSHOT&mapName=%27Routers_Map.netmap%27";
    myArray[5] = "http://demo.opmanager.com/devices/objectdetails.do?name=catalyst2900.zohocorpin.com&requestid=SNAPSHOT&mapName=%27Switches.netmap%27";
	myArray[6] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=192.168.113.209&mapName=Firewalls_Map.netmap";
	myArray[7] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=karthika.zohocorpin.com&mapName=Wireless_Map.netmap";
	myArray[8] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=rejoe.zohocorpin.com&mapName=WANAccelerators_Map.netmap";
	myArray[9] = "http://demo.opmanager.com/overview.do?operation=showVoipDashboard_ajax&selectedTab=Maps&isFromInfra=yes";
	myArray[10] = "http://demo.opmanager.com/NCMModule.do?selectedTab=Network%20Configuration%20Management";
	myArray[11] = "http://demo.opmanager.com/devices/objectdetails.do?name=meps1&mapName=Servers_Map.netmap&requestid=SNAPSHOT";
	myArray[12] = "http://demo.opmanager.com/devices/objectdetails.do?name=app-linux2.zohocorpin.com&mapName=Servers_Map.netmap&requestid=SNAPSHOT";
	myArray[13] = "http://demo.opmanager.com/map/MapView.do?selectedTab=Maps&selectedNode=VI_Map.netmap&viewId=VI_Map.netmap&displayName=VI_Map.netmap";
	myArray[14] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=emp-ex03.zohocorpin.com";
	myArray[15] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=admp-dc1.zohocorpin.com&mapName=DomainController_Map.netmap";
	myArray[16] = "http://demo.opmanager.com/devices/objectdetails.do?name=opman-w2k32.zohocorpin.com&mapName=Servers_Map.netmap&requestid=SNAPSHOT";
	myArray[17] = "http://demo.opmanager.com/devices/objectdetails.do?requestid=SNAPSHOT&name=apcups1.zohocorpin.com&mapName=Ups_Map.netmap";
	myArray[18] = "http://demo.opmanager.com/map/MapView.do?selectedTab=Maps&selectedNode=Printers.netmap&viewId=Printers.netmap&displayName=Printers.netmap";
	myArray[19] = "http://demo.opmanager.com/admin/EventLogRules.do?selectedTab=admin&selectedNode=EventLogRules&viewId=EventLogRules&displayName=Event%20Log%20Rules";
	myArray[20] = "http://demo.opmanager.com/admin/SysLogRules.do?methodCall=showPage&selectedTab=admin&selectedNode=SyslogRules&viewId=SyslogRules&displayName=Syslog%20Rules";
	myArray[21] = "http://demo.opmanager.com/admin/SNMPTrapProcessors.do?selectedTab=admin&selectedNode=SNMPTrapProcessors&viewId=SNMPTrapProcessors&displayName=SNMP%20Trap%20Processors";
	myArray[22] = "http://demo.opmanager.com/overview.do?selectedTab=Home";
	myArray[23] = "http://demo.opmanager.com/fault/AlarmView.do?viewId=ActiveAlarms&selectedTab=Alarms%20View";
	myArray[24] = "http://demo.opmanager.com/customDashboard.do?methodCall=showCCTVDashboard&cctvID=1&firstTime=true";
	myArray[25] = "http://demo.opmanager.com/admin/Profiles.do?selectedTab=admin&selectedNode=ConfigureNotifications&viewId=ConfigureNotifications&displayName=Notification%20Profiles";
	myArray[26] = "http://demo.opmanager.com/reports/ReportsIndex.do?selectedTab=Reports";

    var url1="http://demo.opmanager.com/jsp/Login.do?clienttype=html&userName=demoadmin&password=demoadmin";
    window.location = url1;
    var st="window.location='"+myArray[selectedVal]+"';";
    window.setTimeout(st,1000);
}

function gotoUrlMain(url)
{
	var myArray = [];
	myArray[0] = "http://demo.opmanager.com/jsp/Login.do?clienttype=html&userName=demoadmin&password=demoadmin";
	myArray[1] = "http://demo.opmanager.com/jsp/Login.do?clienttype=html&userName=netadmin&password=netadmin";
	myArray[2] = "http://demo.opmanager.com/jsp/Login.do?clienttype=html&userName=operator&password=operator";
	window.location = myArray[url];
}



/*download page*/
var currentPage="";
var loc = location.search;
currentPage=loc.substring(1);
var numtag = Number(currentPage);
if (!numtag)
{
	numtag = 1;
}	

function divAssign(sVal)
{
	var headVar = "tab";
	var pageVar = "content";
	
	for(i=1; i<=2; i++)
	{
		var headr = headVar+i;
		var contnt = pageVar+i;
		document.getElementById(headr).className = "eplmenunormaldownload";
		document.getElementById(contnt).style.display = "none";
		
	}
	
	document.getElementById(headVar+sVal).className = "eplmenucurrentdownload";
	document.getElementById(pageVar+sVal).style.display = "block";
		
}
function showHide(id,actid,inaid)
{
	if(document.getElementById(actid).style.fontWeight == "bold") {
		return;
	}
	var contentEle = document.getElementById(id);
	if(contentEle.style.display == 'none') {
		contentEle.style.display="block";
	} else if(contentEle.style.display == 'block'){
		contentEle.style.display="none";
	}
	document.getElementById(actid).style.fontWeight = "bold";
	document.getElementById(inaid).style.fontWeight = "";
}

function validate()
{

	submitOK="true";

	if(document.getElementById("userName").value == "")
	{
		alert("Kindly provide your name.");
		document.getElementById("userName").focus();
		return false;
	}
	if(document.getElementById("tel").value == "")
	{
		alert("Kindly provide your contact number");
		document.getElementById("tel").focus();
		return false;
	}
	if(document.getElementById("companyName").value == "")
	{
		alert("Kindly provide your company name");
		document.getElementById("companyName").focus();
		return false;
	}
	email = document.getElementById("emailID").value;
	var at=email.indexOf("@");
	
	if (at==-1)
	{
		alert("Please enter a valid e-mail id.");
		document.getElementById("emailID").focus();
		return false;
	}
	else
			{
			var email = document.getElementById("emailID").focus();
			var nexturl="http://www.manageengine.com/network-monitoring/netflow-plugin-confirm.html?email="+email;
			$("#nexturl").val(nexturl);
			emCamp(name)
			}	
	if(!document.LicenseKeyForm.OtherProp_Agreement.checked)
	{
		alert("Please accept the Terms of the License Agreement.");
		document.LicenseKeyForm.OtherProp_Agreement.focus();
		return false;
	}	
	//check for public email address
	if(email.indexOf("yahoo") > -1 || email.indexOf("gmail") > -1 || email.indexOf("rediff") > -1 || email.indexOf("hotmail") > -1 || email.indexOf("@comcast") > -1 || email.indexOf("@webex") > -1 || email.indexOf("@msn") > -1 || emmail.indexOf("@ymail") > -1 || email.indexOf("@live") > -1 || email.indexOf("@mail") > -1 || email.indexOf("@hushmai") > -1 || email.indexOf("@att") > -1 || email.indexOf("@metromail") > -1 || email.indexOf("@sbcglobal") > -1 || email.indexOf("@aol") > -1 || email.indexOf("@bellsouth") > -1 || email.indexOf("@rocketmail") > -1 || email.indexOf("@myspace") > -1 || email.indexOf("@facebook") > -1 || email.indexOf("@email") > -1 || email.indexOf("@bigpond") > -1 || email.indexOf("@optusnet") > -1 || email.indexOf("@primus") > -1 || email.indexOf("@tpg") > -1 || email.indexOf("@iprimus") > -1 || email.indexOf("@virginbroadband") > -1 || email.indexOf("@fastmail") > -1 || email.indexOf("@iinet") > -1 || email.indexOf("@y7mail") > -1 || email.indexOf("@dodo") > -1 || email.indexOf("@ozemail") > -1|| email.indexOf("@optus") > -1|| email.indexOf("@westnet") > -1)
	{
		if(email.indexOf("yahoo-inc") == -1)
		{
			alert("Kindly provide your company email id.\n hotmail,gmail and yahoo email id's are not accepted.");
			document.getElementById("emailID").focus();
			return false;
		}
	}

	return true;
}
var currentPage="";
var loc = location.search;
currentPage=loc.substring(1);
var numtag = Number(currentPage);
if (!numtag)
{
	numtag = 1;
}	
function getArr(cls)
{
	var arrval = cls.split('_');
	return arrval;
}

function hideState()
{
	if(document.getElementById("country").value != "USA")
	{
		document.getElementById("state").disabled=true;
	}
	else
	{
		document.getElementById("state").disabled=false;
	}	
}
function userFormValidate()
{
	formValidation = validate();

	if(!formValidation)
	{
		return false;
	}
	return true;
}

function tl1validate() 	 
{ 	 
			 if (document.LicenseKeyForm.OtherProp_Agreement.checked == false)
			 {
					alert("Please select the checkbox if you agree to the License Agreement terms");
					document.LicenseKeyForm.OtherProp_Agreement.focus();
					return false;
			 }
			
}
function isEmptyBox(text_value)
{
 	text_value= text_value.replace (/^(\s+)/, "").replace (/(\s+)$/, "")
    if(text_value == "")
        	return true;
    return false;
}
function tvalidate()
{
	elem=document.networkmonitoring.elements;
	elen=document.networkmonitoring.elements.length;
	for(i=0;i<elen;i++)
	{			
		if (elem[i].name.indexOf('fromemail') != -1 && isEmptyBox(elem[i].value))
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}
		if (elem[i].name.indexOf('fromemail') != -1 && elem[i].value.indexOf('@') == -1)
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}
		if (elem[i].name.indexOf('fromemail') != -1 && elem[i].value.indexOf('.') == -1)
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}			
	}
	return true;
}

function IsValidEmail(mailid)
{
    var mailRegExp  = /^[a-z0-9]([a-z0-9_\-\.\+]*)@([a-z0-9_\-\.]+)(\.[a-z]{2,3}){1,2}$/i;
    return mailRegExp.test(mailid);
}

function tl1validate(txtid) 	 
{
	var txtObj = document.getElementById(txtid);
	if (!IsValidEmail(txtObj.value)) 	 
	{ 
		alert("Please enter valid Email ID"); 	 
		txtObj.focus(); 	 
		return false; 	 
	} 	  
}
var myCars=new Array("@comcast","@webex","@gmail","@yahoo","@hotmail","@msn","@rediff","@ymail","@live","@mail","@hushmail","@att","@verizon","@metromail","@sbcglobal","@aol","@bellsouth","@rocketmail","@myspace","@facebook","@email","@bigpond","@optusnet","@primus","@tpg","@iprimus","@virginbroadband","@fastmail","@iinet","@y7mail","@dodo","@ozemail","@optus","@westnet");
function containsCheck(test)
{
	for(i=0;i<=myCars.length-1;i++)
	{
			var singleValue = myCars[i];
			var ex = test.match(singleValue);
			if (ex != null)
			{
				return true;
			}
	}
	return false;
}
function disFals(){
	document.getElementById("downloadSubmit").disabled=false;
	document.getElementById("InvMail").style.display="none";
	document.getElementById("InvId").style.display="none";
}
function disValue()
{
	var txtvalue =document.getElementById("emailID").value;
	var exValue = containsCheck(txtvalue.toLowerCase())
	if(exValue)
	{		
			document.getElementById("sp").style.display="block";
			document.getElementById("emailID").select();
			document.getElementById("downloadSubmit").disabled=true;

	}
	else
	{
			document.getElementById("sp").style.display="none";
			document.getElementById("downloadSubmit").disabled=false;
	}
}
function disFalse(tt){
}
var currentPage="";
var loc = location.search;
currentPage=loc.substring(1);
var numtag = Number(currentPage);
if (!numtag)
{
	numtag = 1;
}	

function divAssign(sVal)
{
	var headVar = "tab";
	var pageVar = "content";
	
	for(i=1; i<=2; i++)
	{
		var headr = headVar+i;
		var contnt = pageVar+i;
		document.getElementById(headr).className = "eplmenunormaldownload";
		document.getElementById(contnt).style.display = "none";
		
	}
	
	document.getElementById(headVar+sVal).className = "eplmenucurrentdownload";
	document.getElementById(pageVar+sVal).style.display = "block";
		
}
function showHide(id,actid,inaid)
{
	if(document.getElementById(actid).style.fontWeight == "bold") {
		return;
	}
	var contentEle = document.getElementById(id);
	if(contentEle.style.display == 'none') {
		contentEle.style.display="block";
	} else if(contentEle.style.display == 'block'){
		contentEle.style.display="none";
	}
	document.getElementById(actid).style.fontWeight = "bold";
	document.getElementById(inaid).style.fontWeight = "";
}

function validate()
{

	submitOK="true";

	if(document.getElementById("userName").value == "")
	{
		alert("Kindly provide your name.");
		document.getElementById("userName").focus();
		return false;
	}
	if(document.getElementById("tel").value == "")
	{
		alert("Kindly provide your contact number");
		document.getElementById("tel").focus();
		return false;
	}
	if(document.getElementById("companyName").value == "")
	{
		alert("Kindly provide your company name");
		document.getElementById("companyName").focus();
		return false;
	}
	email = document.getElementById("emailID").value;
	var at=email.indexOf("@");
	
	if (at==-1)
	{
		alert("Please enter a valid e-mail id.");
		document.getElementById("emailID").focus();
		return false;
	}
	
	if(!document.LicenseKeyForm.OtherProp_Agreement.checked)
	{
		alert("Please accept the Terms of the License Agreement.");
		document.LicenseKeyForm.OtherProp_Agreement.focus();
		return false;
	}	

	return true;
}



var currentPage="";
var loc = location.search;
currentPage=loc.substring(1);
var numtag = Number(currentPage);
if (!numtag)
{
	numtag = 1;
}	
function getArr(cls)
{
	var arrval = cls.split('_');
	return arrval;
}

function hideState()
{
	if(document.getElementById("country").value != "USA")
	{
		document.getElementById("state").disabled=true;
	}
	else
	{
		document.getElementById("state").disabled=false;
	}	
}
function userFormValidate()
{
	formValidation = validate();

	if(!formValidation)
	{
		return false;
	}
	return true;
}


function isEmptyBox(text_value)
{
 	text_value= text_value.replace (/^(\s+)/, "").replace (/(\s+)$/, "")
    if(text_value == "")
        	return true;
    return false;
}
function tvalidate()
{
	elem=document.networkmonitoring.elements;
	elen=document.networkmonitoring.elements.length;
	for(i=0;i<elen;i++)
	{			
		if (elem[i].name.indexOf('fromemail') != -1 && isEmptyBox(elem[i].value))
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}
		if (elem[i].name.indexOf('fromemail') != -1 && elem[i].value.indexOf('@') == -1)
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}
		if (elem[i].name.indexOf('fromemail') != -1 && elem[i].value.indexOf('.') == -1)
		{
			alert("Invalid E-Mail Address.");
			elem[i].focus();return false;
		}			
	}
	return true;
}

function IsValidEmail(mailid)
{
    var mailRegExp  = /^[a-z0-9]([a-z0-9_\-\.\+]*)@([a-z0-9_\-\.]+)(\.[a-z]{2,3}){1,2}$/i;
    return mailRegExp.test(mailid);
	
}

/*
function tl1validate(txtid) 	 
{
	var txtObj = document.getElementById(txtid);
	if (!IsValidEmail(txtObj.value)) 	 
	{ 
		alert("Please enter Valid email Id"); 	 
		txtObj.focus(); 	 
		return false; 	 
	} 	  
}
*/

function directDownloadValid()
{
	var emailId = document.getElementById("emailID");
	if (!IsValidEmail(emailId.value)) 	 
	{ 
		
		document.getElementById("InvMail").style.display="block";
		emailId.select();
		document.getElementById("downloadSubmit").disabled=true;
		//return false;
	} 
	else if(containsCheck(emailId.value.toLowerCase()))
	{		
			document.getElementById("InvId").style.display="block";
			emailId.select();
			document.getElementById("downloadSubmit").disabled=true;
			return false;
	}
	
	else
	{
			var popup = detailviewPopup('Form Submitted', 'solution1', 400);
			document.getElementById("ok").focus();
	}
	
}

function getValidMailId(){
	var emailId = document.getElementById("emailID");
	if(!IsValidEmail(emailId.value))
		{
			document.getElementById("InvMail").style.display="block";
			emailId.select();
			document.getElementById("downloadSubmit").disabled=true;
		}
	else if(containsCheck(emailId.value.toLowerCase()))
		{		
				document.getElementById("InvId").style.display="block";
				emailId.select();
				document.getElementById("downloadSubmit").disabled=true;
				return false;
		}
	
}

 function disEdition()
{
	var frmobj = document.getElementById("disEdidownload");
	var email = document.getElementById("emailID");
	submitOK="true";
	
	if(document.getElementById("userName").value == "")
	{
		alert("Please provide your name.");
		document.getElementById("userName").focus();
		return false;
	}
	if (!IsValidEmail(email.value))
	{
		alert("Please provide a valid business email ID.");
		email.select();
		return false;
	}
	if(containsCheck(email.value.toLowerCase()))
	{		
		alert("Please provide a valid business email ID.");
		email.select();
		return false;
	}
	if(document.getElementById("tel").value == "")
	{
		alert("Please provide your contact number");
		document.getElementById("tel").focus();
		return false;
	}
	if(document.getElementById("companyName").value == "")
	{
		alert("Please provide your company name");
		document.getElementById("companyName").focus();
		return false;
	}
	
	else {

			var popup = detailviewPopup('Form Submitted', 'solution1', 400);		

	}
	
	/*//check for public email address
	if(email.indexOf("yahoo") > -1 || email.indexOf("gmail") > -1 || email.indexOf("rediff") > -1 || email.indexOf("hotmail") > -1 || email.indexOf("@comcast.net") > -1 || email.indexOf("@yahoo.com.sg") > -1 || email.indexOf("@yahoo.com.vn") > -1 ||
	emmail.indexOf("@yahoo.co.id") > -1 || email.indexOf("yahoo.co.in") > -1)
	{
		if(email.indexOf("yahoo-inc") == -1)
		{
			alert("Kindly provide your company email id.\n hotmail,gmail and yahoo email id's are not accepted.");
			document.getElementById("emailID").focus();
			return false;
		}
	}*/
}

function disEditionValidate()
{
	formValidation = disEdition();
	
	if(!formValidation)
	{
		return false;
	}
	return true;
}
function invalidChar()
{
	var emailId = document.getElementById("emailID");
	if (!IsValidEmail(emailId.value)) 	 
	{ 
		
		document.getElementById("InvMail").style.display="block";
		emailId.select();
		document.getElementById("downloadSubmit").disabled=true;
		//return false;
	} 
	else if(containsCheck(emailId.value.toLowerCase()))
	{		
			document.getElementById("InvId").style.display="block";
			emailId.select();
			document.getElementById("downloadSubmit").disabled=true;
			return false;
	}
	
	else
	{
			//document.getElementById("sp").style.display="none";
			document.getElementById("downloadSubmit").disabled=false;
			return true;
	}
}
function licenseAgrmnt(){
		    if(!document.getElementById("licenseAgrement").checked){
			document.getElementById("lanseAgreement").style.display="block";
			return false;
	}
	return true;
}
function downLoadPgValidate(name)
{
	if(!invalidChar())
	{
		return false;
	}
	
	
	else{
		document.getElementById('nexturl').value="http://www.manageengine.com/network-monitoring/download_confirm.html?email="+document.getElementById("emailID").value;
		
	emCamp(name)
	}
}

function pluginDloadValidate(name)
{
	if(!invalidChar())
	{
		return false;
	}

}
