/*++++++++++++++++++++++++++++++++++++++++++++++++++++++/
/ JavaScript functions for this whole website           / 
/  Made by : Abhishek Sarkar                            /  
/  Companey : Jayanth Systems                           /
/  Year : 2006                                          /
+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

// -----------------------Common Functions-----------------------------------------
 

function userLogout(){
	if(confirm("Do you want to logged out from user?")){
		document.frm_logout.submit();
	}
	else
	window.history.go(1);
}



function chkLogout(){
	if(confirm("Do you want to logged out from admin?")){
		document.frm_logout.submit();
	}
	else
	window.history.go(1);
}
function backto(){
	document.frm.pageaction.value="";
	document.frm.submit();
}
function navig(off_set){
	document.frm.offset.value=off_set;
	document.frm.submit();
}
function navigUser(off_set){
	document.frm.offset.value=off_set;
	document.frm.submit();
}
function alphabates(alp){
	document.frm.alpha.value=alp;
	document.frm.offset.value=0;
	document.frm.submit();
}

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function gotoFeaturedCar(id){
	document.frm.pageaction.value="setFeature";
	document.frm.submit();
}
function gotoInShowcase(id){
	document.frm.pageaction.value="inShowcase";
	document.frm.submit();
}

//--------------check select row----------------------------------------------------
var selected;
function selectRowEffect(object, path) {
 
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }
  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;
  if(path)
  	location=path;
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}


//--------------check integer----------------
function isInteger(sInt)
	{
		var ret_int = "true"
		inputInt = sInt.toString()
		for (var i = 0; i < inputInt.length; i++)
			{
			var oneChar = inputInt.charAt(i)			
			if ((oneChar < "0" || oneChar > "9") && oneChar != ".")
					{
						ret_int = "false"
					}
			}
		return (ret_int)
	}
//--------------check date----------------
function isDate(sDate){
	var ret_dt = "true"
	inputDt = sDate.toString()		
	if((/^\d{4}\-\d{2}\-\d{2}$/).exec(inputDt) == null){ //-- date format--->(Y-m-d)
		ret_dt = "false"
	}
	return (ret_dt)
}
//--------------check email----------------
function isEmail(sEmail){
	var ret_email = "true"
	inputEml = sEmail.toString()		
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(inputEml) == null){
		ret_email = "false"
	}
	return (ret_email)
}

//--------------check blanck----------------
function isBlank(sVal){
	var ret_msg = "true"
	inputStr = sVal.toString()		
	if(inputStr.search(/\S/)==-1){ //-- check for space also
		ret_msg = "false"
	}
	return (ret_msg)
}

//******************************************************  USER FUNCTIONS   *****************************************************
function gotoAdd(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}
function gotoAddPtoC(id){
	document.frm.cm_id.value=id;
	document.frm.pageaction.value="add";
	document.frm.submit();
}
function gotoUploadBill(){
	document.frm.pageaction.value="uploadScreen";
	document.frm.submit();
}

function gotoUpdateProductDetl(cid, psid){
	document.frm.cm_id.value=cid;
	document.frm.ps_id.value=psid;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}

function gotoAddNewBillName(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}

function gotoUpdatebilling(id){
	document.frm.billing_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoDeletebilling(id){
	if(confirm("Want to delete this Billing?"))
	{
		document.frm.billing_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoAddbilling(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}

function gotoUpdateStatus(id){
	document.frm.status_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoShowRemarks(id){
	document.frm.ps_id.value=id;
	document.frm.pageaction.value="detl";
	document.frm.submit();
}

function gotoDeleteStatus(id){
	if(confirm("Want to delete this Status?"))
	{
		document.frm.status_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoAddStatus(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}


function gotoUpdatebill(id){
	document.frm.bill_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoDeletebill(id){
	if(confirm("Want to delete this bill?"))
	{
		document.frm.bill_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}

function gotoSearchCustomer(){
	if(document.getElementById("cm_idno").value!='' || document.getElementById("cm_fname").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("reg_no").focus();
	}
}

function gotoShowProductDetails(psid){
	document.frm.ps_id.value=psid;
	document.frm.submit();
}

function gotoSearchSector(){
	if(document.getElementById("sm_idno").value!='' || document.getElementById("sm_name").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("sm_idno").focus();
	}
}
function gotoSearchPCat(){
	if(document.getElementById("pc_idno").value!='' || document.getElementById("pc_name").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("pc_idno").focus();
	}
}
function gotoSearchProduct(){
	if(document.getElementById("pm_idno").value!='' || document.getElementById("pm_name").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("pm_idno").focus();
	}
}
function gotoSearchCustProduct(){
	if(document.getElementById("cm_idno").value!='' || document.getElementById("cm_fname").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("cm_idno").focus();
	}
}

function gotoSearchProductReport(){
	if(document.getElementById("from_date").value!='' || document.getElementById("to_date").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("from_date").focus();
	}
}

function gotoSearchBilling(){
	if(document.getElementById("reg_no").value!='' || document.getElementById("cust_name").value!='' || document.getElementById("bill_no").value!='' || document.getElementById("status").value!=''){
//		alert(document.getElementById("reg_no").value); 
		document.frm.pageaction.value="search";
		document.frm.submit();
	}
	else{
		alert("Enter search value!!");
		document.getElementById("reg_no").focus();
	}
}

function gotoAddbill(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}

function gotoUpdateUser(id){
	document.frm.cm_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoUpdateSector(id){
	document.frm.sm_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}

function gotoUpdatePCat(id){
	document.frm.pc_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}

function gotoUpdateProduct(id){
	document.frm.pm_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoShowProduct(id){
	document.frm.cm_id.value=id;
	document.frm.pageaction.value="showproduct";
	document.frm.submit();
}

function gotoDeleteUser(id){
	if(confirm("Want to delete this User?"))
	{
		document.frm.cm_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoDeleteSector(id){
	if(confirm("Want to delete this Sector?"))
	{
		document.frm.sm_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoDeletePCat(id){
	if(confirm("Want to delete this Product Category?"))
	{
		document.frm.pc_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}

function gotoDeleteProduct(id){
	if(confirm("Want to delete this Product?"))
	{
		document.frm.pm_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}

function gotoDeleteCProduct(cid, psid){
	if(confirm("Want to delete this service details?"))
	{
		document.frm.cm_id.value=cid;
		document.frm.ps_id.value=psid;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}

function gotoAddUser(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}

function gotoUpdateCycle(id){
	document.frm.cycle_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoDeleteCycle(id){
	if(confirm("Want to delete this Cycle?"))
	{
		document.frm.cycle_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoCycleNews(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}


function gotoUpdateResults(id){
	document.frm.results_id.value=id;
	document.frm.pageaction.value="edit";
	document.frm.submit();
}
function gotoDeleteResults(id){
	if(confirm("Want to delete this Results?"))
	{
		document.frm.results_id.value=id;
		document.frm.pageaction.value="delete";
		document.frm.submit();
	}
}
function gotoAddResults(){
	document.frm.pageaction.value="add";
	document.frm.submit();
}

function checkBill(){	
	if(isBlank(document.frm.billing_name.value)=="false"){
		alert("Please insert Bill Category Name");
		document.frm.billing_name.focus();
		return(false);
	}
}


