String.prototype.trim = function()  {
    // skip leading and trailing whitespace and return everything in between
    return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
}

function _add() {
   	var f = $('frmMain');
    var pga = f['hdnPgaction'];
    $(pga).value = 'add';
	f.submit();
}

function _edit(fld,id) {
   	var f = $('frmMain');
    var pga = f['hdnPgaction'];
    $(pga).value = 'edit';
    var fid = f[fld];
    $(fid).value = id;
	f.submit();
}

function _delete(fld,id) {
	if(confirm('Are you sure to remove this record?')) {
        var f = $('frmMain');
        var pga = f['hdnPgaction'];
        $(pga).value = 'delete';
        var fid = f[fld];
		$(fid).value = id;
		f.submit();
    }
}


function _cancel(page_name,hdnPageNo) {
	//alert(hdnPageNo);
	if(hdnPageNo == '') {
		hdnPageNo = 1;
	}
	var redirect = page_name + "?hdnPageNo=" + hdnPageNo;
	location.href = redirect;
}


function Change_Status(fld,id,status_action) {
	var st = confirm('Want to change status !!');
	if(st) {
		var f = $('frmMain');
		var pga = f['hdnPgaction'];
		$(pga).value = 'change_status';
		var fid = f['fld'];
		$(fid).value = fld;
		var hid = f['hdn_fld_id'];
		$(hid).value = id;
		var s_action  = f['status_action'];
		$(s_action).value = status_action;
		f.submit();
		return true;
	}
}



function emailCheck(entry) {
    if ( (/^[a-zA-Z0-9-._]+(@[a-zA-Z0-9-.]{1,}[a-zA-Z0-9_.-]+\.)+[a-zA-Z]{2,4}$/).exec(entry) == null) {
        return false;
    }
    return true;
}


function Bulk_Delete(frmMain,chk_deleted_ids) {
	var str = "";
	var flag = 0;
	var len = document.frmMain.chk_deleted_ids.length;
	if(len >0) {
		for(i=0;i<len;i++) {
			if(document.frmMain.chk_deleted_ids[i].checked==true) {
				str+=document.frmMain.chk_deleted_ids[i].value+",";
				flag = 1;
			}
		}
	}
	else {
		if(document.frmMain.chk_deleted_ids.checked==true) {
				str+=document.frmMain.chk_deleted_ids.value+",";
				flag = 1;
		}
	}
	if(flag == 0) {
		alert("please select atleast one record");
		return false;
	}
	
	else {

		if(confirm("Are you sure to remove these records?")){
		var f = $('frmMain');
		var pga = f['hdnPgaction'];
		$(pga).value = 'delete_selected';
		var del_sel_records = f['del_selected_records'];
		$(del_sel_records).value = str;
		return true;
		}
	}
}
// end of Bulk_Delete


function arrange_order(orderbyfld,orderby) {
	var f = $('frmMain');
	var obyfld = f['hdnOrderbyFieldname'];
	$(obyfld).value = orderbyfld;
	var oby = f['hdnOrderby'];
	$(oby).value = orderby;
	f.submit();
}

// end of arrange_order
var isChecked = false;
function checkAll(frmMain) {
	var check;
	check=false;
	if (isChecked) {
		isChecked = false;
		check = false;
	} else {
		isChecked = true;
		check = true;
	}		
	for(var i=0;i<=frmMain.elements.length-1;i++) {
		if (check) { 
			document.frmMain.elements[i].checked=true;
		} else {
			document.frmMain.elements[i].checked=false;
		}
	}
} 
// end of checkAll

function Page_submit(){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = 'page_submit';
    return true;
}

// Check function start 

function CheckNumeric(e) {   
    var key = (window.event) ? event.keyCode : e.which;   
	if (window.event)     
	    key = event.keyCode   
	else     key = e.which   // Was key that was pressed a numeric character (0-9) or backspace (8)?   
	if ( key > 47 && key < 58 || key == 8 )    
	 return; // if so, do nothing   
	else // otherwise, discard character     
	if (window.event) //IE      
	// window.event.returnValue = null;    
	window.event.keyCode=0;
	  else //Firefox       
	  e.preventDefault(); 
}

