/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Prototype dollar function
 * This function returns Object of given ellement.
 * It is a alternative of document.getElementById.
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-01, 2010..
 */

function $$()
{
    var elements = new Array ();
    for (var i = 0; i < arguments.length; i++)
    {
            var element = arguments[i];
            if (typeof element == 'string')
            {
                    element = document.getElementById(element);
            }
            if (arguments.length == 1)
            {
                    return element;
            }
            elements.push(element);
    }
    return elements;
}

/**
 * This function will call on body load and will contain various functions
 * or peace of code need to call on body load.
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-03, 2009
 */
function CallOnBodyLoad(PAGE_NAME)
{
    //alert("called");
    /**
    * These line of code written for refresh hidden field of slide counter
    * Written on Feb-03, 2010
   */
}

/**
 * LoadAjaxData is used various kind of AJAX request.
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-03, 2010
 * @param string url                url of called script / page.
 * @param string container          Id of div container / html element id where data to be filled or need to show responce text
 * @param string post_vars          Values to be posted to the called script page, will send as querystring format without question mark sign
 * @param string datatype           Can be leave blank (''), Type of data to be return by script. xml, json, script, or html
 * @param string method             Method of data will be sended to the server by POST / GET
 * @param boolean cache             true / false, If set to false it will force the pages that you request to not be cached by the browser.
 * @param boolean async             All requests are sent asynchronous. If you need synchronous requests,
 *                                  set this option to false. Note that synchronous requests may temporarily
 *                                  lock the browser, disabling any actions while the request is active.
 * @param string clickedObjectName  Buttion name which need to enable and desiable at the time of AJAX request running.
 * Use of this function ::          this function can be use to execute a single or multiple responces with the specified
 *                                  combination of parameter. Parameter will be pass in script whch will be return with responce.
 *                                  ie. %!-%ALERT MESSAGE%-!% JavaScript alert will popup
 *                                  %T-%PAGE TITLE%-T% Page title will be change
 *                                  %F-%JavaScript Code comes here%-F% JavaScript code will run and it will pass without any newline continus with terminetor semicolon.
 *                                  %U-%URL TO BE REDIRECTED%-U% URL which need to be redirected.
 *                                  %P-%CONTENT%-P% any HTML or plane TEXT content will be set to passed container
 *                                  If there is no parameter then everything will be displaied to the given container.
 *                                  If container name is blank and not perameerer is found in responce then just called script will run and nothing will happen for client browser.
 */
function LoadAjaxData(url, container, post_vars, datatype, method, cache, async, clickedObjectName)
{
    //alert(url + '?' + post_vars);
    //alert(container);
    $$('DIVStatus').style.display = 'block';
    $$('DIVStatus').innerHTML = 'Loading...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<a href=\"#\" onclick=\"$$(\'DIVStatus\').style.display = \'none\'; ;return false;\">X</a>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    if (clickedObjectName == '[object HTMLInputElement]')
    {
        clickedObjectName.disabled = true;
    }
    
    method = (method != 'GET' && method != 'POST') ? 'GET' : method;
    cache = (cache == '') ? true : cache;
    async = (async == '') ? true : async;
    //alert (url + '?' + post_vars);
    function successHandler (responseText)
    {
        //alert (responseText);
        // Use the response, parsing Smart Tags first
        if (responseText.indexOf ("%!-%") != -1 && responseText.indexOf ("%-!%") != -1) // send a JavaScript !alert!
        {
                alert (responseText.substring (responseText.indexOf ("%!-%") + 4, responseText.indexOf ("%-!%")));
        }

        if (responseText.indexOf ("%T-%") != -1 && responseText.indexOf ("%-T%") != -1) // send a JavaScript !alert!
        {
                document.title = responseText.substring (responseText.indexOf ("%T-%") + 4, responseText.indexOf ("%-T%"));
        }

        if (responseText.indexOf ("%U-%") != -1 && responseText.indexOf ("%-U%") != -1) // go to a URL
        {
                self.location.replace (responseText.substring (responseText.indexOf ("%U-%") + 4, responseText.indexOf ("%-U%")));
        }
        else if (container && responseText.indexOf ("%P-%") != -1 && responseText.indexOf ("%-P%") != -1) // replace the inner HTML of the page area with the PHP script's response
        {
                $$(container).innerHTML = responseText.substring (responseText.indexOf ("%P-%") + 4, responseText.indexOf ("%-P%"));
        }
        else if (container && responseText.indexOf ("%P-%") == -1 && responseText.indexOf ("%F-%") == -1 && responseText.indexOf ("%T-%") == -1 && responseText.indexOf ("%U-%") == -1 && responseText.indexOf ("%!-%") == -1)
        {
                $$(container).innerHTML = responseText;
        }

        if (responseText.indexOf ("%F-%") != -1 && responseText.indexOf ("%-F%") != -1) // Call a function or run a javascript
        {
                window.eval (responseText.substring (responseText.indexOf ("%F-%") + 4, responseText.indexOf ("%-F%")));
        }
    }

    jQuery.ajax({
            type: method,
            url: url,
            data: post_vars,
            cache: cache,
            dataType: datatype,
            async: async,
            success: function(responseText)
            {
                $$('DIVStatus').style.display = 'none';
                successHandler (responseText);
                if (clickedObjectName == '[object HTMLInputElement]')
                    clickedObjectName.disabled = false;
            },
            error: function(xhr, textStatus, errorThrown)
            {
                $$('DIVStatus').innerHTML = 'ERROR in connection...&nbsp;&nbsp;Please check your internet connection and refresh this page then try again.&nbsp;&nbsp;&nbsp;[<a href=\"#\" onclick=\"$$(\'DIVStatus\').style.display = \'none\'; ;return false;\">X</a>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                //alert('Connection failed.');
                //$$('DIVStatus').style.display = 'none';
                if (clickedObjectName == '[object HTMLInputElement]')
                    clickedObjectName.disabled = false;
            }
        });
}



