function check_date()
{
    var field = document.getElementById("ctl00_CP_ddlMonth").value + "/" + document.getElementById("ctl00_CP_ddlDay").value + "/" + document.getElementById("ctl00_CP_ddlYear").value;
    var checkstr = "0123456789";
    var DateField = field;
    var Datevalue = "";
    var DateTemp = "";
    var seperator = "/";
    var day;
    var month;
    var year;
    var leap = 0;
    var err = 0;
    var i;
    var sErrorMsg = "";
   err = 0;
   DateValue = DateField;
   
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++)
   {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0)
	  {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   if(!chkPrevDate(month,day,year))
   {
    err = 27;
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      //DateField.value = month + seperator + day  + seperator + year;
      return true;
   }
   /* Error-message if err != 0 */
   else 
   {
     return false;
   }  
}

function chkPrevDate(month,day,year)
{
	var result= false;
	
	// System Dates
	var strfulldate = new Date()		
	var strMonth = strfulldate.getMonth() + 1;
	var strDate = strfulldate.getDate()
	var strYear = strfulldate.getFullYear();
		
	if(year > strYear)
		result = true;
	else if(year == strYear)
	{
		if(month == strMonth)
		{
			if(day > strDate)
				result = true;
		}
		else if(month > strMonth)
		    result = true;
	}
	return result;
}
function loadCountries(dropCountry)
{
    var CountryArray;
    ClearDropDown(dropCountry);

    var Country = new Array();
    Country[1] = 'Afganistan,Alaska,Albania,Algeria,American Samoa,Andorra,Angola,Anguilla,Antigua and Barbuda,Argentina,Armenia,Australia,Austria,Azerbaijan,Bahamas,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bermuda,Bhutan,Bolivia,Bosnia-Hercegovina,Botswana,Brazil,British Virgin Islands,Brunei-Darussalam,Bulgaria,Burkina Faso,Burma-Myanmar,Burundi,Cambodia,Cameroon,Canada,Cape verde,Cayman Islands,Central African Republic,Chad,Chile,China,Colombia,Comoros,Congo,Costa Rica,Cote dIvoire,Croatia,Cuba,Curacao,Cyprus,Czeck Republic,Denmark,Djibouti,Dominica,Dominican Republic,East Timor,Ecuador,Egypt,El Salvador,England,Equatorial Guinea,Eritrea,Estonia,Ethiopia,European Rusia,Fiji,Finland,France,French Guiana,French Polynesia,Gabon,Gambia,Georgia,Germany,Ghana,Greece,Greenland,Grenada,Guadeloupe,Guam,Guatemala,Guinea,Guinea-Bissau,Guyana,Haiti,Hawaii,Honduras,Hong Kong,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Israel,Italy,Ivory Coast,Jamaica,Japan,Jordan,Kazakhstan,Kenya,Kiribati,Kuwait,Kyrgyzstan,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macedonia,Madagascar,Malawi,Malaysia,Maldives,Mali,Marshall Islands,Martinique,Mauritania,Mauritius,Mayotte,Mexico,Micronesia,Moldova,Mongolia,Montserrat,Morocco,Mozambique,Myanmar,Namibia,Nauru,Nepal,Netherlands,New Caledonia,New Zealand,Nicaragua,Niger,Nigeria,North Korea,Norway,Oman,Pakistan,Palau,Palestine,Panama,Papua New Guinea,Paraguay,Peru,Philippines,Poland,Portugal,Puerto Rico,qatar,Reunion,Romania,Russia,Rwanda,Saint Helena,St. Kitts and Nevis,St. Lucia,St. Pierre and Miquelon,St. Vincent Grenadines,Samoa,San Marino,Sao Tome and Principe,Saudi Arabia,Scotland,Senegal,Seychelles,Sierra Leone,Singapore,Slovakia,Slovenia,Solomon Islands,Somalia,South Africa,South Korea,Spain,Sri Lanka,Sudan,Suriname,Swaziland,Sweden,Switzerland,Syria,Taiwan,Tajikistan,Tanzania,Thailand,Togo,Tonga,Trinidad and Tobago,Tunisia,Turkey,Turkmenistan,Uganda,Ukraine,United Arab Emirates,Uruguay,US Virgin Islands,Uzbekistan,Vanuatu,Venezuela,Vietnam,Wales,Yemen,Yugoslavia,Zambia,Zimbabwe';
    CountryArray = Country[1].split(',');

    loadDropDown(dropCountry,"Select Country","");     
 
    for (var i = 0; i < CountryArray.length; i++)
    {
        if (CountryArray[i])
        {
           loadDropDown(dropCountry,CountryArray[i],CountryArray[i]);        
        }
    }
}	
	
 function loadDropDown(dropDown,text,value)
 {   
    var o = dropDown.options;
    var nIdx;
	if (o.length < 0) 
		nIdx = 0;
	else
		nIdx = o.length;
		
	o[nIdx] = new Option(text,value);
}

