/*function translator(pattern) {
	var open_in_same_window = 1;
	var my_location = unescape(document.location.toString());
	var new_location ='';
	var new_pattern = '';
	if (my_location.indexOf('translate_c?') != -1) {
		/// From google...
		var indexof_u = my_location.indexOf('u=');
		if (indexof_u == -1) {
			new_location = document.location;
		}
		else {
			var subs = my_location.substring(indexof_u, my_location.length);
			var ss = subs.split('&');
			new_location = ss[0].substring(2, ss[0].length);
		}
	}
	else {
		new_location = document.location;
	}

	indexof_p = pattern.indexOf('|');

	var isen = '';
	if (indexof_p == -1) {
		indexof_p1 = pattern.indexOf('><');
		if (indexof_p1 == -1) {
			new_pattern = pattern;
			if (pattern == 'en') {
				isen = 1;
			}
		}
		else {
			var psplit =pattern.split('><');
			new_pattern = psplit[0]+'|'+psplit[1];
			if (psplit[1] == 'en') {
				isen = 1;
			}
		}
	}
	else {
		var psplit = pattern.split('|');
		new_pattern = psplit[0]+'|'+psplit[1];
		if (psplit[1] == 'en') {
			isen = 1;
		}
	}

	var thisurl = '';
	if (isen == 1) {
		thisurl = new_location;
	}
	else {
		thisurl = 'http://translate.google.com/translate_c?langpair=' + new_pattern + "&u=" + new_location;
	}

	if (open_in_same_window == 1) {
		window.location.href = thisurl;
	}
	else {
		if (CanAnimate ){
			msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
			msgWindow.focus();
			msgWindow.location.href = thisurl;
		}
		else {
			msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
		}
	}
}*/
function translator(pattern) {
	var open_in_same_window = 1;
	var my_location = unescape(document.location.toString());
	var new_location ='';
	var new_pattern = '';
	if (my_location.indexOf('translate_url_content?') != -1) {
		/// From google...
		var indexof_u = my_location.indexOf('trurl=');
		if (indexof_u == -1) {
			new_location = document.location;
		}
		else {
			var subs = my_location.substring(indexof_u, my_location.length);
			var ss = subs.split('&');
			new_location = ss[0].substring(2, ss[0].length);
			
			var indexof_url = new_location.indexOf('=url=');
			new_location=new_location.substring(indexof_url+5, new_location.length);
		}
	}
	else {
		new_location = document.location;
	}

	indexof_p = pattern.indexOf('|');

	var isen = '';
	if (indexof_p == -1) {
		indexof_p1 = pattern.indexOf('><');
		if (indexof_p1 == -1) {
			new_pattern = pattern;
			if (pattern == 'en') {
				isen = 1;
			}
		}
		else {
			var psplit =pattern.split('><');
			new_pattern = psplit[0]+'|'+psplit[1];
			if (psplit[1] == 'en') {
				isen = 1;
			}
		}
	}
	else {
		var psplit = pattern.split('|');
		new_pattern = psplit[0]+'|'+psplit[1];
		if (psplit[1] == 'en') {
			isen = 1;
		}
	}

	var thisurl = '';
	if (isen == 1) {
		thisurl = new_location;
	}
	else {
		//http://translate.google.com/translate?u=http%3A%2F%2Fwww.rediff.com&langpair=en%7Ces&hl=en&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools
		//thisurl = 'http://translate.google.com/translate?hl='+psplit[0]+'&ie=UTF-8&oe=UTF-8&langpair='+psplit[0]+'%7C'+psplit[1]+'&u='+ new_location+'&prev=%2Flanguage_tools';
		thisurl = 'http://74.6.146.244/babelfish/translate_url_content?trurl='+new_location+'&lp='+psplit[0]+'_'+psplit[1];
	}

	if (open_in_same_window == 1) {
		window.location.href = thisurl;
	}
	else {
		if (CanAnimate ){
			msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
			msgWindow.focus();
			msgWindow.location.href = thisurl;
		}
		else {
			msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
		}
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
function chkdelete(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].checked == 1){
			c = 1;
		}
	}
	if(c == 0){
		alert('First select a record to delete.');
		return false;
	}
	if(c!=0){
		 return confirm('Are you sure you want to delete ....');
	}
}




function chkactive(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].checked == 1){
			c = 1;
		}
	}
	if(c == 0){
		alert('First select a record to activate.');
		return false;
	}
	if(c!=0){
		 return confirm('Are you sure you want to activate ....');
	}
}

function chkdeactive(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].checked == 1){
			c = 1;
		}
	}
	if(c == 0){
		alert('First select a record to deactivate.');
		return false;
	}
	if(c!=0){
		 return confirm('Are you sure you want to deactivate ....');
	}
}


