function Resize(imgPreview)
{
	var nwidth=imgPreview.width+50;
	var nheight=imgPreview.height+100;
	if(nwidth<200)
		nwidth=200;
	if(nheight<200)
		nheight=200;	
		
	window.resizeTo(nwidth,nheight);
}// JavaScript Document


function CheckIsSelected(formName,checkBoxName,hiddenName,msg)
{
        var obj=eval("document."+formName);
		var chkobj=eval("document."+formName+"."+checkBoxName);
		var hidobj=eval("document."+formName+"."+hiddenName);
		var blSelected = false;
        
		if(!chkobj.length)
		{
			if(chkobj.checked)
				blSelected = true;
		}
		else
		{
			for(i=0;i<chkobj.length;i++)
			{
				if(chkobj[i].checked)
				{ 
						blSelected = true;
						break;
				}
				
			}
		}

		if(!blSelected)
        {
            if(msg)
				alert(msg);
			else
				alert('Please Select at least one record.');
            return false
        }
		else
		{
			var values="";
			if(!chkobj.length)
			{
				hidobj.value=chkobj.value
			}
			else
			{
				for(i=0;i<chkobj.length;i++)
				{
					if(chkobj[i].checked)
						values = values+chkobj[i].value+",";
				}
				hidobj.value=values.substring(0,values.length -1);
			}
			
			//alert(hidobj.value);
			return true;
		}
}

function SelectAll(formName,selChkName,checkBoxName)
{
        var selchkobj=eval("document."+formName+"."+selChkName);
		var chkobj=eval("document."+formName+"."+checkBoxName);
        if(selchkobj.checked)
		{
			if(!chkobj.length)
			{
				chkobj.checked = true;
			}
			else
			{
				for(i=0;i<chkobj.length;i++)
				{
					chkobj[i].checked = true;
				}
			}
		}
		else
		{
			if(!chkobj.length)
			{
				chkobj.checked = false;
			}
			else
			{
				for(i=0;i<chkobj.length;i++)
				{
					chkobj[i].checked = false;
				}
			}
		}
}


// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

/*function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
} */

function isInt(el){
			//var elval= trimEL(el.value);
			//var elval=el.value;
			var elval= el.replace(/[\n\r\s]+/,"");// to remove left trim
			elval= elval.replace(/[\n\r\s]+$/,"");// to remove right trim
			if(elval =="") return true;
			
			var filter=/(^\d*$)/;
			
			if (filter.test(elval))
			{
					return true;
			}
			else
			{
					el.focus();el.select();
					return false;
			}
	}



function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}

function isDate(dtStr){
	
	var daysInMonth = DaysArray(12);
    var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);

	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;

	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy.");
		return false;
	}
	
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month.");
		return false;
	}

	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day.");
		return false;
	}


	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
	{
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+".");
		return false;
	}

	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInt(stripCharsInBag(dtStr, dtCh))==false)
	{
		alert("Please enter a valid date.");
		return false;
	}
return true;
}

	function validEmail(el)
	   {
			var elval= el.value.replace(/[\n\r\s]+/,"");
			if(elval =="") return true;
			var str=el.value;
			var filter=/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,3})$/i         ;
			if (filter.test(str))
			testresults=true;
			else {el.focus();el.select();testresults=false;}
			return (testresults);
	   }


function ComapreDates(txtAuctionSDate, txtAuctionEDate, Caption1, Caption2, focusElement, IsFocus)
 {

    // Pass IsFocus='No' if you don't want to focus on any element 
	// focusElement is the control on which will have focus after alert
	// txtAuctionSDate is the object of first date
	// txtAuctionEDate is the object of end date  


			if(IsFocus==null) IsFocus = 'Yes';
	
		          if(txtAuctionSDate.value.length!=0 && txtAuctionEDate.value.length!=0 )
                        {
                          var StartDate = txtAuctionSDate.value;
                          var EndDate = txtAuctionEDate.value;
                          
                          var arrStart = StartDate.split("/");
                          var arrEnd = EndDate.split("/");          
                          
                          if(arrEnd[2]<arrStart[2])
                                {
                                 alert( Caption1 + ' must be smaller than ' + Caption2 + '.' );

								 /* if focus is shown or not */
                                  if(IsFocus=='Yes')
									 {
										if(focusElement==null) focusElement = txtAuctionEDate.focus();
										else { focusElement.focus();}
									 }		
									 
                                  return false; 
                                }
                          else if(arrEnd[2]==arrStart[2]) 
                                {
                                  	if(parseInt(arrEnd[0])<parseInt(arrStart[0]))
                                    {
                                         alert( Caption1 + ' must be smaller than ' + Caption2 + '.' );

										 /* if focus is shown or not */
                                         if(IsFocus=='Yes') 
											 {
												if(focusElement==null) focusElement = txtAuctionEDate.focus();
												else { focusElement.focus();}
											 }		
											 
                                          return false;
                                    }
                                  	else if(parseInt(arrEnd[0])==parseInt(arrStart[0]))        
                                    {
                                          if(parseInt(arrEnd[1])<parseInt(arrStart[1]))
                                                {
                                                alert( Caption1 + ' must be smaller than ' + Caption2 + '.' );

												   /* if focus is shown or not */
												   if(IsFocus=='Yes') 
													 {
														if(focusElement==null) focusElement = txtAuctionEDate.focus();
														else { focusElement.focus();}
													 }		

                                                 return false;
                                                }
										else return true;			
                                     }
									else return true;

                                }
							else return true;			
	                    }
                else
                        {
                                return true;
                        } 
} 



