<!--hide this script from non-javascript-enabled browsers 
/*
########################################################################     
# File Name: js/functions.js
# Created By: Manish Sharma
# Created On: 21 April 2009
# This file contain all the common javascript functions
#########################################################################
*/

HTTP_DOMAIN = 'http://www.doubleaacorp.com';
HTTPS_DOMAIN = 'https://www.doubleaacorp.com';


/*
###############################################################################################################################
# Function Name :wait()  
# Created By: Manish Sharma
# Created On: 03 June 2009
# Purpose :create wait for specified mili second
###############################################################################################################################
*/
function wait(msecs)
{
	var start = new Date().getTime();
	var cur = start
	
   while(cur - start < msecs)
	{
		cur = new Date().getTime();
	}
}

function fnSetChkBoxVal(id,flag)
{
  $(id).checked=true;
  var checkBoxVal = $F(id);
  var chkBoxValArr =  checkBoxVal.split('#');
  $(id).value = chkBoxValArr[0]+'#'+chkBoxValArr[1]+'#'+chkBoxValArr[2]+'#'+flag;
} 

/*
###############################################################################################################################
# Function Name :fnFillFieldValue()  
# Created By: Manish Sharma
# Created On: 03 June 2009
# Purpose :select popup window and show on parent window
###############################################################################################################################
*/
function fnFillFieldValue(fieldId,val)
{
   window.opener.$(fieldId).value= val;
}


/*
###############################################################################################################################
# Function Name :fnLoadingImage()  
# Created By: Manish Sharma
# Created On: 03 June 2009
# Purpose :show the loading image when procee running(means before get the reponse)
###############################################################################################################################
*/

function fnLoadingImage(target)
{
	$(target).innerHTML = '<img src="../../images/loading.gif"/>';
}

/*
#################################################################################################
# Function Name : fnCalanderFrom()
# Created By : Manish Sharma
# Created On : 04 June 2009
# Description : Function to show the calander according to calander .js (on add mail recipients) 
# Parameter : 
#################################################################################################
*/ 

function fnOpenCalander(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    "f_trigger_c",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2009,2070],
		singleClick    :    true
	});
}

function fnOpenCalander1(inputfield,inputfield1)
{
   //alert(inputfield);	
   Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m/%d/%Y",      // format of the input field
		button         :    inputfield1,  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2009,2070],
		singleClick    :    true
	});
}

function fnCalander(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    "f_trigger_c",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2008,2070],
		dateStatusFunc : dateStatus,
		singleClick    :    true
	});
}

function fnCalanderFrom(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%Y-%m-%d",      // format of the input field
		button         :    "f_trigger_c",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2008,2070],
		dateStatusFunc : dateStatus,
		singleClick    :    true
	});
}

function fnCalanderFrom1(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    "f_trigger_c",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2008,2070],
		singleClick    :    true
	});
}

function fnCalanderTo1(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    "f_trigger_d",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2008,2070],
		singleClick    :    true
	});
}


function fnOpenNewWindow(URL)
{

	var newwindow = window.open(URL,'','screenX=50,screenY=50,width=900,height=600,scrollbars=1,location=1');
	if (window.focus) {newwindow.focus()}

}

/*
#################################################################################################
# Function Name : fnCalanderTo()
# Created By : Manish Sharma
# Created On : 04 June 2009
# Description : Function to show the calander according to calander .js (on add mail recipients) 
# Parameter : 
#################################################################################################
*/ 
function fnCalanderTo(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%Y-%m-%d",      // format of the input field
		button         :    "f_trigger_d",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		range          : [2008,2070],
		dateStatusFunc : dateStatus,
		singleClick    :    true
	});
}

function fullCalander(inputfield,triggerfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    triggerfield,  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		singleClick    :    true
	});

}