function CheckNumericPrice(e) {   
    var key = (window.event) ? event.keyCode : e.which;   
	//alert(key);
	if (window.event)     
	    key = event.keyCode   
	else     key = e.which   // Was key that was pressed a numeric character (0-9) or backspace (8)?   46==>.
	if ( key > 47 && key < 58 || key == 8 || key == 46)    
	 return; // if so, do nothing   
	else // otherwise, discard character     
	if (window.event) //IE      
	// window.event.returnValue = null;    
	window.event.keyCode=0;
	  else //Firefox       
	  e.preventDefault(); 
}

function chkLogin() {
    var f = $('login_frm');
    var username = f['txt_username'];
    var pass = f['txt_password'];
	if ($F(username).search(/\S/) == -1) {
		alert('Please enter your user name');
		$(username).focus();
		return false;
	}
	if ($F(pass).search(/\S/) == -1) {
		alert('Please enter your password');
		$(pass).focus();
		return false;
	}
	return true;
}
// end of chkLogin



function Admin_Change_Password_Check(action) {
	//alert("HEllo");
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	var current_pass = f['current_password'];
	var new_pass = f['new_password'];
	var con_new_pass = f['con_new_password'];
	
	if ($F(current_pass).search(/\S/) == -1) {
		alert('Please enter your current password');
		$(current_pass).focus();
		return false;
	}
	if ($F(new_pass).search(/\S/) == -1) {
		alert('Please enter your new password');
		$(new_pass).focus();
		return false;
	}
	if ($F(con_new_pass).search(/\S/) == -1) {
		alert('Please enter your confirm new password');
		$(con_new_pass).focus();
		return false;
	}
	if ($F(new_pass) != $F(con_new_pass)) {
		alert('New Password and confirm password mismatch');
		$(con_new_pass).focus();
		return false;
	}
	$(pga).value = action;
    return true;
}
// end of Admin_Change_Password_Check

// cms_check function start 
function cms_check(action) {
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	var title = f['cms_title'];
	var content = f['cms_content'];

	if ($F(title).search(/\S/) == -1) {
		alert('Please Enter Title');
		$(title).focus();
		return false;
	}
	
	var oEditor_content = FCKeditorAPI.GetInstance('cms_content') ;
    var content = oEditor_content.GetXHTML( true ) ;
	if(content=="") {
       alert('Please Enter Content');
		return false;
	}
	
	$(pga).value = action;
    return true;
}
// cms_check function end



// _cancel function start 
function _cancel(page_name,hdnPageNo) {
	//alert(hdnPageNo);
	if(hdnPageNo == '') {
		hdnPageNo = 1;
	}
	var redirect = page_name + "?hdnPageNo=" + hdnPageNo;
	location.href = redirect;
}
// _cancel function end



/*function contactus_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	var name = f['name'];
	if($F(name).search(/\S/)==-1) {
		alert('Please enter name');
		$(name).focus();
		return false;
	}
	var email = f['email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	var message = f['message'];
	if($F(message).search(/\S/)==-1) {
		alert('Please enter message');
		$(message).focus();
		return false;
	}
	return true;

}*/


function contactus_check(action)
 {
   var first_name = document.getElementById('first_name').value;
   var last_name = document.getElementById('last_name').value;
   var year = document.getElementById('year').value;
   var email = document.getElementById('email').value;
   var country = document.getElementById('country').value;
   var state = document.getElementById('state').value;
   var message = document.getElementById('message').value;
   document.getElementById('hdnPgaction').value = action;
   
   if(first_name == "")
    {
	  alert('First Name can not be left blank.');
	  document.getElementById('first_name').focus();
	  return false;
	}
   if(last_name == "")
	{
	  alert('Last Name can not be left blank.');
	  document.getElementById('last_name').focus();
	  return false;
	}
   myOption = -1;
   for(i=document.frmMain.gender.length-1; i > -1; i--) 
	{
     if(document.frmMain.gender[i].checked)
	  {
        myOption = i; i = -1;
      }
    }
   if(myOption == -1)
	{
       alert("You must select your gender.");
       return false;
    }	
   if(year == "")
	{
	  alert('Year can not be left blank.');
	  document.getElementById('year').focus();
	  return false;
	}
   if(email == "")
	{
	  alert('Email can not be left blank.');
	  document.getElementById('email').focus();
	  return false;
	}
   if(emailCheck(email)==false)
    {
	  alert('Email is not valid');
	  document.getElementById('email').focus();
	  return false;
	}	
   if(country == "")
	{
	  alert('Country Name can not be left blank.');
	  document.getElementById('country').focus();
	  return false;
	}
   if(state == "")
	{
	  alert('State can not be left blank.');
	  document.getElementById('state').focus();
	  return false;
	}
   if(message == "")
	{
	  alert('Questions or Comments  can not be left blank.');
	  document.getElementById('message').focus();
	  return false;
	} 	
   return true;
 }
