
//Function to create Ajax Object-----------------------------------------------------------------------------------
function createajax()
{
   var objectname = false;	
	try { /*Internet Explorer Browsers*/ objectname = new ActiveXObject('Msxml2.XMLHTTP'); } 
	catch (e)
	{
		try { objectname = new ActiveXObject('Microsoft.XMLHTTP'); } 
		catch (e)  
		{
			try { /*// Opera 8.0+, Firefox, Safari*/ objectname = new XMLHttpRequest();	} 
			catch (e) { /*Something went wrong*/ alert('Your browser is not responding for Javascripts.'); return false; }
		}
	}
	return objectname;
}

function tabopen5(activetab,tabgroupname)
{
	var totaltabs = 5;
	var activetabheadclass = "producttabheadactive";
	var tabheadclass = "producttabhead";
	
	for(var i=1; i<=totaltabs; i++)
	{
		var tabhead = tabgroupname + 'h' + i;
		var tabcontent = tabgroupname + 'c' + i;
		if(i == activetab)
		{
			document.getElementById(tabhead).className = activetabheadclass;
			document.getElementById(tabcontent).style.display = 'block';
		}
		else
		{
			document.getElementById(tabhead).className = tabheadclass;
			document.getElementById(tabcontent).style.display = 'none';
		}
	}
}



function logintabopen3(activetab,tabgroupname)
{
	var totaltabs = 5;
	/*var activetabheadclass = "producttabheadactive";
	var tabheadclass = "producttabhead";*/
	
	for(var i=1; i<=totaltabs; i++)
	{
		var tabhead = tabgroupname + 'h' + i;
		var tabcontent = tabgroupname + 'c' + i;
		if(i == activetab)
		{
			/*document.getElementById(tabhead).className = activetabheadclass;*/
			document.getElementById(tabcontent).style.display = 'block';
		}
		else
		{
		/*	document.getElementById(tabhead).className = tabheadclass;*/
			document.getElementById(tabcontent).style.display = 'none';
		}
	}
}

function tabdisplay(activetab,tabgroupname)
{
	var totaltabs = 5;
	/*var activetabheadclass = "producttabheadactive";
	var tabheadclass = "producttabhead";*/
	
	for(var i=1; i<=totaltabs; i++)
	{
		var tabhead = tabgroupname + 'h' + i;
		var tabcontent = tabgroupname + 'c' + i;
		if(i == activetab)
		{
			/*document.getElementById(tabhead).className = activetabheadclass;*/
			document.getElementById(tabcontent).style.display = 'block';
		}
		else
		{
		/*	document.getElementById(tabhead).className = tabheadclass;*/
			document.getElementById(tabcontent).style.display = 'none';
		}
	}
}

function tabopen25(activetab,tabgroupname)
{
	var totaltabs = 25;
	var activetabheadclass = "tabheadactive";
	var tabheadclass = "tabhead";
	
	for(var i=1; i<=totaltabs; i++)
	{
		var tabhead = tabgroupname + 'h' + i;
		var tabcontent = tabgroupname + 'c' + i;
		if(i == activetab)
		{
			document.getElementById(tabhead).className = activetabheadclass;
			document.getElementById(tabcontent).style.display = 'block';
		}
		else
		{
			document.getElementById(tabhead).className = tabheadclass;
			document.getElementById(tabcontent).style.display = 'none';
		}
	}
}

function requesttabopen2(activetab,tabgroupname)
{
	var totaltabs = 2;
	/*var activetabheadclass = "producttabheadactive";
	var tabheadclass = "producttabhead";*/
	
	for(var i=1; i<=totaltabs; i++)
	{
		var tabhead = tabgroupname + 'h' + i;
		var tabcontent = tabgroupname + 'c' + i;
		if(i == activetab)
		{
			/*document.getElementById(tabhead).className = activetabheadclass;*/
			document.getElementById(tabcontent).style.display = 'block';
		}
		else
		{
		/*	document.getElementById(tabhead).className = tabheadclass;*/
			document.getElementById(tabcontent).style.display = 'none';
		}
	}
}


