function keq_disable(idy,par_id) {
  input = document.getElementById(idy);
  par = document.getElementById(par_id);

  if(par.checked == true) {
    input.disabled = false;
  } else {
    input.disabled = true;
  }
}

$(document).ready(function() {
        $('#keq_13_47_text').val('Please specify');

        // get the select
        var $dd = $('#keq_3');
        if ($dd.length > 0) { // make sure we found the select we were looking for

            // save the selected value
            var selectedVal = $dd.val();

            // get the options and loop through them
            var $options = $('option', $dd);
            var arrVals = [];
            $options.each(function(){
                // push each option value and text into an array
                arrVals.push({
                    val: $(this).val(),
                    text: $(this).text()
                });
            });

            // sort the array by the value (change val to text to sort by text instead)
            arrVals.sort(function(a, b){
                return a.val - b.val;
            });

            // loop through the sorted array and set the text/values to the options
            for (var i = 0, l = arrVals.length; i < l; i++) {
                $($options[i]).val(arrVals[i].val).text(arrVals[i].text);
            }

            // set the selected value back
            $dd.val(selectedVal);
        }


        $('#keq_next').click(function() {




                $("#survey_error").hide();
                $(".error").hide();
                var hasError = false;
                var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;


                var emailaddressVal = $("#survey_email").val();
                if(emailaddressVal == '') {
                    $("#survey_email").after('<span class="error">Please enter your email address.</span>');
                    hasError = true;
                } else if(!emailReg.test(emailaddressVal)) {
                    $("#survey_email").after('<span class="error">Enter a valid email address.</span>');
                    hasError = true;
                } else if($("#survey_company").val() == "") {
                    $("#survey_company").after('<span class="error">You must specify a company</span>');
                    hasError = true;
                }

                if(hasError == true) { return false; }
                else {
                    return true;
                }
    });
});


		$(document).ready(function() {

		var strURL	=	window.location.href;

		if(strURL.search(/msg=invalid/)  > 0  )
		{
			tb_show("", "index.php?id=9&succ=0&login=1&keepThis=true&TB_iframe=true&height=233&width=380", "")
		}
		if(strURL.search(/login=1/)  > 0  )
		{

			jQuery("#rightSide").css("display", "none");
			jQuery("#footer").css("display", "none");
			jQuery(".header").css("display", "none");
			jQuery("#div_topmenu").css("display", "none");

			jQuery("body").css("background-color", "#fff");
			jQuery("body").css("padding",0);
			jQuery("#container").css("width","380px");
			jQuery("#container").css("padding","0px");
			jQuery("#wrapper").css("width","380px");
			jQuery("#letfside").css("width","380px");
			jQuery("leftsideContain").css("width","380px");

			if(jQuery("#frmlogin").attr('id')!=null) {
				jQuery("#frmlogin").validationEngine({
					success :  false,
					failure : function() {}
				});
			}

		}
		if(strURL.search(/register=1/)  > 0  )
		{


			jQuery("#rightSide").css("display", "none");
			jQuery("#footer").css("display", "none");
			jQuery(".header").css("display", "none");
			jQuery("#div_topmenu").css("display", "none");

			jQuery("body").css("background-color", "#fff");
			jQuery("body").css("padding",0);
			jQuery("#container").css("width","655px");
			jQuery("#container").css("padding","0px");
			jQuery("#wrapper").css("width","655px");
			jQuery("#letfside").css("width","655px");
			jQuery("leftsideContain").css("width","655px");

			if(jQuery("#register").attr('id')!=null) {
				jQuery("#register").validationEngine({
					success :  false,
					failure : function() {}
				});
			}

		}

		if(strURL.search(/id=30/)  > 0  )
		{

			jQuery("#rightSide").css("display", "none");
			jQuery("#footer").css("display", "none");
			jQuery(".header").css("display", "none");
			jQuery("#div_topmenu").css("display", "none");
			jQuery("#div_today_date").css("display", "none");

			jQuery("body").css("background-color", "#fff");
			jQuery("body").css("padding",0);
			jQuery("#container").css("width","657px");
			jQuery("#container").css("padding","0px");
			jQuery("#wrapper").css("width","657px");
			jQuery("#letfside").css("width","657px");
			jQuery("leftsideContain").css("width","657px");

			if($("#subnewsid").val()=='1')
			{
				self.parent.document.getElementById("TB_window").style.width='670px';
				self.parent.document.getElementById('TB_iframeContent').style.height = '195px';
				self.parent.document.getElementById("TB_iframeContent").style.width='670px';
			}
			else if($("#subnewsid").val()=='2')
			{
				self.parent.document.getElementById("TB_window").style.width='670px';
				self.parent.document.getElementById('TB_iframeContent').style.height = '266px';
				self.parent.document.getElementById("TB_iframeContent").style.width='670px';
			}
			else if($("#subnewsid").val()=='3')
			{
				self.parent.document.getElementById("TB_window").style.width='657px';
				self.parent.document.getElementById('TB_iframeContent').style.height = '148px';
				self.parent.document.getElementById("TB_iframeContent").style.width='657px';
			}
			else
			{
				self.parent.document.getElementById("TB_window").style.width='680px';
				self.parent.document.getElementById('TB_iframeContent').style.height = '620px';
				self.parent.document.getElementById("TB_iframeContent").style.width='680px';
			}


			if(jQuery("#tt_address_form").attr('id')!=null) {
				jQuery("#tt_address_form").validationEngine({
					success :  false,
					failure : function() {}
				});
			}

		}

		if(jQuery("#frmcomment").attr('id')!=null) {
				jQuery("#frmcomment").validationEngine({
					success :  false,
					failure : function() {}
				});
		}

		if(jQuery("#jd_poll").attr('id')!=null) {
				jQuery("#jd_poll").validationEngine({
					success :  false,
					failure : function() {}
				});
		}

		//$(".subscribeNow a").attr("href", "http://e-travelafrica.com/index.php?id=30&newsletter=1&keepThis=true&TB_iframe=true&height=576&width=660");
		//$(".subscribeNow a").attr("class", "thickbox");



		});