//ContactUs_Validity_Check


//lost_pw
function lost_pw(action){
	
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	var email = f['user_email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please provide your Email address');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	return true;

}
//lost_pw



function News_Validity_Check(action) {
	//alert("Hello");
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	//var news_cat = f['news_cat'];
	var news_title = f['news_title'];

	/*if ($F(news_cat).search(/\S/) == -1) {
		alert('Please select news category');
		$(news_cat).focus();
		return false;
	}*/

	if ($F(news_title).search(/\S/) == -1) {
		alert('Please enter news title');
		$(news_title).focus();
		return false;
	}
	
	var oEditor = FCKeditorAPI.GetInstance('news_desc') ;
    var content = oEditor.GetXHTML( true ) ;
	if(content=="") {
        alert('Please enter news content');
		//message_content.focus();
        return false;
	}

	$(pga).value = action;
	return true;
	
}
//////end////////////////
function Contactus_Info_Check(action) {
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	
	var contact_name = f['contact_name'];
	var contact_email = f['contact_email'];
	var contact_telephone = f['contact_telephone'];
	var contact_address = f['contact_address_1'];
	if ($F(contact_name).search(/\S/) == -1) {
		alert('Please enter name');
		$(contact_name).focus();
		return false;
	}
	if ($F(contact_email).search(/\S/) == -1) {
		alert('Please enter email');
		$(contact_email).focus();
		return false;
	}
	if(emailCheck($F(contact_email))==false) {
		alert('Please enter valid email');
		$(contact_email).focus();
		return false;
	}
	if ($F(contact_telephone).search(/\S/) == -1) {
		alert('Please enter telephone');
		$(contact_telephone).focus();
		return false;
	}
	if ($F(contact_address).search(/\S/) == -1) {
		alert('Please enter address');
		$(contact_address).focus();
		return false;
	}

	$(pga).value = action;
	 return true;
}
// end of Contactus_Info_Check


// Product_Check function end

function Product_Check(action) {
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	var title = f['product_title'];
	var logo = f['product_logo'];
	
	
	if ($F(title).search(/\S/) == -1) {
		alert('Product title can not be left blank');
		$(title).focus();
		return false;
	}
	
	/*if ($F(price).search(/\S/) == -1) {
		alert('Product price can not be left blank');
		$(price).focus();
		return false;
	}*/
	if(action =='insert'){
		if ($F(logo).search(/\S/) == -1) {
			alert('Product image can not be left blank');
			$(logo).focus();
			return false;
		}
	}
	if (document.frmMain.product_logo.value != '') {
		var p_image = document.frmMain.product_logo.value;
		var image_arr = p_image.split(".");
		var product_image = image_arr[1].toUpperCase();
		if(product_image!="GIF" && product_image!="JPG" && product_image!="JPEG" && product_image!="PNG" && product_image!="BMP"){
			alert("Please upload a .GIF/.JPG/.JPEG/.PNG/.BMP file in Product logo");
			document.frmMain.product_logo.focus();
			return false;
		}
	}
	
	var oEditor = FCKeditorAPI.GetInstance('product_desc') ;
    var content = oEditor.GetXHTML( true ) ;
	if(content=="") {
        alert('Product description can not be left blank');
		//message_content.focus();
        return false;
	}
	
	$(pga).value = action;
    return true;

}
////////////start URL_Validity_Check

function URL_Validity_Check(action) {
	//alert("Hello");
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	var site_title = f['site_title'];
	var site_url = f['site_url'];

	if ($F(site_title).search(/\S/) == -1) {
		alert('Title can not be left blank');
		$(site_title).focus();
		return false;
	}

	if ($F(site_url).search(/\S/) == -1) {
		alert('URL can not be left blank');
		$(site_url).focus();
		return false;
	}
	
	

	$(pga).value = action;
	return true;
	
}
//////end////////////////

function mass_mail() {
	var f = $('frmMain');
    var pga = f['hdnPgaction'];
    $(pga).value = 'mass_mail';
	f.submit();
}