function fullCalander_one(inputfield)
{
	Calendar.setup({
		inputField     :    inputfield,     // id of the input field
		ifFormat       :    "%m-%d-%Y",      // format of the input field
		button         :    "f_trigger_d",  // trigger for the calendar (button ID)
		align          :    "Bl",           // alignment (defaults to "Bl")
		singleClick    :    true
	});

}

function fncheckDateValidationParameter(from,to) 
{  
  if(from!='' && to!='')
  { 
	  var startparts= from.split("-"); 
	  var endparts=to.split("-"); 
	 
   var endDate = new Date(endparts[2],endparts[0],endparts[1]);
   var startDate= new Date(startparts[2],startparts[0],startparts[1]);
   
   var sDate = Date.parse(startDate);
   var eDate = Date.parse(endDate);

   if( sDate.valueOf() > eDate.valueOf())
   {
		 //alert(' "To" date should be greater than "From" date ');
		 return false;
   }
   else
   {
		return true;
   }

 }	 
}

/*
 #############################################################################
 # Function Name: isBlank()
 # Created By: Manish Sharma  
 # Created on: 21 April 2009
 # Purpose: Function to check wether given value is blank or not.    
 # Parameters: string strValue : string. 
 # ON SUCCESS: Returns TRUE if value is blank.     
 # ON FAILURE: Returns FLASE  if value is not blank.     
 #############################################################################
 */
 
 function fnIsBlank(strValue)
 {
	 for(var i = 0; i < strValue.length; i++)
	 {
		 var c = strValue.charAt(i);
		 if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	 }
	 return true; 
 }

/*
 #############################################################################
 # Function Name: isValidEmail()
 # Created By: Manish Sharma  
 # Created on: 21 April 2009
 # Purpose: Validate an email address.
 # Parameters: string strEmail : Email address
 # ON SUCCESS: Returns TRUE if string is in valid email format.     
 # ON FAILURE: Returns FLASE if string is not in valid email format.
 #############################################################################
 */
 function fnIsValidEmail(strEmail) 
 {
	 // assume an email address cannot start with an @ or white space, but it 
	 // must contain the @ character followed by groups of alphanumerics and '-' 
	 // followed by the dot character '.' 
	 // It must end with 2 or 3 alphanumerics. 
	 // 
	 var alnum="a-zA-Z0-9"; 
	 exp="^[^@\\s]+@(["+alnum+"+\\-]+\\.)+["+alnum+"]["+alnum+"]["+alnum+"]?$"; 
	 emailregexp = new RegExp(exp); 
	 result = strEmail.match(emailregexp); 
	 if (result != null) 
	 {
		 return true; 
	 }
	 else 
	 {
		 return false; 
	 }
 }
 
  /* 
##################################################################
# Function Name : fnPutFocus()
# Created By : Manish Sharma
# Created On : 21 April 2009
# Parameter : elementId - particular field id 
# Description : function for focus to particular field
################################################################### 
 */
function fnPutFocus(elementId) 
{
	//alert(elementId);
	document.getElementById(elementId).focus();
}
 
 /*
########################################################################
#  Function Name :fnFocusAndAlert()
#  Created By: Manish Sharma
#  Created On: 22 April 2009
#  Paramaeter : alert message and id of that field where focus show
#  Purpose : show alert message and focus on the field
########################################################################
*/  

function fnFocusAndAlert(alert_message , focus_id)
{
	alert(alert_message);
	fnPutFocus(focus_id); 
}

/*
#############################################################################
# Function Name : fnIsNumberPhone 
# Created By: Manish Sharma
# Created On: 10 may 2009
# Purpose : It checks for valid phone number. 
# Parameters: value : value of the field
# string msg : Message if file type is not valid .
################################################################################
*/
function fnIsNumberPhone(value,msg) 
{ 
	var regex = /^[0-9]*$/; 

	if(value.length<10 || value.length>10)
	{
	  alert(' Please enter a valid phone number (No dashes or parenthesis).'); 
	  return false;
	}
	else
	{ 
		if(!regex.test(value)) 
		{ 
			alert(' Please enter a valid phone number  (No dashes or parenthesis).'); 
			return false; 
		}
	}	 
	return true; 
}