function validatecustomerlogin()
{
	var form = document.submitform;
	var field = form.username;
	if(!field.value)
	{
		alert('Please enter the UserName'); field.focus(); return false;
	}
	if(!validatecustomerid(field.value))
	{ 
		alert("Please enter a Valid Customer ID."); field.focus(); return false;
	}
	var field = form.password;
	if(!field.value)
	{
		alert('Enter the Password');field.focus(); return false;
	}
	else
	{
		form.submit();
	}
}


function validatecustomerid(cusid)
{
	var numericExpresion1 = /^\d{17}$/;
	var numericExpresion = /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{5}$/;
	var numericExpresion2 = /^[0-9]{4}(\s)[0-9]{4}(\s)[0-9]{4}(\s)[0-9]{5}$/;
	var numericExpresion3 = /^\d{5}$/;
	if(cusid.match(numericExpresion)) return true;
	else if(cusid.match(numericExpresion1)) return true;
	else if(cusid.match(numericExpresion2)) return true;
	else if(cusid.match(numericExpresion3)) return true;
	else return false;
}
function onblurvalue()
{
	var dtStr =  document.getElementById('username').value;
	var val=dtStr.replace(/-/g,"");
	document.getElementById('username').value = val;
}

function validateuserlogin()
{
	var form = document.noncusloginform;
	var field = form.lgnemail;
	if(!field.value)
	{
		alert('Please Enter Your Email Address '); field.focus(); return false;
	}
	var field = form.lgnpassword;
	if(!field.value)
	{
		alert('Please Enter the Password ');  field.focus(); return false;
	}
	else
	{
		return true;
	}
}

function validatedealerzone()
{
	var form = document.loginform;
	var field = form.username;
	if(!field.value)
	{
		alert('Please Enter the UserName'); field.focus(); return false;
	}
	var field = form.password;
	if(!field.value)
	{
		alert('Please Enter the Password'); field.focus(); return false;
	}
	else
	{
		return true;
	}
}


/*function validatephone(phone)
{
	var numericExpression1 = /^([^9]\d{5,10})$/i;
	var numericExpression2 = /^((\+)?(\d{2}[-]))?(\d{10}){1}?$/;
	if(phone.match(numericExpression1)) return true;
	else if(phone.match(numericExpression2)) return true;
	else return false;
}*/

function validatephone(phone)
{
	var numericExpression1 = /^[8|9]+[0-9]{9,9}$/i;
	var Expression2 = /^([^9]\d{5,7})(?:(?:[,;]([^9]\d{5,7})))*$/i;
	if(phone.match(numericExpression1)) return true;
	else 
	if(phone.match(Expression2)) return true;
	else return false;                                                     
}

function validatecustomerid(cusid)
{
	var numericExpresion1 = /^\d{17}$/;
	var numericExpresion = /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{5}$/;
	var numericExpresion2 = /^[0-9]{4}(\s)[0-9]{4}(\s)[0-9]{4}(\s)[0-9]{5}$/;
	var numericExpresion3 = /^\d{5}$/;
	if(cusid.match(numericExpresion)) return true;
	else if(cusid.match(numericExpresion1)) return true;
	else if(cusid.match(numericExpresion2)) return true;
	else if(cusid.match(numericExpresion3)) return true;
	else return false;
}

function onblurvalue()
{
	var dtStr =  document.getElementById('username').value;
	var val=dtStr.replace(/-/g,"");
	document.getElementById('username').value = val;
}

function validatepincode(pincodenumber)
{
	var numericExpression = /^[^0]+[0-9]{5}$/i;
	if(pincodenumber.match(numericExpression)) return true;
	else return false;
}

function validatecell(cellnumber)
{
	var numericExpression = /^[7|8|9]+[0-9]{9,9}(?:(?:[,;][9]+[0-9]{9,9}))*$/i;
	if(cellnumber.match(numericExpression)) return true;
	else return false;
}

