

	/*************************************************************/
	/*                                                           */
	/*                  Anand Tarey						       */
	/*  														 */
	/*************************************************************/

/****************************************************************/

/** ADDED BY Deepali */
function postit(pcode){ //check postcode format is valid
 test = pcode; 
 size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 pstr = "OK";
 pcode = test; //write back to form field
 if ((size < 6) || (size > 8)){ //Code length rule
 // pstr = " is not a valid postcode - wrong length. \n(example: XXXX XXX or XXX XXX)";
 pstr = "The postcode you entered was not recognized. Please use the format XXXX XXX or XXX XXX. Thankyou.";
 // return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   pstr = test + " is not a valid postcode - cannot start with a number";
  
  // return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   pstr = test + " is not a valid postcode - alpha character in wrong position";
 
  // return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   pstr = test + " is not a valid postcode - number in wrong position";
  // return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   pstr = test + " is not a valid postcode - number in wrong position";
   //return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   pstr = test + " is not a valid postcode - no space or space in wrong position";
  // return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   pstr = test + " is not a valid postcode - only one space allowed";
  // return false;
  }
//return true;
return pstr;
}
//  End -->

/* Check whether E-Mail ObjectField is Valid or Not.*/

function isEmail(s)
    {
		var re;
        re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
        if (re.test(s) == true)
			return true;
        else
			return false;
	}


function isEmailVal(s)
    {
		var re;
       re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;
	   if (re.test(s) == true)
			return true;
        else
			return false;
	}

/****************************************************************/

/* Checks to see if a required date is Valid.*/

   function isDate(objField)
    {
        var re;
        // The format of the date is:
        // dd/mm/yyyy
        // The year must comprise of any 4 digits.
        re = /^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/\d{4}/;
        if (re.test(objField.value) == true)
            return true;
        else
			return false;    
	}

/****************************************************************/

/****************************************************************/

// Checks to see if the objField is Numeric or Not.

   function isNumeric(objField)
    {
        re = /^[^0-9]/;
        if (re.test(objField.value) == true)
			return true;    		
		else
            return false;
    }

/****************************************************************/

//Rajesh End of My Vlidation


	// This file contains the data validation JavaScript functions
	// It is included in the HTML pages with forms that need these
	// data validation routines.


// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";



/****************************************************************/

// PURPOSE:  Check to see if the string passed in is a valid time.
//	A valid time is defined as a string which is postfixed with either
//  "PM" or "AM".  Next it checks to see if there is a colon in the
//  string.  If there is, it makes sure that at least one digit preceeds
//  it and two proceed it.

	function IsTime(strTime)
	{
		var strTestTime = new String(strTime);
		strTestTime.toUpperCase();

		var bolTime = false;

		if (strTestTime.indexOf("PM",1) != -1 || strTestTime.indexOf("AM",1))
			bolTime = true;

		if (bolTime && strTestTime.indexOf(":",0) == 0)
			bolTime = false;

		var nColonPlace = strTestTime.indexOf(":",1);
		if (bolTime && ((parseInt(nColonPlace) + 5) < (strTestTime.length - 1) || (parseInt(nColonPlace) + 4) > (strTestTime.length - 1)))
			bolTime = false;


		return bolTime;
	}

/****************************************************************/

function replaceAll (s, fromStr, toStr)
{
	var new_s = s;
	for (i = 0; i < 100 && new_s.indexOf (fromStr) != -1; i++)
	{
		new_s = new_s.replace (fromStr, toStr);
	}
	return new_s;
}

/****************************************************************/

/* PURPOSE:  Since we are using the single tick mark as the
	string delimiter to construct our SQL queries, a string with
	a tick mark in it will cause a SQL error.  Therefore we replace
	all "'" with "''", which eliminates the possibility of a SQL error.
*/

function sqlSafe (s)
{
	var new_s = s;
	new_s = replaceAll (new_s, "'", "|");
	new_s = replaceAll (new_s, "|", "''");
	new_s = replaceAll (new_s, "\"", "|");
	new_s = replaceAll (new_s, "|", "''");
	return new_s;
}

/****************************************************************/

function makeSafe (i)
{
	i.value = sqlSafe (i.value);
}

/****************************************************************/

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

/****************************************************************/

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}


/****************************************************************/

// Checks to see if a required field is blank.  If it is, a warning
// message is displayed...