function Select_all() {
	var len = document.frmMain.subscriber.length;
	if(len>0) {
		for(i=0;i<len;i++) {
			document.frmMain.subscriber[i].selected=true;
		}
	}
}

function Deselect_all() {
	var len = document.frmMain.subscriber.length;
	if(len>0) {
		for(i=0;i<len;i++) {
			document.frmMain.subscriber[i].selected=false; 
		}
	}
}
///////////start Mass_Mail_Validity_Check
function Mass_Mail_Validity_Check(action) {
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	var str = "";
	var is_selected = 0;
	var len = document.frmMain.subscriber.length;
	if(len>0) {
		for(i=0;i<len;i++) {
			if(document.frmMain.subscriber[i].selected==true) {
				str+=document.frmMain.subscriber[i].value+",";
				is_selected = 1;
			}
		}
	}
	else {
		if(document.frmMain.subscriber.selected==true) {
				str+=document.frmMain.subscriber.value+",";
				is_selected = 1;
		}
	}
	if(is_selected == 0) {
		alert("Please select atleast one subscriber");
		return false;
	}
	var subject = f['subject'];
	if($F(subject).search(/\S/)==-1) {
		alert('Please enter subject');
		$(subject).focus();
		return false;
	}
	var oEditor = FCKeditorAPI.GetInstance('mail_message') ; // Get the editor instance that we want to interact with
	var test_content = oEditor.GetXHTML( true ) ;
	if(test_content=="") {
		alert("Please enter message");
		return false;
	}
	$(pga).value = action;
	var sel_subscrider = f['sel_subscrider'];
	$(sel_subscrider).value = str;
	return true;
}
// end Mass_Mail_Validity_Check

function subscribe_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	var name = f['name'];
	if($F(name).search(/\S/)==-1) {
		alert('Please enter your name');
		$(name).focus();
		return false;
	}
	var email = f['email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	
	return true;

}

//subscribe_check end

function login_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var email = f['user_email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	var password = f['user_password'];
	if($F(password).search(/\S/)==-1) {
		alert('Please enter your password');
		$(password).focus();
		return false;
	}
	
	return true;

}

//user_check end

function distributor_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var email = f['user_email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	var password = f['user_password'];
	if($F(password).search(/\S/)==-1) {
		alert('Please enter your password');
		$(password).focus();
		return false;
	}
	var con_password = f['con_user_password'];
	if($F(con_password).search(/\S/)==-1) {
		alert('Please enter confirm password');
		$(con_password).focus();
		return false;
	}
	if($F(con_password)!=$F(password)) {
		alert('Password mismatch');
		$(con_password).focus();
		return false;
	}
	
	return true;

}

//user_check end


function upload_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var category = f['category'];
	if($F(category).search(/\S/)==-1) {
		alert('Please select a category');
		$(category).focus();
		return false;
	}
	var type = f['type'];
	if($F(type).search(/\S/)==-1) {
		alert('Please select a product type');
		$(type).focus();
		return false;
	}
	var title = f['title'];
	if($F(title).search(/\S/)==-1) {
		alert('Please enter title');
		$(title).focus();
		return false;
	}
	if($(type).value == 'Sell'){
	var price = f['price'];
	if($F(price).search(/\S/)==-1) {
		alert('Please enter price');
		$(price).focus();
		return false;
	}
	}	
	var upload_type = f['upload_type'];
	if($F(upload_type).search(/\S/)==-1) {
		alert('Please select a upload type');
		$(upload_type).focus();
		return false;
	}
	if (document.frmMain.image.value != ''){
		if($(upload_type).value =='image') {
		var p_image = document.frmMain.image.value;
		var image_arr = p_image.split(".");
		var product_image = image_arr[1].toUpperCase();
		if(product_image!="GIF" && product_image!="JPG" && product_image!="JPEG" && product_image!="PNG" && product_image!="BMP"){
			alert("Please upload a .GIF/.JPG/.JPEG/.PNG/.BMP file in Product Or change the upload type");
			document.frmMain.image.focus();
			return false;
		}
		}
		if($(upload_type).value =='doc') {
		var p_image = document.frmMain.image.value;
		var image_arr = p_image.split(".");
		var product_image = image_arr[1].toUpperCase();
		if(product_image!="doc" && product_image!="DOC"){
			alert("Please upload a .DOC file in Product Or change the upload type");
			document.frmMain.image.focus();
			return false;
		}
		}
		if($(upload_type).value =='mp3') {
		var p_image = document.frmMain.image.value;
		var image_arr = p_image.split(".");
		var product_image = image_arr[1].toUpperCase();
		if(product_image!="mp3" && product_image!="MP3"){
			alert("Please upload a .mp3 file in Product Or change the upload type");
			document.frmMain.image.focus();
			return false;
		}
		}
		if($(upload_type).value =='pdf') {
		var p_image = document.frmMain.image.value;
		var image_arr = p_image.split(".");
		var product_image = image_arr[1].toUpperCase();
		if(product_image!="pdf" && product_image!="PDF"){
			alert("Please upload a .PDF file in Product Or change the upload type");
			document.frmMain.image.focus();
			return false;
		}
		}
	}
	return true;

}

