//Date Picker for input text field

$(function()
{
	/*$(".tooltip-target").each( function (i) 
		{
			 $(this).ezpz_tooltip();
		});*/
	//$(".tooltip-target").ezpz_tooltip();
	//$('#body_text *').tooltip();
	$.ui.dialog.defaults.bgiframe = true;	
	$("#dialog").dialog({position: 'top',height:750, width:530, resizable:false, modal:true, draggable: true, autoOpen:false, close: function(event, ui) {closeMyFrame();}});
	
	$('.dp-applied').datepicker({dateFormat: "yy-mm-dd"});
	$('#date').datepicker({dateFormat: "yy-mm-dd"});
	$('#end_date').datepicker({dateFormat: "yy-mm-dd"});
});




var countries = ['Malaysia','Ukraine','Venezuela','Turkey','Thailand','Taiwan','Switzerland','Slovak Republic','Singapore','Russian Federation','Poland','Philippines','Panama','Morocco','Mexico','Macau','Lithuania','Latvia','Korea','Japan','Jamaica','Israel','Indonesia','India','Iceland','Hong Kong','Estonia','Czech Republic','Cyprus','Croatia','Colombia','China','Chile','Brazil','Argentina','United States','South Africa','Botswana','Lesotho','Namibia','Swaziland','Australia','Canada','Ireland','Austria','Belgium','Denmark','France','Greece','Italy','Luxemburg','Nederland', 'Portugal','Spain','Sweden','Finland','New Zealand','England','Wales','Scotland'];
var codes = ['60','380','58','90','66','886','41','421','65','7','48','63','570','212','52','853','370','371','82','81','1','972','62','91','354','852','372','420','357','385','57','86','56','55','54','1','27','267','266','264','268','61', '1','353','43','32','45','33','30','39','352','31','351','34','46','358','64','44','44','44'];
function getCountryCode(selec) {ccode='';for (i = 0;i < 60; i++) {if (countries[i] == $('#'+selec).val()) {ccode = codes[i];}}return "+"+ccode;}

//Masks for Mask Editor
jQuery(function($)
{

		var icount = 0;
		$("#contact_day, #contact_evening, #mobile, #telehpone, #day_phone, #eve_phone, #cell, #ship_phone_day, #ship_phone_eve, #ship_cell, #tel_no, #evening_no, #cell_nr, #bill_phone_day, #bill_phone_eve, #ship_phone").each( function (i) 
		{
			if ($('#personal_country').val() != null) $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("personal_country")+" </span>"); else if ($('#ship_country').val() != null) $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("ship_country")+" </span>"); else if ($('#bill_country').val() != null) $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("bill_country")+" </span>");else $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("country")+" </span>");
			icount = icount + 1;
		});

   $("#date").mask("9999-99-99");
   $("#phone").mask("999 999 9999");
   $("#contact_day").mask("(9)99 999 9999");
   $("#contact_evening").mask("(9)99 999 9999");
   $("#ship_tel1").mask("+99 (9)99 999 9999");
   $("#ship_tel2").mask("+99 (9)99 999 9999");
   $("#ship_tel3").mask("+99 (9)99 999 9999");
   $("#ship_tel4").mask("+99 (9)99 999 9999");
   $("#tel_no").mask("(9)99 999 9999");
   $("#evening_no").mask("(9)99 999 9999");
   $("#ship_phone_day").mask("(9)99 999 9999");
   $("#mobile").mask("(9)99 999 9999");
   $("#telephone").mask("(9)99 999 9999");
   $("#ship_phone_eve").mask("(9)99 999 9999");
   $("#day_phone").mask("(9)99 999 9999");
   $("#eve_phone").mask("(9)99 999 9999");
   $("#ship_cell").mask("(9)99 999 9999");
   $("#cell").mask("(9)99 999 9999");
   $("#tin").mask("99-9999999");
   $("#ssn").mask("999-99-9999");
   $("#discount_exp").mask("99/9999");
	$("#bill_phone_day").mask("(9)99 999 9999");
	$("#bill_phone_eve").mask("(9)99 999 9999");
	$("#ship_phone").mask("(9)99 999 9999");
});





