	var calendertop = 100;
	var calenderleft = 200;
	var selectedObj = null;
	var global_date_format ="dd/MM/yy";
	var global_date_type= "date";
	
	var currDate = new Date();
	var tommorrowDate = new Date();
	tommorrowDate.setDate(currDate.getDate() + 1);
	
	function assignDate( date )
	{	
		document.getElementById( selectedObj ).value = date;
		document.getElementById( selectedObj ).focus();
	}
	
	function formatDate(d)
	{
	    var month = d.getMonth();
	    var day = d.getDate();
	    var year = d.getFullYear();
	    
	    year = year.toString().substr(2,2);
	    
	    month = month + 1;
	    month = month + "";

	    if (month.length == 1)
	    {
	        month = "0" + month;
	    }

	    day = day + "";

	    if (day.length == 1)
	    {
	        day = "0" + day;
	    }

	    return day +"/"+ month +"/"+ year;
	}
	
	function checkAll(element) 
	{
		var checkboxes = document.getElementsByTagName('input');
    
		if (element.checked) 
		{
			for (var i = 0; i < checkboxes.length; i++) 
			{
				if (checkboxes[i].type == 'checkbox') 
				{
					checkboxes[i].checked = true;
	            }
	        }
	    }
		else
		{
			for (var i = 0; i < checkboxes.length; i++) 
	        {
				if (checkboxes[i].type == 'checkbox') 
	            {
					checkboxes[i].checked = false;
	            }
	        }
		}
	}
	
	function setChecked(obj)
	{
		if( obj.value == 'false' )
		{
			obj.value ='true';
		}
		else 
		{
			obj.value = 'false';
		}
	}
	
	function setActionVal( value )
	{  
		//alert(value);
	    document.getElementById("action").value = value;
	}
	
	/**
	 * selecting price or supplier clicking on row
	 */
	function chkRows(id) 
	{
		if (document.getElementById(id).checked)
		{
			document.getElementById(id).checked = false;
			document.getElementById(id).value = 'false';
		}
		else
		{
			document.getElementById(id).checked = true;
			document.getElementById(id).value = 'true';
		}
	}
	
	function chkAllCheckbox(count, element, chkElement) 
	{
		var chkCount = 0;
		
		for (var i = 0; i < count; i++)
		{
			/*alert("chk = "+document.getElementById(element+i).checked);*/
			if (document.getElementById(element+i).checked)
			{
				chkCount++;
			}
		}
		
		/*alert("count = "+ count +" chkCount = "+ chkCount);*/
		if (count == chkCount)
		{
			document.getElementById(chkElement).checked = true;
		}
	}
	
	/* ***************************** Server Response ************************************* */
	
	var httpRequest; 
	var xmlHTTPResponse; 
	var isServerBusy = false;
	
	if (window.ActiveXObject) /*code for IE6, IE5*/
	{
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	else if (window.XMLHttpRequest) /*code for IE7+, Firefox, Chrome, Opera, Safari*/
	{ 
		httpRequest = new XMLHttpRequest(); 
	}
	
	function makeRequest( url, setColumnValues )
	{
		var sURL = unescape(window.location);
	
		if( ! isServerBusy )
		{
	  		isServerBusy = true;
			httpRequest.open("POST", url, false);
			httpRequest.onreadystatechange = function()
			{
				receiveResponse( setColumnValues );
			};
		
			httpRequest.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );
			httpRequest.send( null );
		}
	}

	function receiveResponse( setColumnValues )
	{
		if (httpRequest.readyState == 4)
		{
			if(httpRequest.status == 200) 
			{
		  		processResponse( setColumnValues );
			}
			else 
			{
				alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
			}
		}
	}

	function processResponse( setColumnValues )
	{
	    var returnStr = null;
		isProcessOn = false;
		
		if ( window.ActiveXObject )
		{   
			xmldoc = httpRequest.responseText;
			xmlHTTPResponse = xmldoc;
		}
		else
		{   
			try
			{
		  		var parser = new DOMParser();
		  		xmldoc = httpRequest.responseText;
			}
			catch(e)
			{
		   		alert("inside catch:"+e.message);
			}
		}

		setColumnValues( xmldoc );
		isServerBusy = false;
	}
	
	function loadXMLString(txt)
	{
		if (window.DOMParser)
	  	{
	  		parser=new DOMParser();
	  		xmlDoc=parser.parseFromString(txt,"text/xml");
	  	}
		else /* code for IE*/
		{
	  		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	  		xmlDoc.async=false;
	  		xmlDoc.loadXML(txt);
	  	}
		
		return xmlDoc;
	}
	
	function setColumnValues( retVal )
	{
		var xmldoc = null;
		var count = 0;
		
		retVal = retVal.replace(/(\r\n|\n|\r)/g, '');
		
		xmldoc = loadXMLString(retVal);
		
		if( xmldoc.nodeType != 9 )
		{
			return true;
		}
		
		var x = xmldoc.getElementsByTagName("PROD_SIZE");
		
		/*alert("val "+ xmldoc.getElementsByTagName("Root")[0].childNodes[1].nodeName);*/
		
		if (x.length > 0)
			appendSizesRow();
		
		var sizesValue = new Array();
		
		for (var i = 0; i < x.length; i++) 
	    {
	    	if (x[i].nodeName != null && x[i].nodeName != undefined)
	    	{
	    		var y = x[i].childNodes;
	    		
	    		/*alert("1 = ["+ x[i].childNodes[0].childNodes[0].nodeValue +"]");
	    		alert("2 = ["+ x[i].childNodes[1].childNodes[0].nodeValue +"]");*/
	    		
	    		if (x[i].childNodes[0] != undefined)
				{
	    			var tr = tr + "<tr onclick='chkSizes(event, "+ count +")'>";
	    		
		    		for (var j = 0; j < y.length; j++)
		    		{
		    			if (y[j].nodeName != null && y[j].nodeName != undefined)
		    			{
		    				if (y[j].childNodes[0] != undefined)
		    				{
		    					if (j == 0)
		    					{
		    						sizesValue.push(y[1].childNodes[0].nodeValue);
		    						tr = tr + "<td><input type='checkbox' value='' id=chkid"+count+" onClick='sizeValues()' /></td>";
		    						count++;
		    					}
		    					
		    					tr = tr + "<td>"+ y[j].childNodes[0].nodeValue +"</td>";
		    				}
		    			}
		    		}

		    		tr = tr + "</tr>";
				}
	    	}
	    }
	    
	    $("#sizeDtl tbody").append(tr);
	    
	    var count = $('#sizeDtl tbody tr').length;

		for (var i = 0; i < count; i++)
		{
			document.getElementById("chkid"+i).value = sizesValue[i];
		}
	}
	
	function isNumeric(element) 
	{
		if (isNaN(parseFloat(element.value)))
		{
			document.getElementById(""+element.id).value = "0.000";
        	setTimeout(function(){element.focus();}, 1);
        	return false;
		}
		
		if (element.value == "")
			element.value = 0;
		
		document.getElementById(""+element.id).value = (parseFloat(element.value)).toFixed(3);
		return true;
	}
	
	/**
	 * exapanding Div
	 */
	function expandDiv()
	{
		if (document.getElementById("showDiv").value == "1")
		{
			document.getElementById("headerDiv").style.visibility = 'hidden';
			document.getElementById("headerDiv").style.height = 0+"%";
			document.getElementById("detailDiv").style.height = 99+'%';
			document.getElementById("detail").style.height = 70+'%';
			document.getElementById("showDiv").value = "0";
			document.getElementById("showDiv").src = "/ibase/webitm/images/DD/collapse1.png";
			document.getElementById("showDiv").title = "Collapse";
		}
		else
		{
			document.getElementById("headerDiv").style.visibility = 'visible';
			document.getElementById("headerDiv").style.height = 40+"%";
			document.getElementById("detailDiv").style.height = 60+'%';
			document.getElementById("detail").style.height = 150+'px';
			document.getElementById("showDiv").value = "1";
			document.getElementById("showDiv").src = "/ibase/webitm/images/DD/expand1.png";
			document.getElementById("showDiv").title = "Expand";
		}
	}
	
	/* *************************** Creating Div Start ********************************** */
	
    var popupWindow = null;
    var popupIsShown = false;
    
    function MakePopup (event) 
    {
        if (window.createPopup) 
        {        
            if (!popupWindow) 
            {
                popupWindow = window.createPopup ();
                var popupBody = popupWindow.document.body;
                popupBody.style.backgroundColor = "lightblue";
                popupBody.style.border = "solid black 1px";
                popupBody.innerHTML = "";
            }
            popupWindow.show (100, 100, 150, 25, document.body);
        }
        else 
        {
            if (!popupIsShown) 
            {
                if (!popupWindow) 
                {
                    popupWindow = document.createElement ("div");
                    popupWindow.id = "someID";
                    popupWindow.style.backgroundColor = "lightblue";
                    popupWindow.style.border = "solid black 1px";
                    popupWindow.style.position = "absolute";
                    /*popupWindow.style.width = "400px";*/
                    popupWindow.style.height = "300px";
                    popupWindow.style.top = "60px";
                    popupWindow.style.right = "100px";
                    popupWindow.className = "fadeInDown";
                    popupWindow.innerHTML = "";
                }

                document.body.appendChild (popupWindow);
                
                /*window.addEventListener ('click', RemovePopup, true);
                popupIsShown = true;
                event.stopPropagation ();*/
            }
        }
    }
    
    function RemovePopup (event) {
    	
        if (popupIsShown) 
        {
            var relation = popupWindow.compareDocumentPosition (event.target);
            var clickInPopup = (event.target == popupWindow) || (relation & Node.DOCUMENT_POSITION_CONTAINED_BY);
            if (!clickInPopup) 
            {
                document.body.removeChild (popupWindow);
                window.removeEventListener ('click', RemovePopup, true);
                popupIsShown = false;
            }
        } 
    }
    
    /* ****** Creating Div End ********** */
    
   // Expand/Collapse all
    /*$('.accordion-expand-collapse a').click(function() {
        $('.accordion .ui-accordion-header:not(.ui-state-active)').next().slideToggle();
        $(this).text($(this).text() == 'Expand all' ? 'Collapse all' : 'Expand all');
        $(this).toggleClass('collapse');
        return false;
    });*/