function fnIsFaxNumber(value,msg) 
{ 
	var regex = /^[0-9]*$/; 

	if(value.length<10 || value.length>10)
	{
	  alert(' Please enter a valid fax number (No dashes or parenthesis).'); 
	  return false;
	}
	else
	{ 
		if(!regex.test(value)) 
		{ 
			alert(' Please enter a valid fax number (No dashes or parenthesis).'); 
			return false; 
		}
	}	 
	return true; 
}

/*
#############################################################################
# Function Name : fnIsNumber 
# Created By: Manish Sharma
# Created On: 22 April 2009
# Purpose : It checks for valid numerical string. 
# Parameters: value : value of the field
# string msg : Message if file type is not valid .
################################################################################
*/
function fnIsNumber(value,msg) 
{ 
	var regex = /^[0-9]*$/; 

		if(!regex.test(value)) 
		{ 
			alert(msg+' must be numerical (No dashes or parenthesis).'); 
			return false; 
		}
		 
	return true; 
}  

/*#############################################################################
# Function Name : fnShowAlert 
# Created By: Manish Sharma
# Created On: 23 April 2009
# Purpose : show the message string in javascript alert;
# Parameters: msg - any string
 ################################################################################
*/
function fnShowAlert(msg)
{
	alert(msg);
}

/*#############################################################################
# Function Name : fnIsValidFloat() 
# Created By: Manish Sharma
# Created On: 28 April 2009
# Purpose : It checks for valid float formet. 
# Parameters: currencyFieldId - field value
# OnSuccess : Return true
# OnFailure : Return false.
################################################################################
*/  
function fnIsValidFloat(numval) 
{
	   if(numval==0 || numval==0.0)
	   {
		  return true;
	   }
	   
	   if(parseFloat(numval))
		 {
			
			return true;
		 
		 }
		 else
		 {
			
			return false;
		 } 
		
 }
 
 
 
/*#############################################################################
# Function Name : fnPriceValidation() 
# Created By: Manish Sharma
# Created On: 28 April 2009
# Purpose : It checks for price format lie 12.00 etc. 
# Parameters: price - field value
# OnSuccess : Return true
# OnFailure : Return false.
################################################################################
*/ 
function fnPriceValidation(price)
{
	var numStr = price;
	var matches = numStr.match(/\$?[0-9]{0}[0-9]{0,7}(\.[0-9]{0,6})?/g);
	for(i in matches)
	{
		if(matches[i] == numStr)
		{
		return true;
		 }
	}
	  return false;
}


function fnTaxValidation(price)
{
	var numStr = price;
	var matches = numStr.match(/\$?[0-9]{0}[0-9]{0,7}(\.[0-9]{0,6})?/g);
	for(i in matches)
	{
		if(matches[i] == numStr)
		{
		return true;
		 }
	}
	  return false;
}


function fnCCRValidation(price)
{
	var numStr = price;
	var matches = numStr.match(/\$?[0-9]{0}[0-9]{0,10}(\.[0-9]{0,6})?/g);
	for(i in matches)
	{
		if(matches[i] == numStr)
		{
		return true;
		 }
	}
	  return false;
}


function fnAddCustomerPopup()
{
   var	newwindow = window.open(HTTPS_DOMAIN+'/CustomerSignup/&sales=1','AddCustomer','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0');
	
	if (window.focus) {newwindow.focus()} 
}


/*
 #############################################################################
 # Function Name: fnChangePassValidation()
 # Created By: Manish Sharma  
 # Created on: 13 May 2009
 # Purpose: Function to check change password form validation    
#############################################################################
 */