function CheckAll(){
	var frm=document.formn;
	var count = frm.elements.length;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 0){
				frm.elements[i].checked = 1;
				document.formn.checkall.value="Uncheck All";
				document.formn.chk.checked=1;
			} else {
				frm.elements[i].checked = 0;
				document.formn.checkall.value="Check All";
				document.formn.chk.checked=0;
			}
		}
	}
	
}
function CheckAllfield(frm,fld){
	
	var count = frm.elements.length;
		for (var i=0; i < count; i++){
		
		if(frm.elements[i].type=="checkbox"){			
			if(frm.elements[i].checked == false){				
				frm.elements[i].checked = true;				
				frm.checkall.value="Uncheck All";
				document.formn.chk.checked=1;
			} else {
				frm.elements[i].checked = false;
				frm.checkall.value="Check All";	
				document.formn.chk.checked=0;
			}
		}
	}
	
}

function chkdeletefield(frm){
	//var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].checked == 1){
			c = 1;
		}
	}
	if(c == 0){
		alert('First select a record to delete.');
		return false;
	}
	if(c!=0){
		 return confirm('Are you sure you want to delete ....');
	}
}

function chkalert(frm){
	//var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].checked == 1){
			c = 1;
		}
	}
	if(c == 0){
		alert('First select a record.');
		return false;
	}
	if(c!=0){
		 return confirm('Are you sure you want to Apply ....');
	}
}
function chkactivate(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(c == 0){
		alert('First select a record to activate.');
		return false;
	}
}

function chkdeactivate(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	   if(c == 0){
		alert('First select a record to unactivate.');
		return false;
	}
}
function chksendmail(){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	count = document.formn.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(document.formn.elements[i].checked == 1){
			c = 1;
		}
		
	}
	if(c == 0){
		alert('First, select the record');
		return false;
	}
	else{
		
		if(document.formn.subject.value == ""){
				alert('Please enter subject.');
				document.formn.subject.focus();
				return false;
		}
		/*if(document.formn.message.value == ""){
				alert('Please enter your message.');
				document.formn.message.focus();
				return false;
		}*/
	}
}	
function chksendmail2(){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	count = document.form2.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(document.form2.elements[i].checked == 1){
			c = 1;
		}
		
	}
	if(c == 0){
		alert('First, select the record');
		return false;
	}
	else{
		
		if(document.form2.subject.value == ""){
				alert('Please enter subject.');
				document.form2.subject.focus();
				return false;
		}
		/*if(document.formn.message.value == ""){
				alert('Please enter your message.');
				document.formn.message.focus();
				return false;
		}*/
	}
}	
function sendmail(f1){
	if(document.formn.subject.value == ""){
				alert('Please enter subject.');
				document.formn.subject.focus();
				return false;
		}
		if(document.formn.message.value == ""){
				alert('Please enter your message.');
				return false;
		}

}

function validate_member(f1){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!f1.firstName.value.length) {
	   alert("You Must Enter Your First Name");
	   f1.firstName.focus();
	   return false;
	}
	if (!f1.lastName.value.length) {
	   alert("You Must Enter Your Last Name");
	   f1.lastName.focus();
	   return false;
	}
	if (!f1.dob.value.length) {
	   alert("You Must Enter Your Date Of Birth");
	   f1.dob.focus();
	   return false;
	}
	if (!f1.email.value.length) {
	   alert("You Must Enter Your Email-id");
	   f1.email.focus();
	   return false;
	}
	if (!re_mail.test(f1.email.value))	{
			alert( "Enter Your Email-id correctly" );
			f1.email.focus();
			return false;
	}
	if(f1.member_id.value=="" || f1.admin.value!=""){
		if (!f1.pwd.value.length) {
		   alert("Please Specify the Password");
		   f1.pwd.focus();
		   return false;
		}
		if (!f1.cpwd.value.length) {
			   alert("Please Re-confirm Password");
			   f1.cpwd.focus();
			   return false;
		}
		if (f1.pwd.value != f1.cpwd.value) {
		  alert("Password and Re-entered passwords should be same");
		  f1.cpwd.focus();
		  return false;
	   }
	}
	if (!f1.streetB.value.length) {
	   alert("You Must Enter Your Billing Street Address");
	   f1.streetB.focus();
	   return false;
	}
	if (!f1.postcodeB.value.length) {
		   alert("You Must Enter Your Postcode");
		   f1.postcodeB.focus();
		   return false;
	}
	if (isNaN(f1.postcodeB.value)) {
		   alert("Postcode must be numeric");
		   f1.postcodeB.focus();
		   return false;
	}

	if (!f1.cityB.value.length) {
	   alert("You Must Enter Your City");
	   f1.cityB.focus();
	   return false;
	}
	if (!f1.stateB.value.length) {
		alert("Please enter your state");
	    f1.stateB.focus();
	    return false;
	}
	if (f1.countryB.options[f1.countryB.selectedIndex].value == 'x') {
	   alert("Please select your country");
	   f1.countryB.focus();
	   return false;
	}
	if (!f1.streetS.value.length) {
	   alert("You Must Enter Your Shipping Street Address");
	   f1.streetS.focus();
	   return false;
	}
	if (!f1.postcodeS.value.length) {
		   alert("You Must Enter Your Postcode");
		   f1.postcodeS.focus();
		   return false;
	}
	if (isNaN(f1.postcodeS.value)) {
		   alert("Postcode must be numeric");
		   f1.postcodeS.focus();
		   return false;
	}

	if (!f1.cityS.value.length) {
	   alert("You Must Enter Your City");
	   f1.cityS.focus();
	   return false;
	}
	if (!f1.stateS.value.length) {
		alert("Please enter your state");
	    f1.stateS.focus();
	    return false;
	}
	if (f1.countryS.options[f1.countryS.selectedIndex].value == 'x') {
	   alert("Please select your country");
	   f1.countryS.focus();
	   return false;
	}
	
	if(f1.phone.value=='') {
			alert("Please enter phone number.");
			f1.phone.focus();
	        return false;
	}
	var re2 = /^[0-9 _-]+$/;
	if (!re2.test(f1.phone.value)) {
	   alert("Phone no. can be numeric or - only");
	   f1.phone.focus();
	   return false;
	}
	
}