/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

/**
 * Simplify CookieHandler to Get cookei
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-10, 2010
 * @param string name       Key name of the cookie
 * @return string cookie value
 */
function GetCookie(name)
{
    var Cookies = new CookieHandler();
    if (typeof(Cookies.getCookie(name)) == 'undefined')
        return '';
    else
        return Cookies.getCookie(name);
}

/**
 * Simplify CookieHandler to Set cookei
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-10, 2010
 * @param string name       Key name of the cookie
 * @param string valu       Value of cookie to be set
 * @param string time       Optional :: Time when cookie will expire
 * @return Boolean
 */
function SetCookie(name, value, time)
{
   var Cookies = new CookieHandler();
    Cookies.setCookie(name, value, time);
    if (typeof(Cookies.getCookie(name)) == 'undefined')
        return false;
    else if (Cookies.getCookie(name) == value)
        return true;
    else
        return false;
}

/**
 * Simplify CookieHandler to Delete cookei
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-10, 2010
 * @param string name       Key name of the cookie
 * @return Boolean
 */
function DelCookie(name)
{
    var Cookies = new CookieHandler();
    Cookies.deleteCookie(name);
    if (typeof(Cookies.getCookie(name)) == 'undefined')
        return true;
    else
        return false;
}

/**
 * Object is used to get and set cookies through javascript without refreshing the page.
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-10, 2010
 * @param string KEY        Key name of the cookie
 * @param string VALUE      Value of cookie
 * @param string TIME       Time of deletion of cookie in seconds
 * Use of this function ::
 *                          var Cookies = new CookieHandler();
 *                          Cookies.getCookie(KEY);
 *                          Cookies.setCookie(KEY, VALUE, TIME);
 *                          (typeof(Cookies.getCookie('KEY')) == 'undefined')
 */