function fnChangePassValidation()
{
	 var oldPass = $F('oldPass');
	 var newPass = $F('newPass');
	 var ConfNewPass = $F('confNewPass');
	 
	 
	 if(fnIsBlank(oldPass))
	 {
		fnFocusAndAlert(errorArray[75] , 'oldPass'); 
		return false;
	 }
	 
	 
	 if(fnIsBlank(newPass))
	 {
		fnFocusAndAlert(errorArray[76] , 'newPass'); 
		return false;
	 }
	 else
	 {
		  //check new passowrd length( more then 4 and less then 15)
		 var newPassLength = newPass.length;
	 
		 if(newPassLength <=4 || newPassLength >15) 
		 {
			fnFocusAndAlert(errorArray[2] ,'newPass');
			return false;
		 }
	 } 
	 
	 
	 if(fnIsBlank(ConfNewPass))
	 {
		fnFocusAndAlert(errorArray[77] , 'confNewPass'); 
		return false;
	 }
	 else
	 {
		  //check confirm new passowrd length( more then 4 and less then 15)
		 var confNewPassLength = ConfNewPass.length;
	 
		 if(confNewPassLength <=4 || confNewPassLength >15) 
		 {
			fnFocusAndAlert(errorArray[2] ,'confNewPass');
			return false;
		 }
	 } 
	
	if(!fnIsBlank(newPass) && !fnIsBlank(ConfNewPass)) 
	   {                                                   // password and confirm password both should be same check here.
		 if(newPass != ConfNewPass) 
		 {
			fnFocusAndAlert(errorArray[78] ,'confNewPass');
			return false;
		 }
	   }
}


/*
 #################################################################################
 # Function Name: fnSelectCustomer()
 # Created By: Manish Sharma  
 # Created on: 28 May 2009
 # Purpose: validate invoice and cc reim. template when select no. of customer    
##################################################################################
 */
function fnSelectCustomer()
{
   var vals = $F('no_customer');
   
   if(vals==1)
   {
	  $('singleCustomer').show();
	  $('singleCustomer1').show();
   }
   else
   {
   
	  $('singleCustomer').hide();
	  $('singleCustomer1').hide();
   }
   
}

/*
 #################################################################################
 # Function Name: fnWriteMailToAdmin()
 # Created By: Manish Sharma  
 # Created on: 29 June 2009
 # Purpose: validate write mail to admin form  
##################################################################################
 */
function fnWriteMailToAdmin()
{
		var subject = $F('subject');
		var mail_body = $F('mail_body');
		
	 if(fnIsBlank(subject))	
	 {
		fnFocusAndAlert(errorArray[59] , 'subject'); 
		return false;
	 }
	 
	 if(fnIsBlank(mail_body))
	 {
		fnFocusAndAlert(errorArray[60] , 'mail_body'); 
		return false;
	 }


}

/*
#################################################################################
# Function Name: fnPrintArea()
# Created By: Manish Sharma  
# Created on: 29 June 2009
# Parameter:print_area_div_id - text area id which is to be printed
# Purpose: print selected area of the page 
##################################################################################
*/

function fnPrintArea(print_area_div_id)
{
	var DocumentContainer = document.getElementById(print_area_div_id);
	var WindowObject = window.open('', "Print","width=950,height=2050,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
	WindowObject.document.writeln(DocumentContainer.innerHTML);
	WindowObject.document.close();
	WindowObject.focus();
	WindowObject.print();
	WindowObject.close();
}



function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}


/*
 #############################################################################
 # Function Name: fnShow()
 # Created By: Manish Sharma  
 # Created on: 23 April 2009
 # Parameter : id- id of the div which is to be display
 # Purpose: Function display the div according to id    
#############################################################################
 */
function fnShow(id)
{
	$(id).show();
}
/*
 #############################################################################
 # Function Name: fnHide()
 # Created By: Manish Sharma  
 # Created on: 23 April 2009
 # Parameter : id- id of the div which is to be set display:none
 # Purpose: Set display:none the div according to id    
#############################################################################
 */