/* Following And above functions are same except the message displays is changed */

function ComapreDates2(txtAuctionSDate, txtAuctionEDate, Caption1, Caption2, focusElement, IsFocus)
 {

    // Pass IsFocus='No' if you don't want to focus on any element 
	// focusElement is the control on which will have focus after alert
	// txtAuctionSDate is the object of first date
	// txtAuctionEDate is the object of end date  

			if(IsFocus==null) IsFocus = 'Yes';
	
		          if(txtAuctionSDate.value.length!=0 && txtAuctionEDate.value.length!=0 )
                        {
                          var StartDate = txtAuctionSDate.value;
                          var EndDate = txtAuctionEDate.value;
                          
                          var arrStart = StartDate.split("/");
                          var arrEnd = EndDate.split("/");          
                          
                          if(arrEnd[2]<arrStart[2])
                                {
                                 alert( Caption2 + ' must be greater than ' + Caption1 + '.' );

								 /* if focus is shown or not */
                                  if(IsFocus=='Yes')
									 {
										if(focusElement==null) focusElement = txtAuctionEDate.focus();
										else { focusElement.focus();}
									 }		
									 
                                  return false; 
                                }
                          else if(arrEnd[2]==arrStart[2]) 
                                {
                                  	if(parseInt(arrEnd[0])<parseInt(arrStart[0]))
                                    {
                                         alert( Caption2 + ' must be greater than ' + Caption1 + '.' );

										 /* if focus is shown or not */
                                         if(IsFocus=='Yes') 
											 {
												if(focusElement==null) focusElement = txtAuctionEDate.focus();
												else { focusElement.focus();}
											 }		
											 
                                          return false;
                                    }
                                  	else if(parseInt(arrEnd[0])==parseInt(arrStart[0]))        
                                    {
                                          if(parseInt(arrEnd[1])<parseInt(arrStart[1]))
                                                {
                                                alert( Caption2 + ' must be greater than ' + Caption1 + '.' );

												   /* if focus is shown or not */
												   if(IsFocus=='Yes') 
													 {
														if(focusElement==null) focusElement = txtAuctionEDate.focus();
														else { focusElement.focus();}
													 }		

                                                 return false;
                                                }
										else return true;			
                                     }
									else return true;

                                }
							else return true;			
	                    }
                else
                        {
                                return true;
                        } 
} 







/* following function  removes the left and right spaces from the passing value */

function RemoveLRSpace(elemval)
{
	var val=elemval.replace(/\s*/,"")
	var val=val.replace(/\s*$/,"")
	return val;
}
function getversion()
{
	if(navigator.appName.indexOf("Netscape")>-1)
	{
	make="Netscape";
	}
	else if((navigator.appName.indexOf("Microsoft")>-1) || (navigator.appName.indexOf("MSIE")>-1))
	{
		make="IE";
	}
	else if(navigator.appName.indexOf("Opera")>-1)
	{
		make="Opera";
	}
	else
	{
		make=navigator.appName;
	}
	version=parseInt(navigator.appVersion);
	details=make;
	<!--+"-"+version;// -->
	return details;
}
function checkBrowser()
{
	var browser = navigator.appName; //find the browser name

	if(browser == "Microsoft Internet Explorer")
	{
	  return 'IE';
	}
	else
	{
	  return 'NS'; 	
	}
}
function ReturnResponse(strURL)
{
	CheckBr = checkBrowser();
	
	if(CheckBr =='IE')
	{
		
		 objHTTP=new ActiveXObject("MSXML2.XMLHTTP");
		 var a=objHTTP.open("GET", strURL,false);
		 objHTTP.send();
		 strResult = objHTTP.responseText;
		
	}
	else
	{		
		objHTTP = new XMLHttpRequest();
		
		objHTTP.open( "GET", strURL,false ) ;	

		objHTTP.send(null);
		
		strResult = objHTTP.responseText;	

	}
	return strResult
}

















// function for popup Window

function popupWindow(url,width,height) 

{

  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')

}


/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}




/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
function openXpandedImagePopup(imagePath){
		if (imagePath.length != 0) {
			window.open('XpandedImagePopup.php?imagePath=' + imagePath, 'newwin', 'width=425, height=530, left='+(screen.width-425)/2+', top='+(screen.height-530)/2+', resizable=no, scrollbars=no, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
		}
	}