function phonevalidation(phonenumber)
{
	var numericExpression =  /^([^9]\d{5,9})(?:(?:[,;]([^9]\d{5,9})))*$/i;
	if(phonenumber.match(numericExpression)) return true;
	else return false;
}


function emailvalidation(emailid1)
{
	var emailExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(emailid1.match(emailExp)) return true; 
	else return false; 
}

function validatecontactperson(contactname)
{
	var numericExpression = /^([A-Z\s\()]+[a-zA-Z\s()])(?:(?:[,;]([A-Z\s()]+[a-zA-Z\s()])))*$/i;
	if(contactname.match(numericExpression)) return true;
	else return false;
}

function validatebusinessname(contactname)
{
	var numericExpression = /^([A-Z0-9\s\-()]+[a-zA-Z0-9\s-()])(?:(?:[,;]([A-Z0-9\s-()]+[a-zA-Z0-9\s-()])))*$/i;
	if(contactname.match(numericExpression)) return true;
	else return false;
}

function validatewebsite(website)
{
	var websiteExpression = /^(www\.)?[a-zA-Z0-9-\.,]+\.(com|org|net|mil|edu|ca|co.uk|com.au|gov|co.in|in)$/i;
	if(website.match(websiteExpression)) return true;
	else return false;
}


//Function to get the value of selected radio element---------------------------------------------------------------
function getradiovalue(radioname)
{
	if(radioname.value)
		return radioname.value;
	else
	{
		for(var i = 0; i < radioname.length; i++) 
		{
			if(radioname[i].checked) 
				return radioname[i].value;
		}
	}
}


function validateamount(amount)
{
	var numericExpression = /^[-+]?[0-9]\d{0,9}(\.\d{1,2})?%?$/;
	if(amount.match(numericExpression)) return true;
	else return false;
}


//Function to display the error message in box---------------------------------------------------------------------
function errormessage(message)
{
	var msg = '<div class="errorbox">' + message + '</div>';
	return msg;
}

//Function to display the success message in box-------------------------------------------------------------------
function successmessage(message)
{
	var msg = '<div class="successbox">' + message + '</div>';
	return msg;
}

function getprocessingimage()
{
	var imagehtml = '<img src="../images/relyonweb-loading-image.gif" border="0"/>';
	return imagehtml;
}

//Function to make the display as block as well as none-------------------------------------------------------------
function divdisplay(elementid,imgname)
{
	if($('#'+ elementid).is(':visible'))
	{
		$('#'+ elementid).hide();
		if($('#'+ imgname))
			$('#'+ imgname).attr('src',"../images/plus.jpg");
	}
	else
	{
		$('#'+ elementid).show();
		if($('#'+ imgname))
			$('#'+ imgname).attr('src',"../images/minus.jpg");
	}
}

function divdisplayall(elementid)
{
	var totaltabs = 29;
	if(elementid == 'expand')
	{
		for(i=1;i<=totaltabs;i++)
		{
			var tabhead = 'display' + i;
			var tabimg = 'toggleimg' + i;
			$('#'+tabhead).hide();
			$('#'+ tabimg).attr('src',"../images/plus.jpg");
		}
	}
	else if(elementid == 'collapse')
	{
		for(i=1;i<=totaltabs;i++)
		{
			var tabhead = 'display' + i;
			var tabimg = 'toggleimg' + i;
			$('#'+tabhead).show();
			$('#'+ tabimg).attr('src',"../images/minus.jpg");
		}
	}
}

//Function to check whether the string is alphanumeric
function isAlpha(element)
{
	var myflag = true;
	for(i=0; i<element.length; i++)
	{
		if(((element.charCodeAt(i) == 46) || (element.charCodeAt(i) == 32) || (element.charCodeAt(i) >= 65 && element.charCodeAt(i) <= 90) || (element.charCodeAt(i) >= 97 && element.charCodeAt(i) <= 122) || (element.charCodeAt(i) >= 45 && element.charCodeAt(i) <= 57)) && myflag == true)
		{
			myflag = true;
		}
		else
		{
			myflag = false;
		}
	}
	return myflag;
}