function ForceEntry(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isWhitespace(strField)) {
		alert("You need to enter information for " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}
		
/****************************************************************/

// Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message

function ForceNumber(objField)
{
	var strField = new String(objField.value);

	if (isWhitespace(strField)) return true;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			return false;
		}

	return true;
}

/****************************************************************/

// Rajesh Ghosh Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message

function CharCheck(objField)
{
	var strField = new String(objField.value);
	
	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) >= '0' && strField.charAt(i) <= '9') {
			return false;
		}

	return true;
}
/****************************************************************/
// Returns true if the string passed in is a valid money
//  (no alpha characters except a decimal place), 
//   else it displays an error message

function ForceMoney(objField)
{
	var strField = new String(objField.value);
	
	if (isWhitespace(strField)) return true;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')) {
			return false;
		}

	return true;
}


/****************************************************************/

// Right trims the string...  Useful for SQL datatypes of CHAR

function RTrim(strTrim)
{
	var str = new String(strTrim);
	var i = 0;
	var c = "";
	var endpos = 0

	for (i = str.length; i >= 0 && endpos == 0; i = i - 1) {
		c = str.charAt(i);
		if (whitespace.indexOf(c) == -1)
			endpos = i;
	}

	return str.substring(0,endpos+1);
}

/****************************************************************/

/* PURPOSE:  Returns true if the string is a valid date number.
	A method is passed in (1 = month, 2 = day).  If the string is
	nonnumeric, false is passed back.  If the day in the date string
	is greater than 31, false is returned.  If the month is greater
	than 12, an error is returned.
*/

function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 2)
		if (parseInt(str) > 31)
			return false;
	if (method == 1)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}

/****************************************************************/

// Displays an alert box with the passed in string...

function PromptErrorMsg(Field,strError)
{
	alert("You have entered an invalid date for " + strError + ".  Please make sure your date format is in M/D/Y format.");
	Field.focus();
}

/****************************************************************/

/* PURPOSE: Checks to see if the string is a valid date.  A valid
	date is defined as any of the following:

		MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
		MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
*/

function ForceDate(strDate,strField)
{
	var str = new String(strDate.value);

	if (isWhitespace(str)) {
		return true;
		// if the field is empty, just return true...
	}

	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	return true;
}

/****************************************************************/

// This function determines if the string passed in is a valid
// US zip code.  It accepts either ##### or #####-####.  If the
// string is valid, it returns true, else false.

function isZipcode(strZip)
{
	var s = new String(strZip);

	if (s.length != 5 && s.length != 10)
		// inappropriate length
		return false;


	for (var i=0; i < s.length; i++)
		if ((s.charAt(i) < '0' || s.charAt(s) > '9') && s.charAt(i) != '-')
			return false;

	return true;
}

/****************************************************************/

// This function ensures that a field is less than or equal to the
// Length passed in.  You must call this function with the element
// name in your form (for example: "ForceLength(document.forms[0].txtElement)"
// as opposed to "ForceLength(document.forms[0].txtElement.value)"
// If the field's value is too large, an error message is displayed
// and false is returned, else true is returned.

function ForceLength(objField, nLength, strWarning)
{
	var strField = new String(objField.value);

	if (strField.length > nLength) {
		alert(strWarning);
		return false;
	} else
		return true;
}


// Get checked value from radio button.

function getRadioButtonValue (radio)
{   for (var i = 0; i < radio.length; i++)
    {   if (radio[i].checked) { break }
    }
    return radio[i].value;
}


function chkMephone(objField)
	{
		var strField = new String(objField);
		 
		var i = 0;
		 
		if ( strField.length !=12 ){
			return false ;
		} 
		for (i = 0; i < strField.length; i++ )
		{
			if ( i == 0 )
			{
				if (whitespace.indexOf(strField.charAt(i)) != -1)
					{
						return false;
					}
			}

			if ( strField.charAt(i) < '0' || strField.charAt(i) > '9')
			{		
					 
					if (strField.charAt(i) == '-'   )
					{
						if (  i !=3 &&  i != 7 ) {
																
							return false;
						}
					}
 
			}
		}		

		return true;
	}


/****************************************************************/
/****************************************************************/
// CHEKING FOR A-Z ,a-z ,0-9, or space



