//SuNIL
function download_Product(xID)
{
	var xProduct = $.ajax({
						  url: 'manage_downloads.php?Product_ID=' + xID,
						  async: false
						  }).responseText;

	if(xProduct == '1')
		alert('File is not exist.');
	else if(xProduct != '')
		window.location = xProduct;
	else
		ShowLightBox('includes/login.php');
}

function show_Detail(xID)
{
	var xDetail = $.ajax(
						 {url: 'get_description.php?Product_ID=' + xID,
						 async: false
						}).responseText;
	//$('#dvDetailBox').load('get_description.php?Product_ID=' + xID);
	if(xDetail != '')
	{
		$('#dvDetail').text(xDetail);
		ShowLightBox('get_description.php?Product_ID=' + xID);
	}
}

function register_validate()
{
	if(isBlank($('#txtUser_Name').val()))
	{
		alert("Please enter a User Name.");
		$('#txtUser_Name').focus();
		return false;
	}
	else if(isBlank($('#txtPassword').val()))
	{
		alert("Please enter a Password.");
		$('#txtPassword').focus();
		return false;
	}
	else if(isBlank($('#txtEmail_ID').val()))
	{
		alert("Please your Email.");
		$('#txtEmail_ID').focus();
		return false;
	}
	else
	{
		var pass1 = $('#txtPassword').val();
		var pass2 = $('#txtConfirm_Password').val();
		xEmail_Reg = /^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|0-9]+)*([-][a-z|0-9]+)*@[a-z][a-z|0-9]*([-][a-z|0-9]+)*\.([a-z][a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$/;
		if(pass1 != pass2)
		{
			alert("The passwords do not match.");
			$('#txtPassword').focus();
			return false;
		}
		else if(!xEmail_Reg.test($('#txtEmail_ID').val()))
		{
			alert("Please Enter proper Email.");
			$('#txtEmail_ID').focus();
			return false;
		}
	}
	var xRegistration = $.ajax({
							   url: 'manage_registration.php?txtUser_Name=' + $('#txtUser_Name').val() + '&txtPassword=' + $('#txtPassword').val() + '&txtEmail_ID=' + $('#txtEmail_ID').val(),
							   async: false
							   }).responseText;
	if(xRegistration == '1')
	{
		alert('Registered Successfully...');
		closex();
	}
	else
		alert(xRegistration);
}

function login_validate()
{
	if(isBlank($('#txtUser_Name').val()))
	{
		alert("Please enter a User Name.");
		$('#txtUser_Name').focus();
		return false;
	}
	else if(isBlank($('#txtPassword').val()))
	{
		alert("Please enter a Password.");
		$('#txtPassword').focus();
		return false;
	}
	var xLogin = $.ajax({
						url: "manage_login.php?txtUser_Name=" + $('#txtUser_Name').val() + "&txtPassword=" + $('#txtPassword').val(),
						async: false
						}).responseText;
	if(xLogin != '1')
	{
		alert(xLogin);
		$('#txtUser_Name').focus();
		return false;
	}
	else
	{
		closex();
	}
}

function isBlank(xValue)
{
	return (trim(xValue)=="");
}

function rightTrim(strValue) {
var objRegExp = /^([\w\W]*)(\b\s*)$/;
      if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '$1');
    }
  return strValue;
}

function leftTrim(strValue) {
var objRegExp = /^(\s*)(\b[\w\W]*)$/;
 
      if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function trim(strValue) {
 var objRegExp = /^(\s*)$/;
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}