function fnHide(id)
{
	$(id).hide();
}

/*
 ##########################################################################################################################
 # Function Name: isEarlierOrEqual()
 # Created By: PHP Team   
 # Created on: 12  Sep 2005
 # Purpose: This function will accept start date and end date and will check for date format and it will also check wether end date is earlier than start date.
 # Parameters: string start : Start date 
 #                    string end  : End date 
 # ON SUCCESS: Returns TRUE If both date are in valid format and start date is earlier than end date.
 # ON FAILURE: Returns FLASE If either of date are not in valid format or end date is before start date.
 ###########################################################################################################################
 */

function fncheckDateValidation() 
{
 
   var from = $F('from_date');
   var to = $F('to_date');
	
  if(from!='' && to!='')
  { 
	  var startparts= from.split("-"); 
	  var endparts=to.split("-"); 
	 
   var endDate = new Date(endparts[2],endparts[0],endparts[1]);
   var startDate= new Date(startparts[2],startparts[0],startparts[1]);
   
   var sDate = Date.parse(startDate);
   var eDate = Date.parse(endDate);

   if( sDate.valueOf() > eDate.valueOf())
   {
		 alert(' "To" date should be greater than "From" date ');
		 return false;
   }

 }	 
}

function fnRefresh(page)
{
	window.location.href=HTTP_DOMAIN+'/'+page;	
}

/*
####################################################################################################
#  Function Name :fntoggleVendorDetails()
#  Created By: Manish Sharma
#  Created On: 16 May 2008
#  Parmater: record_id - particular record which toogle when click on the image
#            image_id  - Individual image id when click on the image and particular record toggle
#  Purpose :toggle the vendors details  on click of the event
######################################################################################################
*/  
function fntoggleVendorDetails(record_id,image_id)
 { 
	var rowid = document.getElementById(record_id);
	
	if(rowid.style.display=='none')
	{
		rowid.style.display='';
		document.getElementById(image_id).src="../../images/minus.gif";    
	}
	else
	{
		rowid.style.display='none';
		document.getElementById(image_id).src="../../images/plus.gif";
	}
}


function fntoggleCustomerDetails(record_id,image_id)
 { 
	var rowid = document.getElementById(record_id);
	
	if(rowid.style.display=='none')
	{
		rowid.style.display='';
		document.getElementById(image_id).src="../images/minus.gif";    
	}
	else
	{
		rowid.style.display='none';
		document.getElementById(image_id).src="../images/plus.gif";
	}
}


function fnDisableFuelPriceReportSearchOption()
{
	var customer_id = $F('customer_dd');
	
	if(customer_id!=-1)
	{
	   alert('When search according to customer then fuel price show including markup');
	   
	   $('cust_provider').value=-1;
	   $('cust_provider').disabled=true; 
	   $('select_terminal').value=-1;
	   $('select_terminal').disabled=true;
	   $('gasoline_type').value=-1;
	   $('gasoline_type').disabled=true;
	   $('zone_name').value=-1;
	   $('zone_name').disabled=true; 
	}
	else
	{
		
	   $('cust_provider').disabled=false; 
	   $('select_terminal').disabled=false;
	   $('gasoline_type').disabled=false;
	   $('zone_name').disabled=false;
	}

}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return 0;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