function isSpecial(str)
// returns true if str is alphabetic
// that is only A-Z a-z or space
// returns false otherwise
// returns false if empty
{
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if (  ('A'<=ch && ch<='Z')
        ||('a'<=ch && ch<='z')
        ||(ch==" ")||(ch > '0' && ch < '9')
          )
      p++;
    else
      ok= false;
  }
  return ok;
}
function hasNumber(id,fldname)
	{
	
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
	
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			           //alert("Invalid Character(s)\n\nOnly Characters (a-z) Are Allowed In "+fldname); 
 					   //id.focus();
					   return false; 
       					} 
			}
		}

	}
function hasSemi(id,fldname)
	{
	
	var str=";"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
	
			{
				 if (str.indexOf(id.charAt(i)) != -1) 
				       { 
			             return false; 
       					} 
			}
		}

	}	
function onlyNumber(id,fldname)
	{
	
	var str="0123456789"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
	
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			       	   return false; 
       					} 
			}
		}

	}	
	function hasAlphaNumDash(id,fldname)
	{
	
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			           //alert("Invalid Character(s)\n\nOnly Characters (a-z)(0-9)(-) Are Allowed In "+fldname); 
 					   //id.focus();
					   return false; 
       				   } 
			}
		}
		return true;

	}

/**********************************************************************




************************************************************************/

function hasAlphaNum(id,fldname)
	{
	
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			           //alert("Invalid Character(s)\n\nOnly Characters (a-z)(0-9)Are Allowed In "+fldname); 
 					   //id.focus();
					   return false; 
       				   } 
			}
		}
		return true;

	}


/******************************************************************************************




*******************************************************************************************/
function hasAlphaNumBracket(id,fldname)
	{
	
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[]-"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			           //alert("Invalid Character(s)\n\nOnly Characters (a-z)(0-9) [] - Are Allowed In "+fldname); 
 					   //id.focus();
					   return false; 
       				   } 
			}
		}
		return true;

	}





/************************************************************
Functionh isNumberKey(evt)
called on :- onkeypress
pasing parameter :- event
description :- It checkes the key code if it is other than nuber return flase
CHECKING FOR :-   0-9 and -
************************************************************/
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	{
		return false;
	}
	return true;
}


/**************************************************************
Functionh hasNumDash(id,fldname)
called on :- on function call
pasing parameter :- id,fldname
					id -->  
					fldname --> Fieldname
description :- It checks whether id has only numbers and dash.
****************************************************************/
function hasNumDash(id,fldname)
{
	var str="0123456789-."; 
	var i=0; 
	id=id.replace(/(\s+)$/,""); 
	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
	for(i=0;i<id.length;i++)
	{
		if(id.charAt(i)!=' ') 
		{ 
			if (str.indexOf(id.charAt(i)) == -1) 
			{ 
				//alert("Invalid Character(s)\n\nOnly Characters (0-9)(-) Are Allowed In "+fldname); 
 				//id.focus();
				return false; 
       		} 
		}
	}
	return true;
}
function hasNumRs(id,fldname)
{
	var str="0123456789."; 
	var i=0; 
	id=id.replace(/(\s+)$/,""); 
	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
	for(i=0;i<id.length;i++)
	{
		if(id.charAt(i)!=' ') 
		{ 
			if (str.indexOf(id.charAt(i)) == -1) 
			{ 
				//alert("Invalid Character(s)\n\nOnly Characters (0-9)(-) Are Allowed In "+fldname); 
 				//id.focus();
				return false; 
       		} 
		}
	}
	return true;
}


/**************************************************************
Functionh isWebsite(id,fldname)
called on :- on function call
pasing parameter :- id,fldname
					id -->  
					fldname --> Fieldname
description :- It checks whether id is valid website name or not.
****************************************************************/
function isWebsite(id,fldname)
{
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.:/-"; 
	var i=0; 
	id=id.replace(/(\s+)$/,""); 
	id=id.replace(/^(\s+)/,""); 
	//	var temp_value=id.value;
	for(i=0;i<id.length;i++)
	{
		if(id.charAt(i)!=' ') 
		{ 
			if (str.indexOf(id.charAt(i)) == -1) 
			{ 
				//alert("Invalid Character(s)\n\nOnly Characters (0-9)(-) Are Allowed In "+fldname); 
 				//id.focus();
				return false; 
       		} 
		}
	}
	return true;
}