//upload_check end

function customer_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	var name = f['customer_name'];
	if($F(name).search(/\S/)==-1) {
		alert('Please enter your name');
		$(name).focus();
		return false;
	}
	var email = f['customer_email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	var phone = f['customer_phone'];
	if($F(phone).search(/\S/)==-1) {
		alert('Please enter your phone');
		$(phone).focus();
		return false;
	}
	var address = f['customer_address'];
	if($F(address).search(/\S/)==-1) {
		alert('Please enter your address');
		$(address).focus();
		return false;
	}
	return true;

}
//customer_check end

function forgot_pass_check(action){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var email = f['user_email'];
	if($F(email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(email).focus();
		return false;
	}
	if(emailCheck($F(email))==false) {
		alert('Please enter valid email');
		$(email).focus();
		return false;
	}
	
	return true;

}

//forgot_pass_check end


function Category_Check(action){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var name = f['cat_name'];
	if($F(name).search(/\S/)==-1) {
		alert('Category Name can not be left blank');
		$(name).focus();
		return false;
	}
	
	return true;

}

//Category_Check end

function Add_Press_Check(action) {
	//alert("Hello");
	//alert(action);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;

	/*var type1 = f['resource_type1'];
	if($F(type1).search(/\S/)==-1) {
		alert('File type can not be left blank');
		$(type1).focus();
		return false;
	}*/
	if(action =='insert'){
		var image_name1 = f['image_name1'];
		if($F(image_name1).search(/\S/)==-1) {
			alert('Please upload atleast one file');
			$(image_name1).focus();
			return false;
		}
	}
	var image_caption = f['image_caption'];
	if($F(image_caption).search(/\S/)==-1) {
		alert('Please enter title.');
		$(image_caption).focus();
		return false;
	}

	return true;
	
}
// Add_Press_Check end

function archive(file_month,file_year) {
	//alert("hi");
	    var location_archive = "archive.php?file_month="+file_month+"&file_year="+file_year;
		window.location.href = location_archive;
		//alert(location_archive);
		}
// archive end

function retailers_login_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var retailers_user_email = f['retailers_user_email'];
	if($F(retailers_user_email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(retailers_user_email).focus();
		return false;
	}
	if(emailCheck($F(retailers_user_email))==false) {
		alert('Please enter valid email');
		$(retailers_user_email).focus();
		return false;
	}
	var retailers_user_password = f['retailers_user_password'];
	if($F(retailers_user_password).search(/\S/)==-1) {
		alert('Please enter your password');
		$(retailers_user_password).focus();
		return false;
	}
	
	return true;
}

function retailor_check(action){
	//alert(lan);
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var retailers_user_email = f['retailers_user_email'];
	if($F(retailers_user_email).search(/\S/)==-1) {
		alert('Please enter your email');
		$(retailers_user_email).focus();
		return false;
	}
	if(emailCheck($F(retailers_user_email))==false) {
		alert('Please enter valid email');
		$(retailers_user_email).focus();
		return false;
	}
	var retailers_user_password = f['retailers_user_password'];
	if($F(retailers_user_password).search(/\S/)==-1) {
		alert('Please enter your password');
		$(retailers_user_password).focus();
		return false;
	}
	var con_password = f['con_user_password'];
	if($F(con_password).search(/\S/)==-1) {
		alert('Please enter confirm password');
		$(con_password).focus();
		return false;
	}
	if($F(con_password)!=$F(retailers_user_password)) {
		alert('Password mismatch');
		$(con_password).focus();
		return false;
	}
	
	return true;
}

function retailers_order_check(action)
 {
   var day = document.getElementById('day').value;
   var month = document.getElementById('month').value;
   var year = document.getElementById('year').value;
   var retailers_user_name = document.getElementById('retailers_user_name').value;
   var retailers_user_email = document.getElementById('retailers_user_email').value;
   var retailers_user_address = document.getElementById('retailers_user_address').value;
   //var ret_cat_id = document.getElementById('ret_cat_id').value;
   //var retailers_order_quantity = document.getElementById('retailers_order_quantity').value;
   document.getElementById('hdnPgaction').value = action;
   
   if(day == "")
	{
	  alert('Day can not be left blank.');
	  document.getElementById('day').focus();
	  return false;
	}
   
   if(month == "")
	{
	  alert('Month can not be left blank.');
	  document.getElementById('month').focus();
	  return false;
	}
   
   if(year == "")
	{
	  alert('Year can not be left blank.');
	  document.getElementById('year').focus();
	  return false;
	}
   
   
   if(retailers_user_name == "")
    {
	  alert('Name can not be left blank.');
	  document.getElementById('retailers_user_name').focus();
	  return false;
	}
   if(retailers_user_email == "")
	{
	  alert('Email can not be left blank.');
	  document.getElementById('retailers_user_email').focus();
	  return false;
	}
   if(emailCheck(retailers_user_email)==false)
    {
	  alert('Email is not valid');
	  document.getElementById('retailers_user_email').focus();
	  return false;
	}	
   if(retailers_user_address == "")
	{
	  alert('Address can not be left blank.');
	  document.getElementById('retailers_user_address').focus();
	  return false;
	} 	
   checkboxes = document.frmMain.ret_product_id.length;
   txt_check = "";
   for (i=0; i<checkboxes; i++) 
	 {
       if(document.frmMain.ret_product_id[i].checked)
	     {
           txt_check = txt_check + document.frmMain.ret_product_id[i].value + "~~";
		   var textbox = document.frmMain.retailers_order_quantity[i].value; 
		   if(textbox == "")
		    {
			  alert('Please enter the Order Quantity of ticked product');
			  document.frmMain.retailers_order_quantity[i].focus();
			  return false;
			}
         }
     }
   if(txt_check == "")
    {
     alert('Please select atleast one product');
	 return false;
    }	
   /*else
    {
	  //alert(txt_check);
	  var mySplitResult = txt_check.split("~~");
	  //alert(mySplitResult.length);
	  for(i=0; i<mySplitResult.length-1; i++)
	   { 
	     alert(mySplitResult[i]);
		 alert()
	   }
	}*/
   /*if(retailers_order_quantity == "")
	{
	  alert('Order quantity can not be left blank.');
	  document.getElementById('retailers_order_quantity').focus();
	  return false;
	} */	
   return true;
 }
//retailers_order_check

function Notes_Validity_Check(action) 
 {
   var f = $('frmMain');
   var pga = f['hdnPgaction'];
   var notes_doc = f['notes_doc'];
   if(action == 'insert')
    {
	 if($F(notes_doc).search(/\S/) == -1)
	  {
		alert('Notes File can not be left blank.');
		$(notes_doc).focus();
		return false;
	  }
	}
   if(document.frmMain.notes_doc.value != '')
    {
	  var d_image = document.frmMain.notes_doc.value;
	  var image_arr = d_image.split(".");
	  var notes_doc = image_arr[1].toUpperCase();
	  if(notes_doc!="DOC" && notes_doc!="PDF")
	   {
		 alert("Upload only .DOC / .PDF for notes file.");
	     document.frmMain.notes_doc.focus();
		 return false;
	   }
	}
   $(pga).value = action;
   return true;
 } 
//Notes_Validity_Check 


function Menu_Validity_Check(action) 
 {
   var f = $('frmMain');
   var pga = f['hdnPgaction'];
   var menu_doc = f['menu_doc'];
   if(action == 'insert')
    {
	 if($F(menu_doc).search(/\S/) == -1)
	  {
		alert('Menu File can not be left blank.');
		$(menu_doc).focus();
		return false;
	  }
	}
   if(document.frmMain.menu_doc.value != '')
    {
	  var d_image = document.frmMain.menu_doc.value;
	  var image_arr = d_image.split(".");
	  var menu_doc = image_arr[1].toUpperCase();
	  if(menu_doc!="JPEG" && menu_doc!="JPG" && menu_doc!="PDF")
	   {
		 alert("Upload only .JPEG/.JPG/ .PDF for menu file.");
	     document.frmMain.menu_doc.focus();
		 return false;
	   }
	}
   $(pga).value = action;
   return true;
 } 
//Menu_Validity_Check 


function Image_Validity_Check(action) 
 {
   var f = $('frmMain');
   var pga = f['hdnPgaction'];
   var image_doc = f['image_doc'];
   if(action == 'insert')
    {
	 if($F(image_doc).search(/\S/) == -1)
	  {
		alert('Image File can not be left blank.');
		$(image_doc).focus();
		return false;
	  }
	}
   if(document.frmMain.image_doc.value != '')
    {
	  var d_image = document.frmMain.image_doc.value;
	  var image_arr = d_image.split(".");
	  var image_doc = image_arr[1].toUpperCase();
	  if(image_doc!="JPEG" && image_doc!="JPG" && image_doc!="PDF")
	   {
		 alert("Upload only .JPEG/.JPG/ .PDF for image file.");
	     document.frmMain.image_doc.focus();
		 return false;
	   }
	}
   $(pga).value = action;
   return true;
 } 
//Image_Validity_Check 


function Logo_Validity_Check(action) 
 {
   var f = $('frmMain');
   var pga = f['hdnPgaction'];
   var logo_doc = f['logo_doc'];
   if(action == 'insert')
    {
	 if($F(logo_doc).search(/\S/) == -1)
	  {
		alert('Logo File can not be left blank.');
		$(logo_doc).focus();
		return false;
	  }
	}
   if(document.frmMain.logo_doc.value != '')
    {
	  var d_image = document.frmMain.logo_doc.value;
	  var image_arr = d_image.split(".");
	  var logo_doc = image_arr[1].toUpperCase();
	  if(logo_doc!="JPEG" && logo_doc!="JPG" && logo_doc!="PDF")
	   {
		 alert("Upload only .JPEG/.JPG/ .PDF for logo file.");
	     document.frmMain.logo_doc.focus();
		 return false;
	   }
	}
   $(pga).value = action;
   return true;
 } 
//Logo_Validity_Check 

function Retailer_Category_Check(action){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	
	
	var ret_cat_name = f['ret_cat_name'];
	if($F(ret_cat_name).search(/\S/)==-1) {
		alert('Retailer Category Name can not be left blank');
		$(ret_cat_name).focus();
		return false;
	}
	
	return true;

}

//Retailer_Category_Check end
function Retailer_SubCategory_Check(action){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	var ret_cat_id = f['ret_cat_id'];
	var ret_subcat_name = f['ret_subcat_name'];
	
	if($F(ret_cat_id).search(/\S/)==-1) {
		alert('Retailer Category Name can not be left blank');
		$(ret_cat_id).focus();
		return false;
	}
	
	if($F(ret_subcat_name).search(/\S/)==-1) {
		alert('Retailer Sub Category Name can not be left blank');
		$(ret_subcat_name).focus();
		return false;
	}
	
	return true;

}//Retailer_SubCategory_Check end

//Retailer_Category_Check end
function Retailer_Product_Validity_Check(action){
	var f = $('frmMain');
	var pga = f['hdnPgaction'];
	$(pga).value = action;
	var ret_cat_id = f['ret_cat_id'];
	//var ret_subcat_id = f['ret_subcat_id'];
	var ret_product_name = f['ret_product_name'];
	var ret_product_packsize = f['ret_product_packsize'];
	var ret_product_abv = f['ret_product_abv'];
	
	if($F(ret_cat_id).search(/\S/)==-1) {
		alert('Retailer Category Name can not be left blank');
		$(ret_cat_id).focus();
		return false;
	}
	
	//alert(ret_subcat_id);
	
	if($F(ret_product_name).search(/\S/)==-1) {
		alert('Retailer product name can not be left blank');
		$(ret_product_name).focus();
		return false;
	}
	
	if($F(ret_product_packsize).search(/\S/)==-1) {
		alert('Retailer product pack size can not be left blank');
		$(ret_product_packsize).focus();
		return false;
	}
	
	if($F(ret_product_abv).search(/\S/)==-1) {
		alert('Retailer product abv can not be left blank');
		$(ret_product_abv).focus();
		return false;
	}
	
	return true;

}//Retailer_SubCategory_Check end