function CookieHandler()
{
	this.setCookie = function (name, value, seconds)
        {
		if (typeof(seconds) != 'undefined')
                {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else
			var expires = "";

		document.cookie = name + "=" + value + expires + "; path=/";
	}

	this.getCookie = function (name)
        {
		name = name + "=";
		var carray = document.cookie.split(';');

		for(var i = 0; i < carray.length; i++)
                {
			var c = carray[i];
			while (c.charAt(0) == ' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
		return null;
	}
	this.deleteCookie = function (name)
        {
		this.setCookie(name, "", -1);
	}
}

/**
 * Function is use to Add Products to Shopping cart or Wishlist in Cookies
 * @author Rajneesh Maurya <- rajneesh@exemplarindia.net ->
 * Written on Feb-11, 2010
 * @param string idProduct  Id of Product to be added
 * @param float Quantity    Quantity of product
 * @param string idOffer    Offer Id which was selected
 * @param string Message    Message to be displaied on click if send NO then no message will display or if blank then default message will popup
 * @param string BaseURL    Base URL of application returned by Yii
 * @param string DIVname    Div or contenor name where return value will display by AJAX
 * @param string SetFor     SetFor must be ShoppingCart / ShortList is used as cookie name
 */
function AddToCart(idProduct, Quantity, Message, URL, DIVname, SetFor, idBuyer)
{
    idBuyer = (!idBuyer || idBuyer == '') ? 0 : idBuyer;
    
    var redirectTo = '';
    if (idBuyer > 0 && SetFor == 'ShortList')
    {
       // alert(URL + '&idUser=' + idBuyer + '&idProduct=' + idProduct + '&Quantity=' + Quantity);
            LoadAjaxData(URL ,DIVname, 'idUser=' + idBuyer + '&idProduct=' + idProduct + '&Quantity=' + Quantity + '&idOffer=' + idOffer, '', 'POST', '', '');
    }
    else
    {
            if (SetFor == 'BuyNow')
            {
                SetFor = 'ShoppingCart';
                redirectTo = URL.replace('site/shoppingcart', 'site/checkout');
            }
			else if (SetFor == 'AddToCart')
			{
				SetFor = 'ShoppingCart';
				redirectTo = URL.replace('site/shoppingcart', 'site/productlist');
			}
			else if (SetFor == 'ShoppingCart')
			{
				redirectTo = URL;
			}
            SetFor = (!SetFor || SetFor == '') ? 'ShoppingCart' : SetFor; // SetFor = ShoppingCart / ShortList
            var shopping_cart = GetCookie(SetFor);
            shopping_cart =  (!shopping_cart) ? '' : shopping_cart;
            shopping_cart += ((!shopping_cart) ? '' : '#') + idProduct + '!=!' + Quantity;
            shopping_cart = shopping_cart.replace (/##/, "#");
            SetCookie(SetFor, shopping_cart);

            var message_append = (SetFor == 'ShoppingCart') ? ' shopping cart.' : ' short list.'

            if (Quantity < 0)
            {
                    Quantity = Quantity * (-1);
                    M_add_remove = " removed from ";
            }
            else
            {
                    M_add_remove = " added to ";
            }

            M_plural = (Quantity == 1) ? '' : 's';
            if (Message == '')
            {
                    alert (Quantity + ' item' + M_plural + M_add_remove + message_append);
            }
            else if (Message != 'NO')
            {
                    alert (Message);
            }
            //alert(URL);
            //alert(DIVname);
            if (redirectTo != '')
                location.href = redirectTo;
            else
                LoadAjaxData(URL , DIVname, '' , '', 'POST', '', '', '');
    }
}

/**
 * Function is use to Validate user inputs
 * @author Rajneesh Maurya <- rajneesh@wirefootindia.com ->
 * Written on Feb-16, 2010
 * @param string data       Data to be validated
 * @param string data_type  String value of data type ie.
 *                          email / zipCode / Currency / Time / Date / phoneNumber / phoneNumberInternational / int / float / alpha / alpha_numeric / name
 * @param string inChar     String value (can be blank) of special characters will be allowed. ie. if we want to allow _,-,. in alpha data type then we will use inChar = "_-.", this do not need with data types under "check patern"
 */
function validate_data (data, data_type, inChar)
{
	if (data_type == "email")   //matches email
	{
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "zipCode")  // Matches a US zip Code (ie: 12345 or 12345-1234)
	{
		var filter = /\d{5}(-\d{4})?/;
		if (filter.test(data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "Currency")  // matches $17.23 or $14,281,545.45 or ...
	{
		var filter = /\$\d{1,3}(,\d{3})*\.\d{2}/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "Time")  // matches 5:04 or 12:34 but not 75:83
	{
		var filter = /^([1-9]|1[0-2]):[0-5]\d$/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "Date")  // Date xx/xx/xxxx
	{
		var filter = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "phoneNumber")  // matches phone ###-###-####Matches US phone (###-###-#### or (###) ###-####)
	{
		var filter = /^\(?\d{3}\)?\s|-?\.?\d{3}-?\.?\d{4}$/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}
	else if (data_type == "phoneNumberInternational")  // International Phone Number
	{
		var filter = /^\d(\d|-){7,20}/;
		if (filter.test (data))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}

       
	// Check one by one charector
	for (var i = 0; i < data.length; i++)
	{
		var ch = data.substring(i, i + 1);
		if ((data_type == "int" && (ch < "0" || "9" < ch) && ! InCheck(ch,inChar)) || (data_type == "float" && (ch < "0" || "9" < ch) && ch!="." && ! InCheck(ch,inChar)) || (data_type == "alpha" && (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && ! InCheck(ch,inChar)) || (data_type == "alpha_numeric" && (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch < "0" || "9" < ch) && ! InCheck(ch,inChar)) || (data_type == "name" && (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && ch!=" " && ch!="." && ! InCheck(ch,inChar)))
		{
			return (false);
		}
	}
	return (true);
}

    function compare(oldVal,newVal)
    {
            if(oldVal == newVal)
            {
            return (true);
            }
            return (false);
     }
     
    function isNull(aStr)
    {
              var index;
              for (index=0; index < aStr.length; index++)
              if (aStr.charAt(index) != ' ')
              {
              return (true);
              }
              else
              {
               return (false);
              }
    }
    
    function isCheckNo(aStr, num)
    {
            var reNum=/^[0-9.]+$/;
            if( reNum.test(aStr)) {
                if (aStr.length >= num)
                    return (true);
                else
                    (false);
            }
            return (false);
    }
 
/**
 * Function is use to Validate chareactors in given string
 * @author Rajneesh Maurya <- rajneesh@wirefootindia.com ->
 * Written on Feb-16, 2010
 * @param string sText
 * @param string ValidChars
 */
function InCheck (sText, ValidChars)
{
	if (ValidChars != "")
	{
		var validate=true;
		var Char;

		for (i = 0; i < sText.length && validate == true; i++)
		{
			Char = sText.charAt (i);
			if (ValidChars.indexOf (Char) == -1)
			validate = false;
		}
		return (validate);
	}
	else
	{
		return (false);
	}
}

function checkRadio(m, f)
{
    if (m.checked == false && f.checked == false)
    {
        return false;
    }
 return  true;
}
/**
 * Function is use to Add shashes in javascript
 * @author Rajneesh Maurya <- rajneesh@wirefootindia.com ->
 * Written on Feb-16, 2010
 * @param string str
 * @return string slashed string
 */
function addslashes(str)
{
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

/**
 * Function is use to Remove shashes in javascript
 * @author Rajneesh Maurya <- rajneesh@wirefootindia.com ->
 * Written on Feb-16, 2010
 * @param string slashed string
 * @return string normal string
 */
function stripslashes(str)
{
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

/**
 * Function is use to Remove newline (\n)in javascript
 * @author Rajendra Kumar <- rajendra@exemplarindia.net ->
 * Written on Feb-16, 2010
 * @param string string containing newline charecter
 * @return string <BR> tag appended string
 */
function stripnewline(str)
{
        str = str.replace(/\n/g, '<br />');
        str = str.replace(/\r/g, '<br />');
        return str;closeOverLay
}

function GetXY(event)
{
	//alert(event.type);
	var isIE = document.all ? true : false;
	if (!isIE)
	{
    	pos_x = event.pageX; // + document.getElementById("FeedBackBTN").offsetLeft;
		
		pos_y = event.pageY; // + document.getElementById("FeedBackBTN").offsetTop;
	}
	else
	{
		pos_x = event.clientX; // + document.getElementById("FeedBackBTN").offsetLeft;
		
		pos_y = event.clientY; // + document.getElementById("FeedBackBTN").offsetTop;
	}
	//pos_x = event.pageX;
	//pos_y = event.pageY;
	return new Array(pos_x, pos_y);
}

function GetOffsetXY(event, DIV)
{
        pos_x = $$(DIV).offsetLeft;
	pos_y = $$(DIV).offsetTop;
	return new Array(pos_x, pos_y);
}

    
function RestrictSpace(element)
{
   // alert(element.id);
   var str = element.value;
   if(str == '')
    {
        //alert('ok');
        element.value="";
        element.id.focus();
    }
    else
    {
        var arrStr = str.split('');
        var newStr = '';
        for (var i = 0; i < arrStr.length; i++)
        {
              var hh = arrStr[i].charCodeAt(0);
              if (i==0 && arrStr[i] == ' ')
              {
                  break;
              }
              else
              {
                  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh == 32))
                   {
                         newStr += arrStr[i];
                   }
                   else
                   {
                         Boxy.alert(lang_js['alphanumchar']);
                        break;
                        // return false;
                   }
              }
        }
        element.value = newStr;
    }
    return false;
}
function allowOnlyInt(element)
{
   // alert(element.id);
   var str = element.value;
   if(str == '')
    {
        //alert('ok');
        element.value="";
        element.id.focus();
    }
    else
    {
        var arrStr = str.split('');
        var newStr = '';
        for (var i = 0; i < arrStr.length; i++)
        {
              var hh = arrStr[i].charCodeAt(0);
              if (i==0 && arrStr[i] == ' ')
              {
                  break;
              }
              else
              {
                  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh == 32))
                   {
                         newStr += arrStr[i];
                   }
                   else
                   {
                        // Boxy.alert(lang_js['alphanumchar']);
                       // break;
                        // return false;
                        continue;
                   }
              }
        }
        element.value = newStr;
    }
    return false;
}
function charCount(field,cntfield,maxlimit)
{
   if (field.value.length > maxlimit) // if too long...trim it!
       field.value = field.value.substring(0, maxlimit);// otherwise, update 'characters left' counter
  else
       cntfield.value = maxlimit - field.value.length;
}

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 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(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	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){
		Boxy.alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		Boxy.alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		Boxy.alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		Boxy.alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		Boxy.alert("Please enter a valid date")
		return false
	}
return true
}