function chk_cat(f1){
	if(f1.cat_name.value == ""){
		alert('Please enter category name.');
		f1.cat_name.focus();
		return false;
	}

}
function chk_product(f1){
	if(f1.product_name.value == ""){
		alert('Please enter product name.');
		f1.product_name.focus();
		return false;
	}
	if(f1.product_code.value == ""){
		alert('Please enter product code.');
		f1.product_code.focus();
		return false;
	}
	if(f1.product_price.value == ""){
		alert('Please enter product price.');
		f1.product_price.focus();
		return false;
	}

}
function CheckAllCart(){
	var frm=document.cart;
	var count = frm.elements.length;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 0){
				frm.elements[i].checked = 1;
				document.cart.chk.checked=1;
			} else {
				frm.elements[i].checked = 0;
				document.cart.chk.checked=0;
			}
		}
	}
	
}
function filldata(){

  var f1=document.memfrm;
  if(f1.chk.checked==1){
	  f1.streetS.value=f1.streetB.value;
	  f1.postcodeS.value=f1.postcodeB.value;
	  f1.cityS.value=f1.cityB.value;
	  f1.stateS.value=f1.stateB.value;
	  f1.countryS.value=f1.countryB.options[f1.countryB.selectedIndex].value;
  }else{
	  f1.streetS.value="";
	  f1.postcodeS.value="";
	  f1.cityS.value="";
	  f1.stateS.value="";
	  f1.countryS.value="x";

  }
}
function validate_password(f1){
	if (!f1.existing.value.length) {
		   alert("Please Specify Old Password");
		   f1.existing.focus();
		   return false;
	}
	if (!f1.newp.value.length) {
		   alert("Please Specify New Password");
		   f1.newp.focus();
		   return false;
	}
	if (!f1.confirm.value.length) {
		alert("Please Confirm Password");
		f1.confirm.focus();
		return false;
	}
	if (f1.newp.value != f1.confirm.value) {
	  alert("New Password and Confirm passwords should be same");
	  f1.newp.focus();
	  return false;
   }

}
function validate_friend(f1){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!f1.your_name.value.length) {
		   alert("You Must Enter Your Name");
		   f1.your_name.focus();
		   return false;
	}
	if (!f1.your_email.value.length) {
		   alert("You Must Enter Your Email-id");
		   f1.your_email.focus();
		   return false;
	}
	if (!re_mail.test(f1.your_email.value))	{
				alert( "Enter Your Email-id correctly" );
				f1.your_email.focus();
				return false;
	}
	if (!f1.friend_name.value.length) {
		   alert("You Must Enter Your Friend Name");
		   f1.friend_name.focus();
		   return false;
	}

	if (!f1.friend_email.value.length) {
		   alert("You Must Enter Your Friend Email-id");
		   f1.friend_email.focus();
		   return false;
	}
	if (!re_mail.test(f1.friend_email.value))	{
				alert( "Enter Your Friend  Email-id correctly" );
				f1.friend_email.focus();
				return false;
	}

}
function validate_newsletter(f1){
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!f1.Email.value.length) {
		   alert("You Must Enter Your Email-id");
		   f1.Email.focus();
		   return false;
	}
	if (!re_mail.test(f1.Email.value))	{
				alert( "Enter Your Email-id correctly" );
				f1.Email.focus();
				return false;
	}
}
function chkstatus(){
	var frm=document.formn;
	count = frm.elements.length;
	var c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(c == 0){
		alert('First select a record to change status.');
		return false;
	}
}

function changeClass(row, classIs)
{
		row.className=classIs;
}



function makeItBlank(obj,valueToMatch,replaceWith){
	if(obj.value==valueToMatch)
		obj.value=replaceWith;
}

function showPasswordBlock(checkboxObj,checkCondition,targetObj){
	targetObject=document.getElementById(targetObj);
	if(checkboxObj.checked==checkCondition)
	{
		//alert('yes');
		targetObject.style.display='block';
	}
	else
		targetObject.style.display='none';
}