function fnViewCCRDetailsRep(ccrPreCraftId,strCustomerNo,flag)
{
  var URL ="";
  var newwindow="";
  
if(ccrPreCraftId!='')	
	{
	
		if(flag==1)
		{
		  URL = HTTP_DOMAIN+'/Rep/ViewCCRDetails/'+ccrPreCraftId+'-'+strCustomerNo;
		  newwindow = window.open(URL,'ViewCCRDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==2)
		{
		  URL = HTTP_DOMAIN+'/ViewCCRDetails/'+ccrPreCraftId+'-'+strCustomerNo;
		  newwindow = window.open(URL,'ViewCCRDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0');  
		}
		
		if(flag==3)
		{
		  URL = HTTP_DOMAIN+'/ViewChargeBackDetailsCust/'+ccrPreCraftId+'-'+strCustomerNo; 
		  newwindow = window.open(URL,'ViewChargeBackDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==4)
		{
		  URL = HTTP_DOMAIN+'/Admin/ShowOutStandingBal/'+strCustomerNo;
		  newwindow = window.open(URL,'ShowOutstandingBalanceDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==5)
		{
		  URL = HTTP_DOMAIN+'/Admin/ViewInvoiceDetailsPopup/'+strCustomerNo;
		  newwindow = window.open(URL,'ShowOutstandingBalanceDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==6)
		{
		  URL = HTTP_DOMAIN+'/Admin/ViewRelatedInvoiceDetailsPopUp/'+strCustomerNo;
		  newwindow = window.open(URL,'ViewRelatedInvoice','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==7)
		{
		  URL = HTTP_DOMAIN+'/Admin/ViewOriginalAutoInvoice/'+strCustomerNo;
		  newwindow = window.open(URL,'ViewOriginalAutoInvoice','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
		
		if(flag==8)
		{
		  URL = HTTP_DOMAIN+'/Admin/ViewAllCustOSBalReport/';
		  newwindow = window.open(URL,'ViewAllCustomerOutstandingBalanceReport','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0'); 
		}
	
	}
	
	if (window.focus) {newwindow.focus()}
}


/*
 #############################################################################
 # Function Name: fnViewOrderDetailsPopup()
 # Created By: Manish Sharma  
 # Created on: 23 sept. 2009
 # Purpose: Function to show order details popup    
#############################################################################
 */
function fnViewOrderDetailsPopup(OrderId,flag)
{
	if(flag==0)
	{
	newwindow = window.open(HTTP_DOMAIN+'/Admin/ViewOrderDetails/'+OrderId+'&report=1','ViewOrderDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0');
	}
	
	if(flag==1)	
	{
	newwindow = window.open(HTTP_DOMAIN+'/ViewOrderDetails/'+OrderId+'&report=1','ViewOrderDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0');
	}

	if(flag==2)	
	{
	newwindow = window.open(HTTP_DOMAIN+'/Rep/ViewOrderDetails/'+OrderId+'&report=1','ViewOrderDetails','screenX=50,screenY=50,width=1000,height=500,scrollbars=1,location=0');
	}
	
	if (window.focus) {newwindow.focus()}
}


 function fnDisableLogDD(disableId,openId)
{
  var val = $F(openId);
  if(val!=-1)
  {
	$(disableId).disabled = true;
	$(openId).disabled = false;
  }
  else
  {
	$(disableId).disabled = false;
	$(openId).disabled = false;
  }
}

function fnDisableSALogDD(openId,disableId,disableId1)
{
  var val = $F(openId);
  if(val!=-1)
  {
	$(disableId).disabled = true;
	$(disableId1).disabled = true;
	$(openId).disabled = false;
  }
  else
  {
	$(disableId).disabled = false;
	$(disableId1).disabled = false;   
	$(openId).disabled = false;
  }
}


/* 
################################################################################
# Function Name : isValidURL()
# Created By : Manish Sharma
# Created On : 29 Oct 2009
# Description : For validation of url
# Parameter : url - check field value
# OnSuccess : Return True.
# OnFailure : Return False.
####################################################################################
*/ 
 function isValidURL(url)
 {
	//var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	var RegExp = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/; 
	
	//var RegExp = /^(http|ftp)\:\/\/\w+([\.\-]\w+)*\.\w{2,4}(\:\d+)*([\/\.\-\?\&\%\#]\w+)*\/?$/i;
	
	if(RegExp.test(url))
	{
		return true;
	}
	else
	{
		return false;
	}
}  

// stop hiding
 --> 
 
 
 