function ClearDropDown(dropDown) 
{
   var i = 0;
   var o = dropDown.options;

    for (i = o.length; i >= 0; --i)
		o[i] = null;
}
//function findZip(Frm,tZip,st,city,theme){var url;LeftPosition = (screen.width) ? (screen.width-630)/2 : 0;TopPosition = (screen.height) ? (screen.height-270)/2 : 0;features = 'height='+300+',width='+500+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no';url = '/scripts/zip.aspx?fm='+Frm +'&tzip='+tZip +'&st='+ st+'&city='+ city+'&t='+theme;window.open(url,'zhelp',features);}
function findZip(Frm, tZip, st, city, theme) { var pgHeight = 0; if (self.innerHeight) { pgHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { pgHeight = document.documentElement.clientHeight; } else if (document.body) { pgHeight = document.body.clientHeight; } if (document.body.offsetHeight > pgHeight) { pgHeight = document.body.offsetHeight; } var divBg = document.createElement("div"); divBg.id = "dvBG"; divBg.className = "dvbg"; divBg.style.width = '100%'; divBg.style.height = pgHeight + 'px'; divBg.style.position = 'absolute'; document.body.appendChild(divBg); var point = window.center({ width: 320, height: 200 }); var dvZip = document.createElement("div"); dvZip.id = "dvZip"; dvZip.style.background = "#ffffff"; dvZip.style.border = "4px solid #cccccc"; dvZip.innerHTML = '<iframe src="/zip.aspx?fm=' + Frm + '&tzip=' + tZip + '&st=' + st + '&city=' + city + '&t=' + theme + '" width="320" height="200" frameborder="0" scrolling="auto" bgcolor="#ffffff" />'; dvZip.className = "dvzip"; dvZip.style.top = point.y + "px"; dvZip.style.left = point.x + "px"; dvZip.style.position = 'absolute'; document.body.appendChild(dvZip); }
// Returns the size of the browser window based on the browser and its mode.
window.size = function () { var w = 0; var h = 0; if (!window.innerWidth) { if (!(document.documentElement.clientWidth == 0)) { w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else { w = document.body.clientWidth; h = document.body.clientHeight; } } else { w = window.innerWidth; h = window.innerHeight; } return { width: w, height: h }; }
// Returns top & left position required to center a div tag in a browser window.
window.center = function () { var hWnd = (arguments[0] != null) ? arguments[0] : { width: 0, height: 0 }; var _x = 0; var _y = 0; var offsetX = 0; var offsetY = 0; if (!window.pageYOffset) { if (!(document.documentElement.scrollTop == 0)) { offsetY = document.documentElement.scrollTop; offsetX = document.documentElement.scrollLeft; } else { offsetY = document.body.scrollTop; offsetX = document.body.scrollLeft; } } else { offsetX = window.pageXOffset; offsetY = window.pageYOffset; } _x = ((this.size().width - hWnd.width) / 2) + offsetX; _y = ((this.size().height - hWnd.height) / 2) + offsetY; return { x: _x, y: _y }; }
//Check Shockwave Plugin
function CheckFlashPlugin() { if (window.ActiveXObject) { try { var objFlash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if (objFlash) { document.getElementById('flashContent').style.display = ""; } else { document.getElementById('flashContent').innerHTML = ""; } } catch (e) { } } else { var pluginInstalled = 0; for (var i = 0; i < navigator.plugins.length; i++) { if (navigator.plugins[i].name.indexOf('Flash') != -1) { pluginInstalled = 1; break; } } if (pluginInstalled == 1) { document.getElementById('flashContent').style.display = ""; } else { document.getElementById('flashContent').innerHTML = ""; } } }
// Returns the top & left positions of a given control in a page.
function FindCtrlPos(obj) { var curleft = 0, curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft; curtop += obj.offsetTop; obj = obj.offsetParent; } } else { if (obj.x) { curleft += obj.x; } if (obj.y) { curtop += obj.y; } } return { top: curtop, left: curleft }; }
function ChkPhone(id1, id2, id3, msg) { var err = '', flag = 'no'; var areacode = ['201', '202', '203', '204', '205', '206', '207', '208', '209', '210', '211', '212', '213', '214', '215', '216', '217', '218', '219', '224', '225', '226', '228', '229', '231', '234', '236', '239', '240', '242', '246', '248', '249', '250', '251', '252', '253', '254', '256', '260', '262', '264', '267', '268', '269', '270', '276', '278', '280', '281', '282', '283', '284', '289', '301', '302', '303', '304', '305', '306', '307', '308', '309', '310', '311', '312', '313', '314', '315', '316', '317', '318', '319', '320', '321', '323', '325', '327', '330', '331', '334', '336', '337', '339', '340', '341', '343', '345', '347', '351', '352', '353', '354', '358', '360', '361', '369', '380', '381', '383', '385', '386', '401', '402', '403', '404', '405', '406', '407', '408', '409', '410', '411', '412', '413', '414', '415', '416', '417', '418', '419', '420', '423', '424', '425', '430', '432', '434', '435', '438', '440', '441', '442', '443', '445', '450', '456', '458', '464', '469', '470', '473', '475', '478', '479', '480', '484', '500', '501', '502', '503', '504', '505', '506', '507', '508', '509', '510', '511', '512', '513', '514', '515', '516', '517', '518', '519', '520', '530', '531', '533', '534', '540', '541', '546', '551', '557', '559', '561', '562', '563', '564', '567', '570', '571', '573', '574', '575', '579', '580', '581', '585', '586', '590', '600', '601', '602', '603', '604', '605', '606', '607', '608', '609', '610', '611', '612', '613', '614', '615', '616', '617', '618', '619', '620', '623', '626', '627', '628', '630', '631', '636', '641', '646', '647', '649', '650', '651', '657', '660', '661', '662', '664', '669', '670', '671', '678', '679', '681', '682', '684', '689', '700', '701', '702', '703', '704', '705', '706', '707', '708', '709', '710', '711', '712', '713', '714', '715', '716', '717', '718', '719', '720', '721', '724', '727', '731', '732', '734', '737', '740', '747', '752', '754', '757', '758', '760', '762', '763', '764', '765', '767', '769', '770', '772', '773', '774', '775', '778', '779', '780', '781', '784', '785', '786', '787', '800', '801', '802', '803', '804', '805', '806', '807', '808', '809', '810', '811', '812', '813', '814', '815', '816', '817', '818', '819', '822', '828', '829', '830', '831', '832', '833', '835', '836', '843', '844', '845', '847', '848', '849', '850', '855', '856', '857', '858', '859', '860', '861', '862', '863', '864', '865', '866', '867', '868', '869', '870', '871', '872', '876', '877', '878', '880', '881', '882', '888', '900', '901', '902', '903', '904', '905', '906', '907', '908', '909', '910', '911', '912', '913', '914', '915', '916', '917', '918', '919', '920', '925', '928', '931', '935', '936', '937', '938', '939', '940', '941', '947', '949', '951', '952', '954', '956', '957', '959', '969', '970', '971', '972', '973', '975', '976', '978', '979', '980', '984', '985', '989', '999']; for (var x = 0; x < areacode.length; x++) { if (areacode[x] == document.getElementById(id1).value) { flag = "yes"; } } if (flag != "yes") { err += "\n- Enter AreaCode as first three digits in " + msg; document.getElementById(id1).focus(); } var ph2Val = trim(document.getElementById(id2).value); if (ph2Val.length != 3 || isNaN(ph2Val)) { err += "\n- Enter second three valid digits for " + msg; document.getElementById(id2).focus(); } var ph3Val = trim(document.getElementById(id3).value); if (ph3Val.length != 4 || isNaN(ph3Val)) { err += "\n- Enter last four valid digits for " + msg; document.getElementById(id3).focus(); } return err; }
function ChkEmail(id, msg) { var exclude = /[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/; var check = /@[\w\-]+\./; var checkend = /\.[a-zA-Z]{2,3}$/; var err = ""; var val = trim(document.getElementById(id).value); if (val == '') { err = '\n- ' + msg + ' is required'; document.getElementById(id).focus(); } else { if (((val.search(exclude) != -1) || (val.search(check)) == -1) || (val.search(checkend) == -1)) { err = '\n- ' + msg + ' is invalid'; document.getElementById(id).focus(); } } return err; }
//Function Used to get the Item Details with XML Posting
var colObjVal = "0";
function QFCustomerDetails(cName, cObj, srvId) {
    var cphId = cObj.replace(cName, '');
    if ((cObj).indexOf("3") != "-1") { if (trim(GetPhoneValue(cObj.replace(cName, '')).replace('Ext-', '')) != "" && ChkPhone(cphId + 'txtHphone1', cphId + 'txtHPhone2', cObj, 'Phone Number') == "") { colObjVal = "1"; } }
    else if (trim(document.getElementById(cObj).value) != "" && ChkEmail(cObj, 'Email Address') == "") { colObjVal = "1"; }
    if (colObjVal == "1") {
        var xmlHttpReq = false;
        var self = this;
        var XMLHttpFactories = [function () { return new XMLHttpRequest() }, function () { return new ActiveXObject("Msxml2.XMLHTTP") }, function () { return new ActiveXObject("Msxml3.XMLHTTP") }, function () { return new ActiveXObject("Microsoft.XMLHTTP") } ];
        for (var i = 0; i < XMLHttpFactories.length; i++) {
            try { self.xmlHttpReq = XMLHttpFactories[i](); }
            catch (e) { continue; }
            break;
        }
        var FName = "", LName = "", phoneNo = "", email = "";
        FName = document.getElementById((cObj).replace(cName, 'txtFname')).value;
        LName = document.getElementById((cObj).replace(cName, 'txtLname')).value;
        email = document.getElementById((cObj).replace(cName, 'txtEmail')).value;
        phoneNo = GetPhoneValue(cObj.replace(cName, ''));
        self.xmlHttpReq.open('POST', '/qfcustomerpost.aspx?flag=custData&srvId=' + srvId + '&FName=' + FName + '&LName=' + LName + '&phoneNo=' + phoneNo + '&email=' + email, true);
        self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        self.xmlHttpReq.onreadystatechange = function () {
            if (self.xmlHttpReq.readyState == 4) {
                var strResult = self.xmlHttpReq.responseText;
            }
        }
        self.xmlHttpReq.send('');
    }
}
function GetPhoneValue(cphId) {
    return document.getElementById(cphId + 'txtHphone1').value + " " + document.getElementById(cphId + 'txtHPhone2').value + " " + document.getElementById(cphId + 'txtHphone3').value + "  Ext-";
}


























   