/**************************************************************
Functionh isValidWebName(id,fldname)
called on :- on function call
pasing parameter :- id,fldname
					id -->  
					fldname --> Fieldname
description :- It checks whether id is valid website name or not.
****************************************************************/

function isValidWebName(id, fldname)
{
	var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;

	if (urlRegxp.test(id) != true)
	{
		 //alert("URL appears to be incorrect In" + fldname);
		 return false;
	}
	return true;

}


function isAlphaNumSpecialchar(id, fldname)
{
	
	var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-'"; 

	var i=0; 

	id=id.replace(/(\s+)$/,""); 

	id=id.replace(/^(\s+)/,""); 
//	var temp_value=id.value;
		for(i=0;i<id.length;i++)
		{
			if(id.charAt(i)!=' ') 
			{ 
				 if (str.indexOf(id.charAt(i)) == -1) 
				       { 
			           //alert("Invalid Character(s)\n\nOnly Characters (a-z)(0-9)Are Allowed In "+fldname); 
 					   //id.focus();
					   return false; 
       				   } 
			}
		}
		return true;

	}

	function validate(strPath) {
		postcode = document.home.p_code.value;
		if (postcode == '') { 	
			alert ("Please enter postcode");
			document.getElementById('p_code').focus();
			return false;
		}
		pstr = postit(postcode);
		if (pstr != 'OK') {
			alert(pstr);
			document.getElementById('p_code').focus();
			return false;
		}
		var jTopicType = document.getElementById('j_topic_type').value;
		var jTopicId = trim(document.getElementById('j_topic_id').value);
		if(jTopicType!='-0'){
			 if (jTopicId =='') {
				alert ('Please enter value in the textfield.') ; 
				document.getElementById('j_topic_id').focus();
				return false;
			 }
			 if (jTopicType == '0') {
				if (acceptNumber(jTopicId)) {
					return true;
				} else {
					alert ('Only number (0-9) are allowed.') ; 
					return false;
				}
			 }
			 // END for topic
			 // START for channel
			 if (jTopicType == '1') {
				if (acceptNumberAndHypen(jTopicId)) {
					return true;
				} else {
					alert ('Only number (0-9) and hypen are allowed (i.e, 2909-Z02, profile_id-topic_id).') ; 
					return false;
				}
			 }
		
			document.home.action = strPath+"/jump_to_content/jump_to_content.php";
			document.home.submit();

		}		
		
		return true;
	}

function postit(pcode)
{ //check postcode format is valid
		test = pcode; 
		size = test.length
		test = test.toUpperCase(); //Change to uppercase
		while (test.slice(0,1) == " ") //Strip leading spaces
		{
			test = test.substr(1,size-1);size = test.length
		}
		while(test.slice(size-1,size)== " ") //Strip trailing spaces
		{
			test = test.substr(0,size-1);size = test.length
		}

		pstr = "OK";
		pcode = test; //write back to form field
		if ((size<6) || (size>8)){ //Code length rule
			//pstr = test + " is not a valid postcode - wrong length. \n(example: XXXX XXX or XXX XXX)";
			 pstr = "The postcode you entered was not recognized. Please use the format XXXX XXX or XXX XXX. Thankyou.";
			return pstr;
		// return false;
		}
		if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
		pstr = test + " is not a valid postcode - cannot start with a number";
		return pstr;

		}
		if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
		pstr = test + " is not a valid postcode - alpha character in wrong position";
		return pstr;

		}
		if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
		pstr = test + " is not a valid postcode - number in wrong position";
		return pstr;

		}
		if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
		pstr = test + " is not a valid postcode - number in wrong position";
		return pstr;
		}
		if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
		pstr = test + " is not a valid postcode - no space or space in wrong position";
		return pstr;
		}
		count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
		if (count1 != count2){//only one space rule
		pstr = test + " is not a valid postcode - only one space allowed";
		return pstr;
		}
		return pstr;
		
}
function showhidescroll(){
	jQuery("html").css("overflow","hidden");  
	jQuery("#TB_window").addClass("noredbdr");

	//jQuery("#TB_window").css("border","4px solid black");  
	
}

function showscroll(){
	jQuery("html").css("overflow","hidden");  
}

function comingSoonMsg(){
	alert("This feature is coming soon");
	
}
